[Lutinutil-commits] r1647 - in trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin: . parser parser/impl
Author: tchemit Date: 2009-07-27 22:23:21 +0200 (Mon, 27 Jul 2009) New Revision: 1647 Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nPlugin.java trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/Bundle.java trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/Generate.java trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/Getter.java trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/AbstractI18nParser.java trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJaxx.java trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserSwixat.java trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserXml.java Log: add silent parameter to hide all messages Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nPlugin.java =================================================================== --- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nPlugin.java 2009-07-23 20:14:25 UTC (rev 1646) +++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nPlugin.java 2009-07-27 20:23:21 UTC (rev 1647) @@ -108,6 +108,13 @@ */ protected boolean verbose; /** + * silent flag + * + * @parameter expression="${i18n.silent}" default-value="false" + * @since 1.0.0-rc-5 + */ + protected boolean silent; + /** * conserve les anciens fichiers de traduction avec un suffix ~ * <p/> * Note: par defaut, on ne l'active pas. @@ -259,7 +266,7 @@ } getLog().warn(buffer.toString()); } else { - if (verbose) { + if (!silent && verbose) { getLog().info("bundle " + locale + " is valid (no empty entries)."); } } Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/Bundle.java =================================================================== --- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/Bundle.java 2009-07-23 20:14:25 UTC (rev 1646) +++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/Bundle.java 2009-07-27 20:23:21 UTC (rev 1647) @@ -38,7 +38,6 @@ import org.apache.maven.artifact.resolver.ArtifactCollector; import org.apache.maven.artifact.resolver.filter.ArtifactFilter; import org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter; -import org.apache.maven.model.Resource; import org.apache.maven.project.MavenProject; import org.apache.maven.project.MavenProjectBuilder; import org.apache.maven.shared.dependency.tree.DependencyNode; @@ -193,9 +192,11 @@ i18nArtifacts = detectI18nArtifacts(); - getLog().info("detected " + i18nArtifacts.length + " i18n artifact(s) : "); - for (I18nArtifact a : i18nArtifacts) { - getLog().info(" - " + a); + if (!silent) { + getLog().info("detected " + i18nArtifacts.length + " i18n artifact(s) : "); + for (I18nArtifact a : i18nArtifacts) { + getLog().info(" - " + a); + } } } catch (Exception ex) { throw new RuntimeException(ex); @@ -221,10 +222,11 @@ init(); - getLog().info("config - bundle name : " + bundleOutputName); - getLog().info("config - baseidr : " + bundleOutputDir); - getLog().info("config - locales : " + Arrays.toString(locales)); - + if (!silent) { + getLog().info("config - bundle name : " + bundleOutputName); + getLog().info("config - baseidr : " + bundleOutputDir); + getLog().info("config - locales : " + Arrays.toString(locales)); + } // la locale par defaut est la première Locale defaultLocale = locales[0]; @@ -238,7 +240,9 @@ File bundleOut = getI18nFile(bundleOutputDir, bundleOutputName, locale, false); - getLog().info("generate bundle for locale " + locale); + if (!silent) { + getLog().info("generate bundle for locale " + locale); + } SortedProperties propertiesOut = new SortedProperties(encoding, false); StringBuilder buffer = new StringBuilder(); @@ -258,10 +262,12 @@ } if (buffer.length() > 0) { bundleDico.put(locale, buffer.substring(1)); - getLog().info("bundles for locale : " + bundleDico.get(locale)); + if (!silent) { + getLog().info("bundles for locale : " + bundleDico.get(locale)); + } } propertiesOut.store(bundleOut); - if (verbose) { + if (!silent && verbose) { getLog().info("bundle created in " + PluginHelper.convertTime(t0, System.nanoTime()) + " (detected sentences : " + propertiesOut.size() + ")"); } if (checkBundle) { @@ -274,7 +280,9 @@ // charger String f = String.format(I18nBundleFactory.UNIQUE_BUNDLE_DEF, bundleOutputName); File defOut = new File(bundleOutputDir, f); - getLog().info("prepare i18n definition " + defOut.getAbsolutePath()); + if (!silent) { + getLog().info("prepare i18n definition " + defOut.getAbsolutePath()); + } SortedProperties p = new SortedProperties(encoding, false); p.setProperty(I18nBundleFactory.BUNDLE_DEF_LOCALES, bundles); for (Entry<Locale, String> e : bundleDico.entrySet()) { @@ -282,7 +290,7 @@ } p.store(new FileOutputStream(defOut), null); - if (verbose) { + if (!silent && verbose) { getLog().info("done in " + PluginHelper.convertTime(t00, System.nanoTime())); } } catch (IOException e) { @@ -309,12 +317,12 @@ for (Object o : project.getArtifacts()) { i18nArtifact = new I18nArtifact((Artifact) o); if (i18nArtifact.detectBundles()) { - if (getLog().isDebugEnabled()) { + if (!silent && getLog().isDebugEnabled()) { getLog().debug("detected artifact " + i18nArtifact); } dico.put(i18nArtifact.getArtifact(), i18nArtifact); } else { - if (getLog().isDebugEnabled()) { + if (!silent && getLog().isDebugEnabled()) { getLog().debug("reject artifact " + i18nArtifact); } } @@ -336,7 +344,7 @@ i18nArtifact = new I18nArtifact(projectArtifact, src.getParentFile()); if (i18nArtifact.detectBundles()) { - if (verbose) { + if (!silent && verbose) { getLog().info("detected artifact " + i18nArtifact); } artifacts.add(i18nArtifact.getArtifact()); Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/Generate.java =================================================================== --- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/Generate.java 2009-07-23 20:14:25 UTC (rev 1646) +++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/Generate.java 2009-07-27 20:23:21 UTC (rev 1647) @@ -64,12 +64,15 @@ return; } - getLog().info("config - src basedir : " + src.getAbsolutePath()); - getLog().info("config - out basedir : " + out.getAbsolutePath()); - getLog().info("config - locales : " + Arrays.toString(locales)); - + if (!silent) { + getLog().info("config - src basedir : " + src.getAbsolutePath()); + getLog().info("config - out basedir : " + out.getAbsolutePath()); + getLog().info("config - locales : " + Arrays.toString(locales)); + } for (Locale locale : locales) { - getLog().info("prepare bundle for locale " + locale); + if (!silent) { + getLog().info("prepare bundle for locale " + locale); + } try { // Merge File bundleSrc = getI18nFile(src, artifactId, locale, false); @@ -114,7 +117,9 @@ if (genSrc && keepBackup) { backupFile(bundleSrc); } - getLog().info("merge bundle " + locale + " to out"); + if (!silent) { + getLog().info("merge bundle " + locale + " to out"); + } if (checkBundle) { checkBundle(locale, propertiesOut, showEmpty); @@ -124,7 +129,9 @@ // Copie des fichiers dans les sources copyFile(bundleOut, bundleSrc); //if (verbose) { - getLog().info("copy bundle " + locale + " to src"); + if (!silent) { + getLog().info("copy bundle " + locale + " to src"); + } //} } Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/Getter.java =================================================================== --- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/Getter.java 2009-07-23 20:14:25 UTC (rev 1646) +++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/Getter.java 2009-07-27 20:23:21 UTC (rev 1647) @@ -52,10 +52,11 @@ } return; } + if (!silent) { + getLog().info("config - basedir : " + out.getAbsolutePath()); + getLog().info("config - locales : " + Arrays.toString(locales)); + } - getLog().info("config - basedir : " + out.getAbsolutePath()); - getLog().info("config - locales : " + Arrays.toString(locales)); - try { File bundleGetters = new File(out.getAbsolutePath() + File.separatorChar + artifactId + ".properties"); bundleGetters.createNewFile(); @@ -74,17 +75,19 @@ if (genSrc) { bundleGetter.delete(); } - getLog().info("import getter " + bundleGetter.getName() + " in " + PluginHelper.convertTime(System.nanoTime() - t0)); + if (!silent) { + getLog().info("import getter " + bundleGetter.getName() + " in " + PluginHelper.convertTime(System.nanoTime() - t0)); + } } // Création des bundles for (Locale locale : locales) { - if (getLog().isDebugEnabled()) { + if (!silent && getLog().isDebugEnabled()) { getLog().debug("generate bundle for locale " + locale); } File bundleOut = getI18nFile(out, artifactId, locale, false); copyFile(bundleGetters, bundleOut); - if (verbose) { + if (!silent && verbose) { getLog().info("generate bundle " + locale); } } Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/AbstractI18nParser.java =================================================================== --- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/AbstractI18nParser.java 2009-07-23 20:14:25 UTC (rev 1646) +++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/AbstractI18nParser.java 2009-07-27 20:23:21 UTC (rev 1647) @@ -107,7 +107,7 @@ addParserEvent(KeysModifier.getInstance(getKeyModifierStart(), getKeyModifierEnd(), encoding)); } treadedFiles = new ArrayList<File>(); - if (verbose) { + if (!silent && verbose) { showTouchedFiles = true; } } @@ -126,10 +126,10 @@ return; } - if (safeMode) { + if (!silent && safeMode) { getLog().info("config - safeMode is on (could be slower)."); } - if (strictMode) { + if (!silent && strictMode) { getLog().info("config - strictMode is on (all files will be parsed)."); } @@ -156,9 +156,13 @@ int i = treadedFiles.size(); if (fileTreated == 0) { - getLog().info("Nothing to generate - all files are up to date."); + if (!silent) { + getLog().info("Nothing to generate - all files are up to date."); + } } else { - getLog().info(getVerboseLog().getLogEntry("parsing is done. [treated file(s) : " + i + '/' + fileTreated + "]", fileTreated, 0, t0)); + if (!silent) { + getLog().info(getVerboseLog().getLogEntry("parsing is done. [treated file(s) : " + i + '/' + fileTreated + "]", fileTreated, 0, t0)); + } addGetter(); } @@ -188,7 +192,7 @@ boolean skip = entry.init(this); if (skip) { - if (verbose) { + if (!silent && verbose) { getLog().info("skip - " + entry.getSkipMessage()); } continue; @@ -196,14 +200,14 @@ long t000 = System.nanoTime(); int nbFiles = entry.getFiles().length; - if (verbose) { + if (!silent && verbose) { vLog.infoEntry("start", vLog.getLogEntry("[incoming file(s) : " + entry.getFoudFiles() + "]", 0, 0, 0)); } // launch parser for found files parseEntry(entry); - if (verbose) { + if (!silent && verbose) { // log skipped files for (String skipFile : entry.getSkipFiles()) { vLog.setFile(new File(entry.getBasedir(), skipFile)); @@ -211,7 +215,7 @@ } } fileTreated += nbFiles; - if (verbose) { + if (!silent && verbose) { vLog.infoEntry("end", vLog.getLogEntry("[treated file(s) : " + nbFiles + "]", nbFiles, t000, t00)); } t00 = System.nanoTime(); @@ -258,7 +262,7 @@ touchFile = false; int size = result.size(); - if (verbose) { + if (!silent && verbose) { vLog.infoFile("parse", null); } parseFile(file); Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJaxx.java =================================================================== --- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJaxx.java 2009-07-23 20:14:25 UTC (rev 1646) +++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJaxx.java 2009-07-27 20:23:21 UTC (rev 1647) @@ -30,7 +30,10 @@ * @author julien * @goal parserJaxx * @phase generate-resources + * @deprecated since 1.0.0, prefer use the java parser since xml parser can not + * be easly extendable */ +@Deprecated public class ParserJaxx extends ParserXml { /** Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserSwixat.java =================================================================== --- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserSwixat.java 2009-07-23 20:14:25 UTC (rev 1646) +++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserSwixat.java 2009-07-27 20:23:21 UTC (rev 1647) @@ -27,7 +27,9 @@ * @author julien * @goal parserSwixat * @phase generate-resources + * @deprecated since 1.0.0 : swixat is dead... */ +@Deprecated public class ParserSwixat extends ParserXml { /** Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserXml.java =================================================================== --- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserXml.java 2009-07-23 20:14:25 UTC (rev 1646) +++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserXml.java 2009-07-27 20:23:21 UTC (rev 1647) @@ -176,7 +176,7 @@ // load core rules readInputStream = loadRulesFile(getCoreFileRules()); - if (verbose) { + if (!silent && verbose) { getLog().info("core rules : " + getCoreFileRules()); } buffer.append(readInputStream); @@ -184,7 +184,7 @@ if (!fileRules.equals(getCoreFileRules())) { // add custom rules readInputStream = loadRulesFile(fileRules); - if (verbose) { + if (!silent && verbose) { getLog().info("custom rules : " + fileRules); } buffer.append(" | ").append(readInputStream);
participants (1)
-
tchemit@users.labs.libre-entreprise.org