Author: tchemit
Date: 2009-08-26 00:25:58 +0200 (Wed, 26 Aug 2009)
New Revision: 1661
Added:
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/I18nSourceEntry.java
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/impl/ParserJava.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/ParserValidation.java
Log:
fix bug [#27]
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-08-22 23:35:30 UTC (rev 1660)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/AbstractI18nParser.java 2009-08-25 22:25:58 UTC (rev 1661)
@@ -27,7 +27,6 @@
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.List;
import org.nuiton.util.SourceEntry;
@@ -68,7 +67,7 @@
*
* @parameter expression="${i18n.entries}"
*/
- protected MySourceEntry[] entries;
+ protected I18nSourceEntry[] entries;
/**
* flag to display touched files while parsing.
* <p/>
@@ -94,6 +93,10 @@
protected boolean touchFile;
protected List<File> treadedFiles;
+ public boolean isStrictMode() {
+ return strictMode;
+ }
+
@Override
public void init() {
super.init();
@@ -140,7 +143,6 @@
oldParser.load(oldParserFile);
copyFile(oldParserFile, saveFile);
-// FileUtil.copy(oldParserFile, saveFile);
// Anciennes cles disponnibles
//fixme : pourquoi on utilise un bundle precis ? le premier ici, je ne comprends pas
@@ -184,7 +186,7 @@
addDefaultEntry();
}
long t00 = System.nanoTime();
- for (MySourceEntry entry : this.entries) {
+ for (I18nSourceEntry entry : this.entries) {
I18nLogger vLog = getVerboseLog();
vLog.setEntry(entry);
@@ -228,15 +230,17 @@
* This is a convinient method to simplify the configuration of the plugin.
*/
protected void addDefaultEntry() {
- List<MySourceEntry> list;
-
- if (entries == null || entries.length == 0) {
- list = new ArrayList<MySourceEntry>();
- } else {
- list = new ArrayList<MySourceEntry>(Arrays.asList(entries));
+// List<MySourceEntry> list;
+ if (verbose) {
+ getLog().info("add default entry");
}
- list.add(new MySourceEntry());
- entries = list.toArray(new MySourceEntry[list.size()]);
+ boolean hasEntries = entries != null && entries.length > 0;
+ I18nSourceEntry[] tmp = new I18nSourceEntry[hasEntries ? entries.length + 1 : 1];
+ if (hasEntries) {
+ System.arraycopy(entries, 0, tmp, 0, entries.length);
+ }
+ tmp[tmp.length - 1] = new I18nSourceEntry();
+ entries = tmp;
}
/**
@@ -306,64 +310,4 @@
result.store(getterFile);
}
- public static class MySourceEntry extends SourceEntry {
-
- public boolean init(AbstractI18nParser mojo) {
- if (!useForGoal(mojo.getClass().getSimpleName())) {
- // skip not for this goal
- skipMessage = "exclude for this goal.";
- return true;
- }
-
- String[] filesForEntry = getFilesForEntry(mojo);
-
- if (filesForEntry.length == 0) {
- // skip no file found
- skipMessage = "no file found.";
- return true;
- }
- setUpdater(mojo.newFileUpdater(this));
-
- if (mojo.strictMode || updater == null) {
- // mojo strict mode or not updater, so force all files
- skipFiles = new String[0];
- this.files = filesForEntry;
- return false;
- }
-
- List<String> listFiles = new ArrayList<String>();
- List<String> listSkipFiles = new ArrayList<String>();
-
- // test if have any file
- for (String foundFile : filesForEntry) {
- File file = new File(getBasedir(), foundFile);
- if (isFileUptodate(file)) {
- listSkipFiles.add(foundFile);
- } else {
- listFiles.add(foundFile);
- }
- }
- boolean todo = !listFiles.isEmpty();
- if (!todo) {
- // skip, no file out-of -date
- skipMessage = "all files are up to date.";
- this.skipFiles = listSkipFiles.toArray(new String[listSkipFiles.size()]);
- this.files = new String[0];
- return true;
- }
- this.skipFiles = listSkipFiles.toArray(new String[listSkipFiles.size()]);
- this.files = listFiles.toArray(new String[listFiles.size()]);
- return false;
- }
-
- /**
- * Obtain all the relative path of files to treate for a given entry.
- *
- * @param mojo the given mojo
- * @return the list of relative path of files for the given entry
- */
- protected String[] getFilesForEntry(AbstractI18nParser mojo) {
- return getIncludedFiles(mojo.getDefaultBasedir(), mojo.getDefaultIncludes(), mojo.getDefaultExcludes());
- }
- }
}
Added: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/I18nSourceEntry.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/I18nSourceEntry.java (rev 0)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/I18nSourceEntry.java 2009-08-25 22:25:58 UTC (rev 1661)
@@ -0,0 +1,72 @@
+package org.nuiton.i18n.plugin.parser;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+import org.nuiton.util.SourceEntry;
+
+/**
+ * Customized {@link SourceEntry} for parsers goals.
+ *
+ * @author chemit
+ */
+public class I18nSourceEntry extends SourceEntry {
+
+ public boolean init(AbstractI18nParser mojo) {
+ if (!useForGoal(mojo.getClass().getSimpleName())) {
+ // skip not for this goal
+ skipMessage = "exclude for this goal.";
+ return true;
+ }
+
+ String[] filesForEntry = getFilesForEntry(mojo);
+
+ if (filesForEntry.length == 0) {
+ // skip no file found
+ skipMessage = "no file found.";
+ return true;
+ }
+ setUpdater(mojo.newFileUpdater(this));
+
+ if (mojo.isStrictMode() || updater == null) {
+ // mojo strict mode or not updater, so force all files
+ skipFiles = new String[0];
+ this.files = filesForEntry;
+ return false;
+ }
+
+ List<String> listFiles = new ArrayList<String>();
+ List<String> listSkipFiles = new ArrayList<String>();
+
+ // test if have any file
+ for (String foundFile : filesForEntry) {
+ File file = new File(getBasedir(), foundFile);
+ if (isFileUptodate(file)) {
+ listSkipFiles.add(foundFile);
+ } else {
+ listFiles.add(foundFile);
+ }
+ }
+ boolean todo = !listFiles.isEmpty();
+ if (!todo) {
+ // skip, no file out-of -date
+ skipMessage = "all files are up to date.";
+ this.skipFiles = listSkipFiles.toArray(new String[listSkipFiles.size()]);
+ this.files = new String[0];
+ return true;
+ }
+ this.skipFiles = listSkipFiles.toArray(new String[listSkipFiles.size()]);
+ this.files = listFiles.toArray(new String[listFiles.size()]);
+ return false;
+ }
+
+ /**
+ * Obtain all the relative path of files to treate for a given entry.
+ *
+ * @param mojo the given mojo
+ * @return the list of relative path of files for the given entry
+ */
+ protected String[] getFilesForEntry(AbstractI18nParser mojo) {
+ return getIncludedFiles(mojo.getDefaultBasedir(), mojo.getDefaultIncludes(), mojo.getDefaultExcludes());
+ }
+}
Property changes on: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/I18nSourceEntry.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJava.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJava.java 2009-08-22 23:35:30 UTC (rev 1660)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJava.java 2009-08-25 22:25:58 UTC (rev 1661)
@@ -44,7 +44,7 @@
/**
* Source entries (src+includes+excludes) .
*
- * @parameter expression="${i18n.defaultIncludes}" default-value="**\\/*.java"
+ * @parameter expression="${i18n.defaultIncludes}" default-value="**\/*.java"
*/
protected String defaultIncludes;
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-08-22 23:35:30 UTC (rev 1660)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJaxx.java 2009-08-25 22:25:58 UTC (rev 1661)
@@ -39,7 +39,7 @@
/**
* Source entries (src+includes+excludes) .
*
- * @parameter expression="${i18n.defaultIncludes}" default-value="**\\/*.jaxx"
+ * @parameter expression="${i18n.defaultIncludes}" default-value="**\/*.jaxx"
*/
protected String defaultIncludes;
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-08-22 23:35:30 UTC (rev 1660)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserSwixat.java 2009-08-25 22:25:58 UTC (rev 1661)
@@ -35,14 +35,14 @@
/**
* Source entries (src+includes) .
*
- * @parameter expression="${i18n.defaultIncludes}" default-value="**\\/*.xml"
+ * @parameter expression="${i18n.defaultIncludes}" default-value="**\/*.xml"
*/
protected String defaultIncludes;
/**
* Source entries (src+excludes) .
*
- * @parameter expression="${i18n.defaultIncludes}" default-value="**\\/context.xml"
+ * @parameter expression="${i18n.defaultIncludes}" default-value="**\/context.xml"
*/
protected String defaultExcludes;
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserValidation.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserValidation.java 2009-08-22 23:35:30 UTC (rev 1660)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserValidation.java 2009-08-25 22:25:58 UTC (rev 1661)
@@ -47,7 +47,7 @@
/**
* Source entries (src+includes+excludes) .
*
- * @parameter expression="${i18n.defaultIncludes}" default-value="**\\/**-validation.xml"
+ * @parameter expression="${i18n.defaultIncludes}" default-value="**\/**-validation.xml"
*/
protected String defaultIncludes;
/**