[Lutinutil-commits] r1340 - in maven-i18n-plugin/trunk: . src/main/java/org/codelutin/i18n/plugin/parser src/main/java/org/codelutin/i18n/plugin/parser/impl
Author: tchemit Date: 2009-02-14 11:27:26 +0000 (Sat, 14 Feb 2009) New Revision: 1340 Modified: maven-i18n-plugin/trunk/changelog.txt maven-i18n-plugin/trunk/src/main/java/org/codelutin/i18n/plugin/parser/AbstractI18nParser.java maven-i18n-plugin/trunk/src/main/java/org/codelutin/i18n/plugin/parser/impl/ParserXml.java Log: add safeMode, showTouchedFiles properties in parser mojo (none safeMode will improve performance) Modified: maven-i18n-plugin/trunk/changelog.txt =================================================================== --- maven-i18n-plugin/trunk/changelog.txt 2009-02-11 09:56:20 UTC (rev 1339) +++ maven-i18n-plugin/trunk/changelog.txt 2009-02-14 11:27:26 UTC (rev 1340) @@ -1,4 +1,5 @@ 0.9 ??? 200902?? + * 20090214 [chemit] add safeMode, showTouchedFiles properties in parser mojo (none safeMode will improve performance) * 20090205 [chemit] use lutinproject 3.4 0.8 chemit 20090107 * 20081205 [chemit] modify ParserValidation (message can by suffix by ## to delimite args) Modified: maven-i18n-plugin/trunk/src/main/java/org/codelutin/i18n/plugin/parser/AbstractI18nParser.java =================================================================== --- maven-i18n-plugin/trunk/src/main/java/org/codelutin/i18n/plugin/parser/AbstractI18nParser.java 2009-02-11 09:56:20 UTC (rev 1339) +++ maven-i18n-plugin/trunk/src/main/java/org/codelutin/i18n/plugin/parser/AbstractI18nParser.java 2009-02-14 11:27:26 UTC (rev 1340) @@ -76,6 +76,24 @@ */ protected MySourceEntry[] entries; + /** + * flag to display touched files while parsing. + * <p/> + * Note: the value will be always <code>true</code> if {@link #verbose} is set + * at <code>true</code>. + * + * @parameter expression="${i18n.showTouchedFiles}" default-value="${maven.verbose}" + * @since 0.9 + */ + protected boolean showTouchedFiles; + /** + * flag to save at eachfile treated the getter file + * + * @parameter expression="${i18n.safeMode}" default-value="false" + * @since 0.9 + */ + protected boolean safeMode; + protected I18nProperties result; protected I18nProperties oldParser; @@ -103,6 +121,9 @@ addParserEvent(KeysModifier.getInstance(getKeyModifierStart(), getKeyModifierEnd(), encoding)); } treadedFiles = new ArrayList<File>(); + if (verbose) { + showTouchedFiles = true; + } } @@ -119,6 +140,14 @@ // nothing to do return; } + + if (safeMode) { + getLog().infoAction("[config]"," safeMode is active (could be slower)."); + } + if (strictMode) { + getLog().infoAction("[config]"," strictMode is active (all files will be parsed)."); + } + try { // Reprise sur un ancien parsing File oldParserFile = PluginHelper.getGetterFile(out, getOutGetter(), true); @@ -227,6 +256,7 @@ protected final void parseEntry(SourceEntry entry) throws IOException { long t00 = System.nanoTime(); String[] files = entry.getFiles(); + int beforeEntryResultSize = result.size(); for (int i = 0, max = files.length; i < max; i++) { String file1 = files[i]; long t000 = System.nanoTime(); @@ -244,12 +274,19 @@ } parseFile(file); + //TC-20090214 pour des questions de performance, on ne sauvegarde pas + // a chaque traitement de fichier, les clefs mais une fois pour chaque + // source entry // Detection de nouvelles cles, sauvegarde du fichier pour pouvoir le restaurer en cas de plantage - if (size != result.size()) { - saveGetterFile(); + if (safeMode) { + if (size != result.size()) { + saveGetterFile(); + } } if (touchFile) { - getLog().infoFile("touch", null); + if (showTouchedFiles) { + getLog().infoFile("touch", null); + } treadedFiles.add(file); if (getLog().isDebugEnabled()) { getLog().debug(getLog().getLogEntry(fileName, i, t000, t00)); @@ -259,6 +296,11 @@ event.eventNextFile(file); } } + + if (!safeMode && beforeEntryResultSize < result.size()) { + // Detection de nouvelles cles, sauvegarde du fichier + saveGetterFile(); + } } /** @@ -302,6 +344,10 @@ print(2, "INFO", action, file.toString() + (content == null ? "" : " - " + content)); } + public void infoAction(String action, String content) { + print(2, "INFO", action, (content == null ? "" : " - " + content)); + } + private void print(int start, String prefix, String context, String content) { StringBuilder sb = new StringBuilder(); sb.append("[").append(prefix).append("] [").append(parser).append("] "); Modified: maven-i18n-plugin/trunk/src/main/java/org/codelutin/i18n/plugin/parser/impl/ParserXml.java =================================================================== --- maven-i18n-plugin/trunk/src/main/java/org/codelutin/i18n/plugin/parser/impl/ParserXml.java 2009-02-11 09:56:20 UTC (rev 1339) +++ maven-i18n-plugin/trunk/src/main/java/org/codelutin/i18n/plugin/parser/impl/ParserXml.java 2009-02-14 11:27:26 UTC (rev 1340) @@ -99,10 +99,11 @@ Node node = list.item(index); parseLine(file, node.getTextContent()); } - - // Détection de nouvelles clés, sauvegarde du fichier pour pouvoir le restaurer en cas de plantage - if (size != result.size()) { - saveGetterFile(); + if (safeMode) { + // Détection de nouvelles clés, sauvegarde du fichier pour pouvoir le restaurer en cas de plantage + if (size != result.size()) { + saveGetterFile(); + } } } catch (Exception e) { throw new ParserException(e);
participants (1)
-
tchemit@users.labs.libre-entreprise.org