I18n-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- 802 discussions
r1737 - trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl
by tchemit@users.nuiton.org 03 Apr '10
by tchemit@users.nuiton.org 03 Apr '10
03 Apr '10
Author: tchemit
Date: 2010-04-03 21:36:06 +0200 (Sat, 03 Apr 2010)
New Revision: 1737
Log:
add debug log to show all keys detected by file
Modified:
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJavaMojo.java
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJavaMojo.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJavaMojo.java 2010-04-03 09:44:25 UTC (rev 1736)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJavaMojo.java 2010-04-03 19:36:06 UTC (rev 1737)
@@ -154,6 +154,9 @@
// Found a set of i18n Strings, split it.
String[] keys = keysSet.split("=");
for (String key : keys) {
+ if (getLog().isDebugEnabled()) {
+ getLog().debug(file.getName()+" detected key = " + key);
+ }
registerKey(key);
}
}
1
0
r1736 - in trunk: . ant-i18n-task maven-i18n-plugin nuiton-i18n
by tchemit@users.nuiton.org 03 Apr '10
by tchemit@users.nuiton.org 03 Apr '10
03 Apr '10
Author: tchemit
Date: 2010-04-03 11:44:25 +0200 (Sat, 03 Apr 2010)
New Revision: 1736
Log:
[maven-release-plugin] prepare for next development iteration
Modified:
trunk/ant-i18n-task/pom.xml
trunk/maven-i18n-plugin/pom.xml
trunk/nuiton-i18n/pom.xml
trunk/pom.xml
Modified: trunk/ant-i18n-task/pom.xml
===================================================================
--- trunk/ant-i18n-task/pom.xml 2010-04-03 09:44:21 UTC (rev 1735)
+++ trunk/ant-i18n-task/pom.xml 2010-04-03 09:44:25 UTC (rev 1736)
@@ -10,7 +10,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>i18n</artifactId>
- <version>1.2.1</version>
+ <version>1.2.2-SNAPSHOT</version>
</parent>
<groupId>org.nuiton.i18n</groupId>
Modified: trunk/maven-i18n-plugin/pom.xml
===================================================================
--- trunk/maven-i18n-plugin/pom.xml 2010-04-03 09:44:21 UTC (rev 1735)
+++ trunk/maven-i18n-plugin/pom.xml 2010-04-03 09:44:25 UTC (rev 1736)
@@ -9,7 +9,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>i18n</artifactId>
- <version>1.2.1</version>
+ <version>1.2.2-SNAPSHOT</version>
</parent>
<groupId>org.nuiton.i18n</groupId>
Modified: trunk/nuiton-i18n/pom.xml
===================================================================
--- trunk/nuiton-i18n/pom.xml 2010-04-03 09:44:21 UTC (rev 1735)
+++ trunk/nuiton-i18n/pom.xml 2010-04-03 09:44:25 UTC (rev 1736)
@@ -10,7 +10,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>i18n</artifactId>
- <version>1.2.1</version>
+ <version>1.2.2-SNAPSHOT</version>
</parent>
<groupId>org.nuiton.i18n</groupId>
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-04-03 09:44:21 UTC (rev 1735)
+++ trunk/pom.xml 2010-04-03 09:44:25 UTC (rev 1736)
@@ -13,7 +13,7 @@
</parent>
<artifactId>i18n</artifactId>
- <version>1.2.1</version>
+ <version>1.2.2-SNAPSHOT</version>
<modules>
<module>nuiton-i18n</module>
@@ -233,9 +233,9 @@
<!-- Source control management. -->
<scm>
- <connection>scm:svn:http://svn.nuiton.org/svn/i18n/tags/i18n-1.2.1</connection>
- <developerConnection>scm:svn:http://svn.nuiton.org/svn/i18n/tags/i18n-1.2.1</developerConnection>
- <url>http://www.nuiton.org/repositories/browse/i18n/tags/i18n-1.2.1</url>
+ <connection>scm:svn:http://svn.nuiton.org/svn/i18n/trunk</connection>
+ <developerConnection>scm:svn:http://svn.nuiton.org/svn/i18n/trunk</developerConnection>
+ <url>http://www.nuiton.org/repositories/browse/i18n/trunk</url>
</scm>
</project>
1
0
Author: tchemit
Date: 2010-04-03 11:44:21 +0200 (Sat, 03 Apr 2010)
New Revision: 1735
Log:
[maven-release-plugin] copy for tag i18n-1.2.1
Added:
tags/i18n-1.2.1/
1
0
r1734 - in trunk: . ant-i18n-task maven-i18n-plugin nuiton-i18n
by tchemit@users.nuiton.org 03 Apr '10
by tchemit@users.nuiton.org 03 Apr '10
03 Apr '10
Author: tchemit
Date: 2010-04-03 11:44:19 +0200 (Sat, 03 Apr 2010)
New Revision: 1734
Log:
[maven-release-plugin] prepare release i18n-1.2.1
Modified:
trunk/ant-i18n-task/pom.xml
trunk/maven-i18n-plugin/pom.xml
trunk/nuiton-i18n/pom.xml
trunk/pom.xml
Modified: trunk/ant-i18n-task/pom.xml
===================================================================
--- trunk/ant-i18n-task/pom.xml 2010-04-03 09:38:02 UTC (rev 1733)
+++ trunk/ant-i18n-task/pom.xml 2010-04-03 09:44:19 UTC (rev 1734)
@@ -10,7 +10,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>i18n</artifactId>
- <version>1.2.1-SNAPSHOT</version>
+ <version>1.2.1</version>
</parent>
<groupId>org.nuiton.i18n</groupId>
Modified: trunk/maven-i18n-plugin/pom.xml
===================================================================
--- trunk/maven-i18n-plugin/pom.xml 2010-04-03 09:38:02 UTC (rev 1733)
+++ trunk/maven-i18n-plugin/pom.xml 2010-04-03 09:44:19 UTC (rev 1734)
@@ -1,7 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
@@ -11,7 +9,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>i18n</artifactId>
- <version>1.2.1-SNAPSHOT</version>
+ <version>1.2.1</version>
</parent>
<groupId>org.nuiton.i18n</groupId>
Modified: trunk/nuiton-i18n/pom.xml
===================================================================
--- trunk/nuiton-i18n/pom.xml 2010-04-03 09:38:02 UTC (rev 1733)
+++ trunk/nuiton-i18n/pom.xml 2010-04-03 09:44:19 UTC (rev 1734)
@@ -10,7 +10,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>i18n</artifactId>
- <version>1.2.1-SNAPSHOT</version>
+ <version>1.2.1</version>
</parent>
<groupId>org.nuiton.i18n</groupId>
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-04-03 09:38:02 UTC (rev 1733)
+++ trunk/pom.xml 2010-04-03 09:44:19 UTC (rev 1734)
@@ -13,7 +13,7 @@
</parent>
<artifactId>i18n</artifactId>
- <version>1.2.1-SNAPSHOT</version>
+ <version>1.2.1</version>
<modules>
<module>nuiton-i18n</module>
@@ -233,9 +233,9 @@
<!-- Source control management. -->
<scm>
- <connection>scm:svn:http://svn.nuiton.org/svn/i18n/trunk</connection>
- <developerConnection>scm:svn:http://svn.nuiton.org/svn/i18n/trunk</developerConnection>
- <url>http://www.nuiton.org/repositories/browse/i18n/trunk</url>
+ <connection>scm:svn:http://svn.nuiton.org/svn/i18n/tags/i18n-1.2.1</connection>
+ <developerConnection>scm:svn:http://svn.nuiton.org/svn/i18n/tags/i18n-1.2.1</developerConnection>
+ <url>http://www.nuiton.org/repositories/browse/i18n/tags/i18n-1.2.1</url>
</scm>
</project>
1
0
r1733 - in trunk/maven-i18n-plugin/src: it/parsers/newProject it/parsers/withNewKeys main/java/org/nuiton/i18n/plugin main/java/org/nuiton/i18n/plugin/parser
by tchemit@users.nuiton.org 03 Apr '10
by tchemit@users.nuiton.org 03 Apr '10
03 Apr '10
Author: tchemit
Date: 2010-04-03 11:38:02 +0200 (Sat, 03 Apr 2010)
New Revision: 1733
Log:
finalize fix bug #438 + improve design and integration tests
Added:
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/I18nParserConfiguration.java
Modified:
trunk/maven-i18n-plugin/src/it/parsers/newProject/invoker.properties
trunk/maven-i18n-plugin/src/it/parsers/newProject/pom.xml
trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/invoker.properties
trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/pom.xml
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nMojo.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/GenerateMojo.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/AbstractFileParser.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/AbstractI18nParserMojo.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/FileParser.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/ParserThread.java
Modified: trunk/maven-i18n-plugin/src/it/parsers/newProject/invoker.properties
===================================================================
--- trunk/maven-i18n-plugin/src/it/parsers/newProject/invoker.properties 2010-04-02 20:02:13 UTC (rev 1732)
+++ trunk/maven-i18n-plugin/src/it/parsers/newProject/invoker.properties 2010-04-03 09:38:02 UTC (rev 1733)
@@ -1,6 +1,6 @@
# A comma or space separated list of goals/phases to execute, may
# specify an empty list to execute the default goal of the IT project
-invoker.goals=clean process-resources
+invoker.goals=clean compile
# Optionally, a list of goals to run during further invocations of Maven
#invoker.goals.2=${project.groupId}:${project.artifactId}:${project.version}:run
Modified: trunk/maven-i18n-plugin/src/it/parsers/newProject/pom.xml
===================================================================
--- trunk/maven-i18n-plugin/src/it/parsers/newProject/pom.xml 2010-04-02 20:02:13 UTC (rev 1732)
+++ trunk/maven-i18n-plugin/src/it/parsers/newProject/pom.xml 2010-04-03 09:38:02 UTC (rev 1733)
@@ -15,6 +15,7 @@
<version>@pom.version@</version>
</parent>
+ <groupId>org.nuiton.i18n</groupId>
<artifactId>parsers-newProject</artifactId>
<!-- ************************************************************* -->
@@ -29,15 +30,17 @@
<packaging>jar</packaging>
- <properties>
- <i18nVersion>@pom.version@</i18nVersion>
+ <dependencies>
- <!-- default encoding -->
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>nuiton-i18n</artifactId>
+ <version>${project.version}</version>
+ </dependency>
- </properties>
-
+ </dependencies>
+
<build>
<plugins>
@@ -45,27 +48,27 @@
<plugin>
<groupId>org.nuiton.i18n</groupId>
<artifactId>maven-i18n-plugin</artifactId>
- <version>${i18nVersion}</version>
-
- <!--configuration>
- <treateDefaultEntry>false</treateDefaultEntry>
- <entries>
- <entry>
- <specificGoal>parserValidation</specificGoal>
- <basedir>${maven.src.dir}/main/java/</basedir>
- <includes>
- <param>**/**-validation.xml</param>
- </includes>
- </entry>
- </entries>
- </configuration-->
+ <version>@pom.version@</version>
+ <configuration>
+ <verbose>true</verbose>
+ </configuration>
<executions>
<execution>
+ <id>first</id>
<goals>
<goal>parserJava</goal>
<goal>parserValidation</goal>
</goals>
</execution>
+ <execution>
+ <!-- this execution is to test thread with no files -->
+ <id>second</id>
+ <goals>
+ <goal>parserJava</goal>
+ <goal>parserValidation</goal>
+ </goals>
+ <phase>compile</phase>
+ </execution>
</executions>
</plugin>
</plugins>
Modified: trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/invoker.properties
===================================================================
--- trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/invoker.properties 2010-04-02 20:02:13 UTC (rev 1732)
+++ trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/invoker.properties 2010-04-03 09:38:02 UTC (rev 1733)
@@ -1,6 +1,6 @@
# A comma or space separated list of goals/phases to execute, may
# specify an empty list to execute the default goal of the IT project
-invoker.goals=clean process-resources
+invoker.goals=clean compile
# Optionally, a list of goals to run during further invocations of Maven
#invoker.goals.2=${project.groupId}:${project.artifactId}:${project.version}:run
Modified: trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/pom.xml
===================================================================
--- trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/pom.xml 2010-04-02 20:02:13 UTC (rev 1732)
+++ trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/pom.xml 2010-04-03 09:38:02 UTC (rev 1733)
@@ -15,6 +15,7 @@
<version>@pom.version@</version>
</parent>
+ <groupId>org.nuiton.i18n</groupId>
<artifactId>parsers-withNewKeys</artifactId>
<!-- ************************************************************* -->
@@ -29,15 +30,16 @@
<packaging>jar</packaging>
- <properties>
+ <dependencies>
- <i18nVersion>@pom.version@</i18nVersion>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>nuiton-i18n</artifactId>
+ <version>${project.version}</version>
+ </dependency>
- <!-- default encoding -->
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </dependencies>
- </properties>
-
<build>
<plugins>
@@ -45,30 +47,30 @@
<plugin>
<groupId>org.nuiton.i18n</groupId>
<artifactId>maven-i18n-plugin</artifactId>
- <version>${i18nVersion}</version>
+ <version>@pom.version@</version>
<configuration>
<keepGetters>true</keepGetters>
+ <verbose>true</verbose>
</configuration>
- <!--configuration>
- <treateDefaultEntry>false</treateDefaultEntry>
- <entries>
- <entry>
- <specificGoal>parserValidation</specificGoal>
- <basedir>${maven.src.dir}/main/java/</basedir>
- <includes>
- <param>**/**-validation.xml</param>
- </includes>
- </entry>
- </entries>
- </configuration-->
<executions>
<execution>
+ <id>first</id>
<goals>
<goal>parserJava</goal>
<goal>parserValidation</goal>
<goal>gen</goal>
</goals>
</execution>
+ <execution>
+ <!-- this execution is to test thread with no files -->
+ <id>second</id>
+ <goals>
+ <goal>parserJava</goal>
+ <goal>parserValidation</goal>
+ <goal>gen</goal>
+ </goals>
+ <phase>compile</phase>
+ </execution>
</executions>
</plugin>
</plugins>
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nMojo.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nMojo.java 2010-04-02 20:02:13 UTC (rev 1732)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nMojo.java 2010-04-03 09:38:02 UTC (rev 1733)
@@ -139,6 +139,7 @@
return !acceptPackaging(Packaging.pom);
}
+ @Override
public void init() throws Exception {
if (verbose) {
@@ -251,10 +252,12 @@
}
+ @Override
public File getBackupFile(File file) {
return new File(file.getAbsolutePath() + "~");
}
+ @Override
protected void backupFile(File f) throws IOException {
File dst = getBackupFile(f);
copyFile(f, dst);
@@ -268,19 +271,31 @@
this.encoding = encoding;
}
+ @Override
public MavenProject getProject() {
return project;
}
+ @Override
public void setProject(MavenProject project) {
this.project = project;
}
+ @Override
public boolean isVerbose() {
return verbose;
}
+ @Override
public void setVerbose(boolean verbose) {
this.verbose = verbose;
}
+
+ public boolean isSilent() {
+ return silent;
+ }
+
+ public boolean isStrictMode() {
+ return strictMode;
+ }
}
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/GenerateMojo.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/GenerateMojo.java 2010-04-02 20:02:13 UTC (rev 1732)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/GenerateMojo.java 2010-04-03 09:38:02 UTC (rev 1733)
@@ -73,7 +73,6 @@
*/
protected boolean keepGetters;
-
@Override
protected boolean checkSkip() {
if (!needGeneration()) {
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/AbstractFileParser.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/AbstractFileParser.java 2010-04-02 20:02:13 UTC (rev 1732)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/AbstractFileParser.java 2010-04-03 09:38:02 UTC (rev 1733)
@@ -63,6 +63,11 @@
return log;
}
+ /**
+ * Method to invoke when a i18n key was detected .
+ *
+ * @param key the i18n key to register
+ */
protected void registerKey(String key) {
Object value = oldParser.get(key);
if (value == null) {
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/AbstractI18nParserMojo.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/AbstractI18nParserMojo.java 2010-04-02 20:02:13 UTC (rev 1732)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/AbstractI18nParserMojo.java 2010-04-03 09:38:02 UTC (rev 1733)
@@ -34,7 +34,7 @@
*
* @author tony
*/
-public abstract class AbstractI18nParserMojo extends AbstractI18nMojo {
+public abstract class AbstractI18nParserMojo extends AbstractI18nMojo implements I18nParserConfiguration {
/** @return the outGetter to use for the instance (java.getter,...) */
protected abstract String getOutGetter();
@@ -64,8 +64,16 @@
/** @return the default src directory to use in directory scanner */
protected abstract File getDefaultBasedir();
+ /**
+ * @return a new file parser to be used in the parser consumer thread
+ * @since 1.2
+ */
public abstract FileParser newFileParser();
+ /**
+ * @param entry the incoming source entry to attach to the file updater
+ * @return a new file updater to detects files to treate
+ */
public abstract FileUpdater newFileUpdater(SourceEntry entry);
/**
@@ -146,6 +154,7 @@
ParserThread thread;
+ @Override
public boolean isStrictMode() {
return strictMode;
}
@@ -187,7 +196,7 @@
}
}
- thread = new ParserThread(result);
+ thread = new ParserThread(this);
}
@Override
@@ -245,13 +254,15 @@
continue;
}
+ // launch parser for found files
+ String[] files = entry.getFiles();
+
if (!silent) {
getLog().info("start entry " + entry.toString());
- getLog().info("incoming file(s) : " + entry.getFoudFiles());
+ getLog().info(files.length + " file(s) to treate (amoung " +
+ entry.getFoudFiles() + " files)");
}
- // launch parser for found files
- String[] files = entry.getFiles();
for (int i = 0, max = files.length; i < max; i++) {
String file1 = files[i];
String fileName = entry.getBasedir().getAbsolutePath() +
@@ -301,6 +312,16 @@
thread.clear();
}
+ @Override
+ public boolean isShowTouchedFiles() {
+ return showTouchedFiles;
+ }
+
+ @Override
+ public SortedProperties getResult() {
+ return result;
+ }
+
/**
* Add the default entry to entries given in configuration.
* <p/>
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/FileParser.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/FileParser.java 2010-04-02 20:02:13 UTC (rev 1732)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/FileParser.java 2010-04-03 09:38:02 UTC (rev 1733)
@@ -1,6 +1,5 @@
package org.nuiton.i18n.plugin.parser;
-import org.apache.maven.plugin.logging.Log;
import org.nuiton.io.SortedProperties;
import java.io.File;
@@ -16,24 +15,15 @@
public interface FileParser {
/**
- * maven logger to use.
- *
- * @return the logger
- */
- Log getLog();
-
- /** @return {@code true} if should print on logger when file is touched */
- boolean isShowTouchedFiles();
-
- /**
* @return {@code true} if file was touched (says contains at least one i18n
* key)
*/
boolean isTouched();
/**
- * TODO As we do not used anylonger old language, we should directly TODO
- * use only a set of keys, no need to keep i18n value...
+ * TODO As we do not used anylonger old language, we should directly
+ * <p/>
+ * TODO use only a set of keys, no need to keep i18n value...
*
* @return the results of i18n keys found for the given file
*/
Added: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/I18nParserConfiguration.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/I18nParserConfiguration.java (rev 0)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/I18nParserConfiguration.java 2010-04-03 09:38:02 UTC (rev 1733)
@@ -0,0 +1,23 @@
+package org.nuiton.i18n.plugin.parser;
+
+import org.apache.maven.plugin.logging.Log;
+import org.nuiton.io.SortedProperties;
+
+/**
+ * Shared configuration for a parser mojo.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.2
+ */
+public interface I18nParserConfiguration {
+
+ boolean isVerbose();
+
+ boolean isSilent();
+
+ boolean isShowTouchedFiles();
+
+ Log getLog();
+
+ SortedProperties getResult();
+}
Property changes on: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/I18nParserConfiguration.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/ParserThread.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/ParserThread.java 2010-04-02 20:02:13 UTC (rev 1732)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/ParserThread.java 2010-04-03 09:38:02 UTC (rev 1733)
@@ -1,7 +1,6 @@
package org.nuiton.i18n.plugin.parser;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.apache.maven.plugin.logging.Log;
import org.nuiton.io.SortedProperties;
import org.nuiton.plugin.PluginHelper;
@@ -17,135 +16,15 @@
* @author tchemit <chemit(a)codelutin.com>
* @since 1.2
*/
-public class ParserThread extends Thread {
+public class ParserThread extends Thread implements I18nParserConfiguration {
- /** Logger */
- private static final Log log = LogFactory.getLog(ParserThread.class);
-
/**
- * This is a task to parse a {@link #file}.
- * <p/>
- * The task will be executed in the executor service created in the thread.
+ * the incoming configuration (from mojo which contains shared result and
+ * logger)
*/
- class ParserTask implements Runnable {
+ protected final I18nParserConfiguration configuration;
- /** the file parser */
- protected final FileParser parser;
-
- /** the file to parse */
- protected final File file;
-
- /** starting time */
- protected long startingTime;
-
- /** ending time */
- protected long endingTime;
-
- ParserTask(FileParser parser, File file) {
- this.parser = parser;
- this.file = file;
- }
-
- @Override
- public void run() {
- startingTime = System.nanoTime();
- if (log.isDebugEnabled()) {
- log.debug("starting action for " + file);
- }
- try {
-
- parser.parseFile(file);
-
- } catch (IOException e) {
- if (log.isErrorEnabled()) {
- log.error("could not parse file " + file, e);
- }
- } finally {
-
- if (log.isDebugEnabled()) {
- log.debug("ending action for " + file);
- }
- endingTime = System.nanoTime();
- }
- }
-
- @Override
- public String toString() {
- return super.toString() + " - " + file;
- }
-
- protected File getFile() {
- return file;
- }
-
- protected long getDelay() {
- return endingTime - startingTime;
- }
-
- protected void destroy() {
- parser.destroy();
- }
-
- @Override
- protected void finalize() throws Throwable {
- super.finalize();
- destroy();
- }
-
- /**
- * Register the result of the parsing of the {@link #file} after {@link
- * #run()} method was invoked.
- * <p/>
- * This method should be invoked by the executor as an ending hook.
- *
- * @param treatedFiles list of files already treated
- * @param touchedFiles list of files already touched
- * @param result shared result.
- */
- protected synchronized void registerResult(List<File> treatedFiles,
- List<File> touchedFiles,
- SortedProperties result) {
-
- try {
- treatedFiles.add(file);
- if (log.isDebugEnabled()) {
- String delay = PluginHelper.convertTime(getDelay());
- log.debug("[" + treatedFiles.size() + "] " + file +
- " in " + delay);
- }
-
- if (parser.isTouched()) {
-
- // mark file as touched
- touchedFiles.add(file);
-
- if (parser.isShowTouchedFiles()) {
- parser.getLog().info("touch " + file);
- }
- if (log.isInfoEnabled()) {
- String delay = PluginHelper.convertTime(getDelay());
- log.info("[" + treatedFiles.size() + "] touchs " +
- file + " in " + delay);
- }
-
- // merge file result with
- // merge result
- result.putAll(parser.getResult());
- }
- } finally {
-
- // destroy runner
- destroy();
-
- // release lock2
-
- synchronized (lock2) {
- lock2.notifyAll();
- }
- }
- }
- }
-
+ /** queue of tasks to consume */
protected final BlockingQueue<ParserTask> tasks;
/** list of files consumed */
@@ -154,8 +33,8 @@
/** list of files touched (says having at least one i18n key) */
protected final List<File> touchedFiles;
- /** the shared result where to merge atomic results */
- protected final SortedProperties result;
+ /** number of files registred to consume */
+ protected int nbFiles;
/**
* object used to lock method {@link #terminatesAndWaits()} until the thread
@@ -169,17 +48,39 @@
*/
private final Object lock2 = new Object();
- /** number of files registred to consume */
- protected int nbFiles;
-
- public ParserThread(SortedProperties result) {
+ public ParserThread(I18nParserConfiguration configuration) {
super(ParserThread.class.getSimpleName());
- this.result = result;
+ this.configuration = configuration;
tasks = new LinkedBlockingQueue<ParserTask>();
touchedFiles = new ArrayList<File>();
treatedFiles = new ArrayList<File>();
}
+ @Override
+ public boolean isVerbose() {
+ return getConfiguration().isVerbose();
+ }
+
+ @Override
+ public boolean isSilent() {
+ return getConfiguration().isSilent();
+ }
+
+ @Override
+ public boolean isShowTouchedFiles() {
+ return getConfiguration().isShowTouchedFiles();
+ }
+
+ @Override
+ public Log getLog() {
+ return getConfiguration().getLog();
+ }
+
+ @Override
+ public SortedProperties getResult() {
+ return getConfiguration().getResult();
+ }
+
public List<File> getTreatedFiles() {
return treatedFiles;
}
@@ -199,8 +100,8 @@
for (File f : files) {
nbFiles++;
- if (log.isInfoEnabled()) {
- log.info("[" + nbFiles + "] " + f);
+ if (isVerbose()) {
+ getLog().info("[" + nbFiles + "] " + f);
}
tasks.offer(new ParserTask(parser, f));
}
@@ -215,49 +116,55 @@
* <b>Note:</b> The method does not return until all files are not
* consumed.
*/
- public void terminatesAndWaits() {
+ public synchronized void terminatesAndWaits() {
- if (log.isInfoEnabled()) {
- log.info("add terminate runner");
+ if (isVerbose()) {
+ getLog().info("add terminate runner");
}
tasks.offer(new ParserTask(null, null));
- // block until end of service
-
- if (log.isInfoEnabled()) {
- log.info("block until ends...");
+ // we waits a little time to make sure, the thread receive the
+ // sentinel, we can not use a lock here
+ try {
+ Thread.sleep(100);
+ } catch (InterruptedException e) {
+ if (getLog().isErrorEnabled()) {
+ getLog().error(e);
+ }
}
- //TODO-TC20100402 Should test (and use another internal state) to be
- //TODO-TC20100402 sure We have to perform a lock, sometimes it is not
- //TODO-TC20100402 necessary if thread is dead before coming at this point
+ if (getNbFilesToTreate() > 0) {
- synchronized (lock) {
- try {
- lock.wait();
- } catch (InterruptedException e) {
- if (log.isErrorEnabled()) {
- log.error(e);
+ // there is still something to treate,
+ // MUST block until the thread is fully terminated
+
+ if (isVerbose()) {
+ getLog().info("block until ends...");
+ }
+
+ synchronized (lock) {
+ try {
+ lock.wait();
+ } catch (InterruptedException e) {
+ if (getLog().isErrorEnabled()) {
+ getLog().error(e);
+ }
}
}
}
- if (nbFiles != treatedFiles.size()) {
+
+ if (getNbFilesToTreate() > 0) {
+ // this case should never happens : once we are here, all files
+ // MUST have been consumed
throw new IllegalStateException(
"should have " + nbFiles + " files treated, but found " +
treatedFiles.size());
}
- if (log.isDebugEnabled()) {
- log.debug("thread is terminated.");
+ if (getLog().isDebugEnabled()) {
+ getLog().debug("thread is terminated.");
}
}
- /** clean internal state after usage of the thread. */
- public void clear() {
- treatedFiles.clear();
- touchedFiles.clear();
- nbFiles = 0;
- }
-
@Override
public void run() {
@@ -273,8 +180,8 @@
try {
runner = tasks.take();
} catch (InterruptedException e) {
- if (log.isErrorEnabled()) {
- log.error(e);
+ if (getLog().isErrorEnabled()) {
+ getLog().error(e);
}
canQuit = true;
continue;
@@ -282,31 +189,21 @@
if (runner.getFile() == null) {
// ask to quit the tread
- if (log.isDebugEnabled()) {
- log.debug("no more files to treate, wait termination...");
+ if (getLog().isDebugEnabled()) {
+ getLog().debug("Termination is asked..., will terminate to " +
+ "resting consume files");
}
- //FIXME-TC20100402, sleep to make sure that the lock2 is always
- //FIXME-TC20100402 block before the thread is done.
- //FIXME-TC20100402 otherwise, it could ends in a dead-end...
- //TODO Should really use another lock or internal state before
- //TODO doing lock in method terminatesAndWaits
-
- try {
- Thread.sleep(100);
- } catch (InterruptedException e) {
- log.error(e);
- }
canQuit = true;
continue;
}
- if (log.isDebugEnabled()) {
- log.debug("consume " + runner);
+ if (getLog().isDebugEnabled()) {
+ getLog().debug("consume " + runner);
}
executor.execute(runner);
- if (log.isDebugEnabled()) {
- log.debug("after consume " + runner);
+ if (getLog().isDebugEnabled()) {
+ getLog().debug("after consume " + runner);
}
}
@@ -315,14 +212,14 @@
if (nbFiles == 0) {
// no file consumed
- if (log.isInfoEnabled()) {
- log.info("no file consumed.");
+ if (isVerbose()) {
+ getLog().info("No file consumed.");
}
} else {
- if (log.isInfoEnabled()) {
- log.info("will waits until all files (" + nbFiles +
- ") are consumed (still " + getFilesToTreate() +
- " file(s) to consume)");
+ if (isVerbose()) {
+ getLog().info("Will waits until all files (" + nbFiles +
+ ") are consumed (still " + getNbFilesToTreate() +
+ " file(s) to consume)");
}
}
@@ -332,20 +229,20 @@
while (!canQuit) {
- int treate = getFilesToTreate();
+ int nbFilesToTreate = getNbFilesToTreate();
// can quit if and only if executore is terminated are there is no
// more files to consume
- // Note : normally, the second is not necessary...
- canQuit = executor.isTerminated() || treate == 0;
+ // Note : normally, the second test is not necessary...
+ canQuit = executor.isTerminated() || nbFilesToTreate == 0;
if (canQuit) {
continue;
}
- if (log.isDebugEnabled()) {
- log.debug("waiting end... (still " + treate +
- " file(s) to consume)");
+ if (getLog().isDebugEnabled()) {
+ getLog().debug("Waiting end... (still " + nbFilesToTreate +
+ " file(s) to consume)");
}
// waits a task to be done
@@ -353,14 +250,19 @@
try {
lock2.wait();
} catch (InterruptedException e) {
- log.error(e);
+ getLog().error(e);
break;
}
}
+
+ if (getLog().isDebugEnabled()) {
+ getLog().debug("A task was consumed, still " + getNbFilesToTreate() +
+ " file(s) to treate.");
+ }
}
- if (log.isInfoEnabled()) {
- log.info("executor is terminated, will release thread lock.");
+ if (isVerbose()) {
+ getLog().info("Executor is terminated, will release thread lock.");
}
// service was shutdown and terminated, release thread main lock.
@@ -371,7 +273,20 @@
}
+ /** clean internal state after usage of the thread. */
+ public void clear() {
+ treatedFiles.clear();
+ touchedFiles.clear();
+ nbFiles = 0;
+ }
+
+ /**
+ * Creates the {@link ExecutorService} which will consumed i8n tasks.
+ *
+ * @return the instanciated executor
+ */
protected ExecutorService createExecutor() {
+
// creates thread factory
ThreadFactory factory =
new ThreadFactory() {
@@ -396,16 +311,146 @@
@Override
protected void afterExecute(Runnable r, Throwable t) {
- super.afterExecute(r, t);
- ParserTask i18n = (ParserTask) r;
- i18n.registerResult(treatedFiles, touchedFiles, result);
+ try {
+ super.afterExecute(r, t);
+ ParserTask i18n = (ParserTask) r;
+ i18n.registerResult(treatedFiles, touchedFiles, getResult());
+ } finally {
+
+ // task is done, notify thread
+
+ synchronized (lock2) {
+ lock2.notifyAll();
+ }
+ }
}
};
return executor;
}
- protected int getFilesToTreate() {
+ protected I18nParserConfiguration getConfiguration() {
+ return configuration;
+ }
+
+ protected int getNbFilesToTreate() {
return nbFiles - treatedFiles.size();
}
+ /**
+ * This is a task to parse a {@link #file}.
+ * <p/>
+ * The task will be executed in the executor service created in the thread.
+ */
+ class ParserTask implements Runnable {
+
+ /** the file parser */
+ protected final FileParser parser;
+
+ /** the file to parse */
+ protected final File file;
+
+ /** starting time */
+ protected long startingTime;
+
+ /** ending time */
+ protected long endingTime;
+
+ ParserTask(FileParser parser, File file) {
+ this.parser = parser;
+ this.file = file;
+ }
+
+ @Override
+ public void run() {
+ startingTime = System.nanoTime();
+ if (getLog().isDebugEnabled()) {
+ getLog().debug("starting action for " + file);
+ }
+ try {
+
+ parser.parseFile(file);
+
+ } catch (IOException e) {
+ if (getLog().isErrorEnabled()) {
+ getLog().error("could not parse file " + file, e);
+ }
+ } finally {
+
+ if (getLog().isDebugEnabled()) {
+ getLog().debug("ending action for " + file);
+ }
+ endingTime = System.nanoTime();
+ }
+ }
+
+ @Override
+ public String toString() {
+ return super.toString() + " - " + file;
+ }
+
+ protected File getFile() {
+ return file;
+ }
+
+ protected long getDelay() {
+ return endingTime - startingTime;
+ }
+
+ protected void destroy() {
+ parser.destroy();
+ }
+
+ @Override
+ protected void finalize() throws Throwable {
+ super.finalize();
+ destroy();
+ }
+
+ /**
+ * Register the result of the parsing of the {@link #file} after {@link
+ * #run()} method was invoked.
+ * <p/>
+ * This method should be invoked by the executor as an ending hook.
+ *
+ * @param treatedFiles list of files already treated
+ * @param touchedFiles list of files already touched
+ * @param result shared result.
+ */
+ protected synchronized void registerResult(List<File> treatedFiles,
+ List<File> touchedFiles,
+ SortedProperties result) {
+
+ try {
+ treatedFiles.add(file);
+ if (getLog().isDebugEnabled()) {
+ String delay = PluginHelper.convertTime(getDelay());
+ getLog().debug("[" + treatedFiles.size() + "] " + file +
+ " in " + delay);
+ }
+
+ if (parser.isTouched()) {
+
+ // mark file as touched
+ touchedFiles.add(file);
+
+ if (isShowTouchedFiles()) {
+ getLog().info("touch " + file);
+ }
+ if (isVerbose()) {
+ String delay = PluginHelper.convertTime(getDelay());
+ getLog().info("[" + treatedFiles.size() + "] touchs " +
+ file + " in " + delay);
+ }
+
+ // merge file result with
+ // merge result
+ result.putAll(parser.getResult());
+ }
+ } finally {
+
+ // destroy runner
+ destroy();
+ }
+ }
+ }
}
1
0
r1732 - trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser
by tchemit@users.nuiton.org 02 Apr '10
by tchemit@users.nuiton.org 02 Apr '10
02 Apr '10
Author: tchemit
Date: 2010-04-02 22:02:13 +0200 (Fri, 02 Apr 2010)
New Revision: 1732
Log:
Anomalie #438: Blocage sur le parserJava lorsqu'il n'y a aucun fichier ?\195?\160 parser
Modified:
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/ParserThread.java
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/ParserThread.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/ParserThread.java 2010-03-30 20:35:54 UTC (rev 1731)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/ParserThread.java 2010-04-02 20:02:13 UTC (rev 1732)
@@ -22,14 +22,23 @@
/** Logger */
private static final Log log = LogFactory.getLog(ParserThread.class);
+ /**
+ * This is a task to parse a {@link #file}.
+ * <p/>
+ * The task will be executed in the executor service created in the thread.
+ */
class ParserTask implements Runnable {
+ /** the file parser */
protected final FileParser parser;
+ /** the file to parse */
protected final File file;
+ /** starting time */
protected long startingTime;
+ /** ending time */
protected long endingTime;
ParserTask(FileParser parser, File file) {
@@ -83,6 +92,16 @@
destroy();
}
+ /**
+ * Register the result of the parsing of the {@link #file} after {@link
+ * #run()} method was invoked.
+ * <p/>
+ * This method should be invoked by the executor as an ending hook.
+ *
+ * @param treatedFiles list of files already treated
+ * @param touchedFiles list of files already touched
+ * @param result shared result.
+ */
protected synchronized void registerResult(List<File> treatedFiles,
List<File> touchedFiles,
SortedProperties result) {
@@ -114,8 +133,15 @@
result.putAll(parser.getResult());
}
} finally {
+
// destroy runner
destroy();
+
+ // release lock2
+
+ synchronized (lock2) {
+ lock2.notifyAll();
+ }
}
}
}
@@ -132,11 +158,17 @@
protected final SortedProperties result;
/**
- * object used to lock method {@link #terminatesAndWaits()} until all tasks
- * are consumed.
+ * object used to lock method {@link #terminatesAndWaits()} until the thread
+ * is not fully terminated.
*/
private final Object lock = new Object();
+ /**
+ * object used to lock in {@link #run()} until all tasks are consumed after
+ * the shutdown of the executor
+ */
+ private final Object lock2 = new Object();
+
/** number of files registred to consume */
protected int nbFiles;
@@ -156,28 +188,39 @@
return touchedFiles;
}
+ /**
+ * Add a file to be consumed.
+ *
+ * @param parser the parser of the file
+ * @param files files to parse
+ */
public void addFile(FileParser parser, File... files) {
- synchronized (tasks) {
+ for (File f : files) {
- for (File f : files) {
-
- nbFiles++;
- if (log.isInfoEnabled()) {
- log.info("[" + nbFiles + "] " + f);
- }
- tasks.offer(new ParserTask(parser, f));
+ nbFiles++;
+ if (log.isInfoEnabled()) {
+ log.info("[" + nbFiles + "] " + f);
}
+ tasks.offer(new ParserTask(parser, f));
}
}
- public synchronized void terminatesAndWaits() {
- synchronized (tasks) {
- if (log.isDebugEnabled()) {
- log.debug("add terminate runner");
- }
- tasks.offer(new ParserTask(null, null));
+ /**
+ * Ask the thread to stop.
+ * <p/>
+ * It will finish all incoming files (but will not accept more files to
+ * parse)
+ * <p/>
+ * <b>Note:</b> The method does not return until all files are not
+ * consumed.
+ */
+ public void terminatesAndWaits() {
+
+ if (log.isInfoEnabled()) {
+ log.info("add terminate runner");
}
+ tasks.offer(new ParserTask(null, null));
// block until end of service
@@ -185,6 +228,10 @@
log.info("block until ends...");
}
+ //TODO-TC20100402 Should test (and use another internal state) to be
+ //TODO-TC20100402 sure We have to perform a lock, sometimes it is not
+ //TODO-TC20100402 necessary if thread is dead before coming at this point
+
synchronized (lock) {
try {
lock.wait();
@@ -204,6 +251,7 @@
}
}
+ /** clean internal state after usage of the thread. */
public void clear() {
treatedFiles.clear();
touchedFiles.clear();
@@ -213,36 +261,12 @@
@Override
public void run() {
- // creates thread factory
- ThreadFactory factory =
- new ThreadFactory() {
- final ThreadFactory defaultFactory =
- Executors.defaultThreadFactory();
-
- public Thread newThread(Runnable r) {
- Thread thread =
- defaultFactory.newThread(r);
- thread.setName(ParserThread.this + "-" + thread.getName());
- return thread;
- }
- };
-
// create pool executor
- ExecutorService service = new ThreadPoolExecutor(
- 8, 10,
- 1L, TimeUnit.SECONDS,
- new LinkedBlockingQueue<Runnable>(),
- factory) {
+ ExecutorService executor = createExecutor();
- @Override
- protected void afterExecute(Runnable r, Throwable t) {
- super.afterExecute(r, t);
- ParserTask i18n = (ParserTask) r;
- i18n.registerResult(treatedFiles, touchedFiles, result);
- }
- };
+ boolean canQuit = false;
- while (true) {
+ while (!canQuit) {
// waiting for a new file to treate
ParserTask runner;
@@ -252,60 +276,136 @@
if (log.isErrorEnabled()) {
log.error(e);
}
+ canQuit = true;
continue;
}
if (runner.getFile() == null) {
// ask to quit the tread
- if (log.isInfoEnabled()) {
- log.info("no more files to treate, wait termination...");
+ if (log.isDebugEnabled()) {
+ log.debug("no more files to treate, wait termination...");
}
- service.shutdown();
- break;
+ //FIXME-TC20100402, sleep to make sure that the lock2 is always
+ //FIXME-TC20100402 block before the thread is done.
+ //FIXME-TC20100402 otherwise, it could ends in a dead-end...
+ //TODO Should really use another lock or internal state before
+ //TODO doing lock in method terminatesAndWaits
+
+ try {
+ Thread.sleep(100);
+ } catch (InterruptedException e) {
+ log.error(e);
+ }
+ canQuit = true;
+ continue;
}
if (log.isDebugEnabled()) {
log.debug("consume " + runner);
}
- service.execute(runner);
+ executor.execute(runner);
if (log.isDebugEnabled()) {
log.debug("after consume " + runner);
}
}
- if (log.isInfoEnabled()) {
- log.info("will waits until ends of all " + nbFiles + " runner(s)!");
+ // ask executor to terminate
+ executor.shutdown();
+
+ if (nbFiles == 0) {
+ // no file consumed
+ if (log.isInfoEnabled()) {
+ log.info("no file consumed.");
+ }
+ } else {
+ if (log.isInfoEnabled()) {
+ log.info("will waits until all files (" + nbFiles +
+ ") are consumed (still " + getFilesToTreate() +
+ " file(s) to consume)");
+ }
}
- // waits end of service
+ // waits end of executor
- while (true) {
+ canQuit = false;
- if (service.isTerminated()) {
- if (log.isInfoEnabled()) {
- log.info("all runners are terminated. [" + treatedFiles.size() + "]");
- }
+ while (!canQuit) {
- // release lock
- synchronized (lock) {
- lock.notifyAll();
- }
- break;
+ int treate = getFilesToTreate();
+
+ // can quit if and only if executore is terminated are there is no
+ // more files to consume
+ // Note : normally, the second is not necessary...
+ canQuit = executor.isTerminated() || treate == 0;
+
+ if (canQuit) {
+ continue;
}
if (log.isDebugEnabled()) {
- log.debug("waiting end...");
+ log.debug("waiting end... (still " + treate +
+ " file(s) to consume)");
}
- try {
- sleep(200);
- } catch (InterruptedException e) {
- if (log.isErrorEnabled()) {
+ // waits a task to be done
+ synchronized (lock2) {
+ try {
+ lock2.wait();
+ } catch (InterruptedException e) {
log.error(e);
+ break;
}
}
}
+
+ if (log.isInfoEnabled()) {
+ log.info("executor is terminated, will release thread lock.");
+ }
+
+ // service was shutdown and terminated, release thread main lock.
+
+ synchronized (lock) {
+ lock.notifyAll();
+ }
+
}
+ protected ExecutorService createExecutor() {
+ // creates thread factory
+ ThreadFactory factory =
+ new ThreadFactory() {
+ final ThreadFactory defaultFactory =
+ Executors.defaultThreadFactory();
+
+ public Thread newThread(Runnable r) {
+ Thread thread =
+ defaultFactory.newThread(r);
+ thread.setName(ParserThread.this + "-" +
+ thread.getName());
+ return thread;
+ }
+ };
+
+ // create pool executor
+ ExecutorService executor = new ThreadPoolExecutor(
+ 8, 10,
+ 1L, TimeUnit.SECONDS,
+ new LinkedBlockingQueue<Runnable>(),
+ factory) {
+
+ @Override
+ protected void afterExecute(Runnable r, Throwable t) {
+ super.afterExecute(r, t);
+ ParserTask i18n = (ParserTask) r;
+ i18n.registerResult(treatedFiles, touchedFiles, result);
+ }
+ };
+ return executor;
+ }
+
+ protected int getFilesToTreate() {
+ return nbFiles - treatedFiles.size();
+ }
+
}
1
0
Author: tchemit
Date: 2010-03-30 22:35:54 +0200 (Tue, 30 Mar 2010)
New Revision: 1731
Log:
Evolution #426: Add integration tests
Added:
trunk/maven-i18n-plugin/src/it/
trunk/maven-i18n-plugin/src/it/parsers/
trunk/maven-i18n-plugin/src/it/parsers/newProject/
trunk/maven-i18n-plugin/src/it/parsers/newProject/LICENSE.txt
trunk/maven-i18n-plugin/src/it/parsers/newProject/README.txt
trunk/maven-i18n-plugin/src/it/parsers/newProject/changelog.txt
trunk/maven-i18n-plugin/src/it/parsers/newProject/invoker.properties
trunk/maven-i18n-plugin/src/it/parsers/newProject/pom.xml
trunk/maven-i18n-plugin/src/it/parsers/newProject/src/
trunk/maven-i18n-plugin/src/it/parsers/newProject/src/main/
trunk/maven-i18n-plugin/src/it/parsers/newProject/src/main/java/
trunk/maven-i18n-plugin/src/it/parsers/newProject/src/main/java/org/
trunk/maven-i18n-plugin/src/it/parsers/newProject/src/main/java/org/nuiton/
trunk/maven-i18n-plugin/src/it/parsers/newProject/src/main/java/org/nuiton/i18n/
trunk/maven-i18n-plugin/src/it/parsers/newProject/src/main/java/org/nuiton/i18n/test/
trunk/maven-i18n-plugin/src/it/parsers/newProject/src/main/java/org/nuiton/i18n/test/MyBean.java
trunk/maven-i18n-plugin/src/it/parsers/newProject/src/main/resources/
trunk/maven-i18n-plugin/src/it/parsers/newProject/src/main/resources/org/
trunk/maven-i18n-plugin/src/it/parsers/newProject/src/main/resources/org/nuiton/
trunk/maven-i18n-plugin/src/it/parsers/newProject/src/main/resources/org/nuiton/i18n/
trunk/maven-i18n-plugin/src/it/parsers/newProject/src/main/resources/org/nuiton/i18n/test/
trunk/maven-i18n-plugin/src/it/parsers/newProject/src/main/resources/org/nuiton/i18n/test/MyBean-validation.xml
trunk/maven-i18n-plugin/src/it/parsers/newProject/verify.groovy
trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/
trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/LICENSE.txt
trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/README.txt
trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/changelog.txt
trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/invoker.properties
trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/pom.xml
trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/src/
trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/src/main/
trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/src/main/java/
trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/src/main/java/org/
trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/src/main/java/org/nuiton/
trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/src/main/java/org/nuiton/i18n/
trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/src/main/java/org/nuiton/i18n/test/
trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/src/main/java/org/nuiton/i18n/test/MyBean.java
trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/src/main/resources/
trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/src/main/resources/i18n/
trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/src/main/resources/i18n/parsers-withNewKeys-fr_FR.properties
trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/src/main/resources/org/
trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/src/main/resources/org/nuiton/
trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/src/main/resources/org/nuiton/i18n/
trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/src/main/resources/org/nuiton/i18n/test/
trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/src/main/resources/org/nuiton/i18n/test/MyBean-validation.xml
trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/verify.groovy
trunk/maven-i18n-plugin/src/it/settings.xml
Modified:
trunk/maven-i18n-plugin/pom.xml
Modified: trunk/maven-i18n-plugin/pom.xml
===================================================================
--- trunk/maven-i18n-plugin/pom.xml 2010-03-28 21:39:04 UTC (rev 1730)
+++ trunk/maven-i18n-plugin/pom.xml 2010-03-30 20:35:54 UTC (rev 1731)
@@ -1,5 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
@@ -11,7 +13,7 @@
<artifactId>i18n</artifactId>
<version>1.2.1-SNAPSHOT</version>
</parent>
-
+
<groupId>org.nuiton.i18n</groupId>
<artifactId>maven-i18n-plugin</artifactId>
@@ -78,7 +80,7 @@
<artifactId>plexus-utils</artifactId>
</dependency>
- <dependency>
+ <dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<scope>runtime</scope>
@@ -91,11 +93,12 @@
<!-- ************************************************************* -->
<name>I18n :: Maven Plugin</name>
<description>
- Plugin pour maven 2 de génération des bundles pour l'internationalisation (i18n) des applications java
+ Plugin pour maven 2 de génération des bundles pour
+ l'internationalisation (i18n) des applications java
basé sur nuiton-i18n-api.
</description>
<inceptionYear>2007</inceptionYear>
-
+
<!-- ************************************************************* -->
<!-- *** Build Settings ****************************************** -->
<!-- ************************************************************* -->
@@ -103,7 +106,6 @@
<packaging>maven-plugin</packaging>
<build>
- <defaultGoal>install</defaultGoal>
<plugins>
@@ -118,7 +120,7 @@
</execution>
</executions>
</plugin>
-
+
</plugins>
</build>
@@ -127,8 +129,48 @@
<plugins>
<plugin>
<artifactId>maven-plugin-plugin</artifactId>
- </plugin>
+ </plugin>
</plugins>
</reporting>
+ <profiles>
+ <profile>
+ <id>run-its</id>
+ <activation>
+ <property>
+ <name>performRelease</name>
+ <value>true</value>
+ </property>
+ </activation>
+ <build>
+ <defaultGoal>verify</defaultGoal>
+ <plugins>
+ <plugin>
+ <artifactId>maven-invoker-plugin</artifactId>
+ <configuration>
+ <pomIncludes>
+ <pomInclude>**/pom.xml</pomInclude>
+ </pomIncludes>
+ <postBuildHookScript>verify</postBuildHookScript>
+ <localRepositoryPath>${basedir}/target/local-repo</localRepositoryPath>
+ <settingsFile>src/it/settings.xml</settingsFile>
+ <cloneProjectsTo>${project.build.directory}/its</cloneProjectsTo>
+ <!--<debug>true</debug>-->
+ </configuration>
+ <executions>
+ <execution>
+ <id>integration-test</id>
+ <goals>
+ <goal>install</goal>
+ <goal>run</goal>
+ </goals>
+ <phase>integration-test</phase>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
</project>
Added: trunk/maven-i18n-plugin/src/it/parsers/newProject/LICENSE.txt
===================================================================
--- trunk/maven-i18n-plugin/src/it/parsers/newProject/LICENSE.txt (rev 0)
+++ trunk/maven-i18n-plugin/src/it/parsers/newProject/LICENSE.txt 2010-03-30 20:35:54 UTC (rev 1731)
@@ -0,0 +1,166 @@
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+
+ This version of the GNU Lesser General Public License incorporates
+the terms and conditions of version 3 of the GNU General Public
+License, supplemented by the additional permissions listed below.
+
+ 0. Additional Definitions.
+
+ As used herein, "this License" refers to version 3 of the GNU Lesser
+General Public License, and the "GNU GPL" refers to version 3 of the GNU
+General Public License.
+
+ "The Library" refers to a covered work governed by this License,
+other than an Application or a Combined Work as defined below.
+
+ An "Application" is any work that makes use of an interface provided
+by the Library, but which is not otherwise based on the Library.
+Defining a subclass of a class defined by the Library is deemed a mode
+of using an interface provided by the Library.
+
+ A "Combined Work" is a work produced by combining or linking an
+Application with the Library. The particular version of the Library
+with which the Combined Work was made is also called the "Linked
+Version".
+
+ The "Minimal Corresponding Source" for a Combined Work means the
+Corresponding Source for the Combined Work, excluding any source code
+for portions of the Combined Work that, considered in isolation, are
+based on the Application, and not on the Linked Version.
+
+ The "Corresponding Application Code" for a Combined Work means the
+object code and/or source code for the Application, including any data
+and utility programs needed for reproducing the Combined Work from the
+Application, but excluding the System Libraries of the Combined Work.
+
+ 1. Exception to Section 3 of the GNU GPL.
+
+ You may convey a covered work under sections 3 and 4 of this License
+without being bound by section 3 of the GNU GPL.
+
+ 2. Conveying Modified Versions.
+
+ If you modify a copy of the Library, and, in your modifications, a
+facility refers to a function or data to be supplied by an Application
+that uses the facility (other than as an argument passed when the
+facility is invoked), then you may convey a copy of the modified
+version:
+
+ a) under this License, provided that you make a good faith effort to
+ ensure that, in the event an Application does not supply the
+ function or data, the facility still operates, and performs
+ whatever part of its purpose remains meaningful, or
+
+ b) under the GNU GPL, with none of the additional permissions of
+ this License applicable to that copy.
+
+ 3. Object Code Incorporating Material from Library Header Files.
+
+ The object code form of an Application may incorporate material from
+a header file that is part of the Library. You may convey such object
+code under terms of your choice, provided that, if the incorporated
+material is not limited to numerical parameters, data structure
+layouts and accessors, or small macros, inline functions and templates
+(ten or fewer lines in length), you do both of the following:
+
+ a) Give prominent notice with each copy of the object code that the
+ Library is used in it and that the Library and its use are
+ covered by this License.
+
+ b) Accompany the object code with a copy of the GNU GPL and this license
+ document.
+
+ 4. Combined Works.
+
+ You may convey a Combined Work under terms of your choice that,
+taken together, effectively do not restrict modification of the
+portions of the Library contained in the Combined Work and reverse
+engineering for debugging such modifications, if you also do each of
+the following:
+
+ a) Give prominent notice with each copy of the Combined Work that
+ the Library is used in it and that the Library and its use are
+ covered by this License.
+
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
+ document.
+
+ c) For a Combined Work that displays copyright notices during
+ execution, include the copyright notice for the Library among
+ these notices, as well as a reference directing the user to the
+ copies of the GNU GPL and this license document.
+
+ d) Do one of the following:
+
+ 0) Convey the Minimal Corresponding Source under the terms of this
+ License, and the Corresponding Application Code in a form
+ suitable for, and under terms that permit, the user to
+ recombine or relink the Application with a modified version of
+ the Linked Version to produce a modified Combined Work, in the
+ manner specified by section 6 of the GNU GPL for conveying
+ Corresponding Source.
+
+ 1) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (a) uses at run time
+ a copy of the Library already present on the user's computer
+ system, and (b) will operate properly with a modified version
+ of the Library that is interface-compatible with the Linked
+ Version.
+
+ e) Provide Installation Information, but only if you would otherwise
+ be required to provide such information under section 6 of the
+ GNU GPL, and only to the extent that such information is
+ necessary to install and execute a modified version of the
+ Combined Work produced by recombining or relinking the
+ Application with a modified version of the Linked Version. (If
+ you use option 4d0, the Installation Information must accompany
+ the Minimal Corresponding Source and Corresponding Application
+ Code. If you use option 4d1, you must provide the Installation
+ Information in the manner specified by section 6 of the GNU GPL
+ for conveying Corresponding Source.)
+
+ 5. Combined Libraries.
+
+ You may place library facilities that are a work based on the
+Library side by side in a single library together with other library
+facilities that are not Applications and are not covered by this
+License, and convey such a combined library under terms of your
+choice, if you do both of the following:
+
+ a) Accompany the combined library with a copy of the same work based
+ on the Library, uncombined with any other library facilities,
+ conveyed under the terms of this License.
+
+ b) Give prominent notice with the combined library that part of it
+ is a work based on the Library, and explaining where to find the
+ accompanying uncombined form of the same work.
+
+ 6. Revised Versions of the GNU Lesser General Public License.
+
+ The Free Software Foundation may publish revised and/or new versions
+of the GNU Lesser General Public License from time to time. Such new
+versions will be similar in spirit to the present version, but may
+differ in detail to address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Library as you received it specifies that a certain numbered version
+of the GNU Lesser General Public License "or any later version"
+applies to it, you have the option of following the terms and
+conditions either of that published version or of any later version
+published by the Free Software Foundation. If the Library as you
+received it does not specify a version number of the GNU Lesser
+General Public License, you may choose any version of the GNU Lesser
+General Public License ever published by the Free Software Foundation.
+
+ If the Library as you received it specifies that a proxy can decide
+whether future versions of the GNU Lesser General Public License shall
+apply, that proxy's public statement of acceptance of any version is
+permanent authorization for you to choose that version for the
+Library.
+
Added: trunk/maven-i18n-plugin/src/it/parsers/newProject/README.txt
===================================================================
--- trunk/maven-i18n-plugin/src/it/parsers/newProject/README.txt (rev 0)
+++ trunk/maven-i18n-plugin/src/it/parsers/newProject/README.txt 2010-03-30 20:35:54 UTC (rev 1731)
@@ -0,0 +1,2 @@
+To test parserJava on a new project (says a project with no i18n translations)
+At the end we should have in target/generated-sources/i18n getters detected.
Added: trunk/maven-i18n-plugin/src/it/parsers/newProject/changelog.txt
===================================================================
--- trunk/maven-i18n-plugin/src/it/parsers/newProject/changelog.txt (rev 0)
+++ trunk/maven-i18n-plugin/src/it/parsers/newProject/changelog.txt 2010-03-30 20:35:54 UTC (rev 1731)
@@ -0,0 +1 @@
+see the changelog of org.nuiton:i18n project.
\ No newline at end of file
Added: trunk/maven-i18n-plugin/src/it/parsers/newProject/invoker.properties
===================================================================
--- trunk/maven-i18n-plugin/src/it/parsers/newProject/invoker.properties (rev 0)
+++ trunk/maven-i18n-plugin/src/it/parsers/newProject/invoker.properties 2010-03-30 20:35:54 UTC (rev 1731)
@@ -0,0 +1,21 @@
+# A comma or space separated list of goals/phases to execute, may
+# specify an empty list to execute the default goal of the IT project
+invoker.goals=clean process-resources
+
+# Optionally, a list of goals to run during further invocations of Maven
+#invoker.goals.2=${project.groupId}:${project.artifactId}:${project.version}:run
+
+# A comma or space separated list of profiles to activate
+#invoker.profiles=run-all run-once
+
+# The value for the environment variable MAVEN_OPTS
+#invoker.mavenOpts=-Dfile.encoding=UTF-16 -Xms32m -Xmx256m
+
+# Possible values are "fail-fast" (default), "fail-at-end" and "fail-never"
+invoker.failureBehavior=fail-at-end
+
+# The expected result of the build, possible values are "success" (default) and "failure"
+#invoker.buildResult=success
+
+# A boolean value controlling the -N flag, defaults to "false"
+#invoker.nonRecursive=false
Added: trunk/maven-i18n-plugin/src/it/parsers/newProject/pom.xml
===================================================================
--- trunk/maven-i18n-plugin/src/it/parsers/newProject/pom.xml (rev 0)
+++ trunk/maven-i18n-plugin/src/it/parsers/newProject/pom.xml 2010-03-30 20:35:54 UTC (rev 1731)
@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <!-- ************************************************************* -->
+ <!-- *** POM Relationships *************************************** -->
+ <!-- ************************************************************* -->
+
+ <parent>
+ <groupId>org.nuiton</groupId>
+ <artifactId>i18n</artifactId>
+ <version>@pom.version@</version>
+ </parent>
+
+ <artifactId>parsers-newProject</artifactId>
+
+ <!-- ************************************************************* -->
+ <!-- *** Project Information ************************************* -->
+ <!-- ************************************************************* -->
+
+ <name>I18n Test :: parsers-new</name>
+
+ <!-- ************************************************************* -->
+ <!-- *** Build Settings ****************************************** -->
+ <!-- ************************************************************* -->
+
+ <packaging>jar</packaging>
+
+ <properties>
+
+ <i18nVersion>@pom.version@</i18nVersion>
+
+ <!-- default encoding -->
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+
+ </properties>
+
+ <build>
+
+ <plugins>
+
+ <plugin>
+ <groupId>org.nuiton.i18n</groupId>
+ <artifactId>maven-i18n-plugin</artifactId>
+ <version>${i18nVersion}</version>
+
+ <!--configuration>
+ <treateDefaultEntry>false</treateDefaultEntry>
+ <entries>
+ <entry>
+ <specificGoal>parserValidation</specificGoal>
+ <basedir>${maven.src.dir}/main/java/</basedir>
+ <includes>
+ <param>**/**-validation.xml</param>
+ </includes>
+ </entry>
+ </entries>
+ </configuration-->
+ <executions>
+ <execution>
+ <goals>
+ <goal>parserJava</goal>
+ <goal>parserValidation</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
+
+
Added: trunk/maven-i18n-plugin/src/it/parsers/newProject/src/main/java/org/nuiton/i18n/test/MyBean.java
===================================================================
--- trunk/maven-i18n-plugin/src/it/parsers/newProject/src/main/java/org/nuiton/i18n/test/MyBean.java (rev 0)
+++ trunk/maven-i18n-plugin/src/it/parsers/newProject/src/main/java/org/nuiton/i18n/test/MyBean.java 2010-03-30 20:35:54 UTC (rev 1731)
@@ -0,0 +1,11 @@
+package org.nuiton.i18n.test;
+
+import static org.nuiton.i18n.I18n._;
+import static org.nuiton.i18n.I18n.n_;
+
+public class MyBean {
+
+ protected String field1 = n_("javaGetter.key1");
+
+ protected String field2 = _("javaGetter.key2");
+}
Property changes on: trunk/maven-i18n-plugin/src/it/parsers/newProject/src/main/java/org/nuiton/i18n/test/MyBean.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: trunk/maven-i18n-plugin/src/it/parsers/newProject/src/main/resources/org/nuiton/i18n/test/MyBean-validation.xml
===================================================================
--- trunk/maven-i18n-plugin/src/it/parsers/newProject/src/main/resources/org/nuiton/i18n/test/MyBean-validation.xml (rev 0)
+++ trunk/maven-i18n-plugin/src/it/parsers/newProject/src/main/resources/org/nuiton/i18n/test/MyBean-validation.xml 2010-03-30 20:35:54 UTC (rev 1731)
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE validators PUBLIC
+ "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
+ "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
+<validators>
+
+ <field name="field1">
+
+ <field-validator type="required">
+ <message>validationGetter.key1</message>
+ </field-validator>
+
+ </field>
+
+ <field name="field2">
+
+ <field-validator type="required">
+ <message>validationGetter.key2##${parm1}</message>
+ </field-validator>
+
+ </field>
+
+</validators>
Added: trunk/maven-i18n-plugin/src/it/parsers/newProject/verify.groovy
===================================================================
--- trunk/maven-i18n-plugin/src/it/parsers/newProject/verify.groovy (rev 0)
+++ trunk/maven-i18n-plugin/src/it/parsers/newProject/verify.groovy 2010-03-30 20:35:54 UTC (rev 1731)
@@ -0,0 +1,16 @@
+
+file = new File(basedir, 'target/generated-sources/i18n/java.getter');
+assert file.exists();
+
+content = file.text;
+assert content.contains( 'javaGetter.key1=' );
+assert content.contains( 'javaGetter.key2=' );
+
+file = new File(basedir, 'target/generated-sources/i18n/validation.getter');
+assert file.exists();
+
+content = file.text;
+assert content.contains( 'validationGetter.key1=' );
+assert content.contains( 'validationGetter.key2=' );
+
+return true;
Added: trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/LICENSE.txt
===================================================================
--- trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/LICENSE.txt (rev 0)
+++ trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/LICENSE.txt 2010-03-30 20:35:54 UTC (rev 1731)
@@ -0,0 +1,166 @@
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+
+ This version of the GNU Lesser General Public License incorporates
+the terms and conditions of version 3 of the GNU General Public
+License, supplemented by the additional permissions listed below.
+
+ 0. Additional Definitions.
+
+ As used herein, "this License" refers to version 3 of the GNU Lesser
+General Public License, and the "GNU GPL" refers to version 3 of the GNU
+General Public License.
+
+ "The Library" refers to a covered work governed by this License,
+other than an Application or a Combined Work as defined below.
+
+ An "Application" is any work that makes use of an interface provided
+by the Library, but which is not otherwise based on the Library.
+Defining a subclass of a class defined by the Library is deemed a mode
+of using an interface provided by the Library.
+
+ A "Combined Work" is a work produced by combining or linking an
+Application with the Library. The particular version of the Library
+with which the Combined Work was made is also called the "Linked
+Version".
+
+ The "Minimal Corresponding Source" for a Combined Work means the
+Corresponding Source for the Combined Work, excluding any source code
+for portions of the Combined Work that, considered in isolation, are
+based on the Application, and not on the Linked Version.
+
+ The "Corresponding Application Code" for a Combined Work means the
+object code and/or source code for the Application, including any data
+and utility programs needed for reproducing the Combined Work from the
+Application, but excluding the System Libraries of the Combined Work.
+
+ 1. Exception to Section 3 of the GNU GPL.
+
+ You may convey a covered work under sections 3 and 4 of this License
+without being bound by section 3 of the GNU GPL.
+
+ 2. Conveying Modified Versions.
+
+ If you modify a copy of the Library, and, in your modifications, a
+facility refers to a function or data to be supplied by an Application
+that uses the facility (other than as an argument passed when the
+facility is invoked), then you may convey a copy of the modified
+version:
+
+ a) under this License, provided that you make a good faith effort to
+ ensure that, in the event an Application does not supply the
+ function or data, the facility still operates, and performs
+ whatever part of its purpose remains meaningful, or
+
+ b) under the GNU GPL, with none of the additional permissions of
+ this License applicable to that copy.
+
+ 3. Object Code Incorporating Material from Library Header Files.
+
+ The object code form of an Application may incorporate material from
+a header file that is part of the Library. You may convey such object
+code under terms of your choice, provided that, if the incorporated
+material is not limited to numerical parameters, data structure
+layouts and accessors, or small macros, inline functions and templates
+(ten or fewer lines in length), you do both of the following:
+
+ a) Give prominent notice with each copy of the object code that the
+ Library is used in it and that the Library and its use are
+ covered by this License.
+
+ b) Accompany the object code with a copy of the GNU GPL and this license
+ document.
+
+ 4. Combined Works.
+
+ You may convey a Combined Work under terms of your choice that,
+taken together, effectively do not restrict modification of the
+portions of the Library contained in the Combined Work and reverse
+engineering for debugging such modifications, if you also do each of
+the following:
+
+ a) Give prominent notice with each copy of the Combined Work that
+ the Library is used in it and that the Library and its use are
+ covered by this License.
+
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
+ document.
+
+ c) For a Combined Work that displays copyright notices during
+ execution, include the copyright notice for the Library among
+ these notices, as well as a reference directing the user to the
+ copies of the GNU GPL and this license document.
+
+ d) Do one of the following:
+
+ 0) Convey the Minimal Corresponding Source under the terms of this
+ License, and the Corresponding Application Code in a form
+ suitable for, and under terms that permit, the user to
+ recombine or relink the Application with a modified version of
+ the Linked Version to produce a modified Combined Work, in the
+ manner specified by section 6 of the GNU GPL for conveying
+ Corresponding Source.
+
+ 1) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (a) uses at run time
+ a copy of the Library already present on the user's computer
+ system, and (b) will operate properly with a modified version
+ of the Library that is interface-compatible with the Linked
+ Version.
+
+ e) Provide Installation Information, but only if you would otherwise
+ be required to provide such information under section 6 of the
+ GNU GPL, and only to the extent that such information is
+ necessary to install and execute a modified version of the
+ Combined Work produced by recombining or relinking the
+ Application with a modified version of the Linked Version. (If
+ you use option 4d0, the Installation Information must accompany
+ the Minimal Corresponding Source and Corresponding Application
+ Code. If you use option 4d1, you must provide the Installation
+ Information in the manner specified by section 6 of the GNU GPL
+ for conveying Corresponding Source.)
+
+ 5. Combined Libraries.
+
+ You may place library facilities that are a work based on the
+Library side by side in a single library together with other library
+facilities that are not Applications and are not covered by this
+License, and convey such a combined library under terms of your
+choice, if you do both of the following:
+
+ a) Accompany the combined library with a copy of the same work based
+ on the Library, uncombined with any other library facilities,
+ conveyed under the terms of this License.
+
+ b) Give prominent notice with the combined library that part of it
+ is a work based on the Library, and explaining where to find the
+ accompanying uncombined form of the same work.
+
+ 6. Revised Versions of the GNU Lesser General Public License.
+
+ The Free Software Foundation may publish revised and/or new versions
+of the GNU Lesser General Public License from time to time. Such new
+versions will be similar in spirit to the present version, but may
+differ in detail to address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Library as you received it specifies that a certain numbered version
+of the GNU Lesser General Public License "or any later version"
+applies to it, you have the option of following the terms and
+conditions either of that published version or of any later version
+published by the Free Software Foundation. If the Library as you
+received it does not specify a version number of the GNU Lesser
+General Public License, you may choose any version of the GNU Lesser
+General Public License ever published by the Free Software Foundation.
+
+ If the Library as you received it specifies that a proxy can decide
+whether future versions of the GNU Lesser General Public License shall
+apply, that proxy's public statement of acceptance of any version is
+permanent authorization for you to choose that version for the
+Library.
+
Added: trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/README.txt
===================================================================
--- trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/README.txt (rev 0)
+++ trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/README.txt 2010-03-30 20:35:54 UTC (rev 1731)
@@ -0,0 +1,2 @@
+To test parsers on a i18n project (says a project with some i18n translations)
+At the end we should have in target/generated-sources/i18n getters detected.
Added: trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/changelog.txt
===================================================================
--- trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/changelog.txt (rev 0)
+++ trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/changelog.txt 2010-03-30 20:35:54 UTC (rev 1731)
@@ -0,0 +1 @@
+see the changelog of org.nuiton:i18n project.
\ No newline at end of file
Added: trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/invoker.properties
===================================================================
--- trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/invoker.properties (rev 0)
+++ trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/invoker.properties 2010-03-30 20:35:54 UTC (rev 1731)
@@ -0,0 +1,21 @@
+# A comma or space separated list of goals/phases to execute, may
+# specify an empty list to execute the default goal of the IT project
+invoker.goals=clean process-resources
+
+# Optionally, a list of goals to run during further invocations of Maven
+#invoker.goals.2=${project.groupId}:${project.artifactId}:${project.version}:run
+
+# A comma or space separated list of profiles to activate
+#invoker.profiles=run-all run-once
+
+# The value for the environment variable MAVEN_OPTS
+#invoker.mavenOpts=-Dfile.encoding=UTF-16 -Xms32m -Xmx256m
+
+# Possible values are "fail-fast" (default), "fail-at-end" and "fail-never"
+invoker.failureBehavior=fail-at-end
+
+# The expected result of the build, possible values are "success" (default) and "failure"
+#invoker.buildResult=success
+
+# A boolean value controlling the -N flag, defaults to "false"
+#invoker.nonRecursive=false
Added: trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/pom.xml
===================================================================
--- trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/pom.xml (rev 0)
+++ trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/pom.xml 2010-03-30 20:35:54 UTC (rev 1731)
@@ -0,0 +1,79 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <!-- ************************************************************* -->
+ <!-- *** POM Relationships *************************************** -->
+ <!-- ************************************************************* -->
+
+ <parent>
+ <groupId>org.nuiton</groupId>
+ <artifactId>i18n</artifactId>
+ <version>@pom.version@</version>
+ </parent>
+
+ <artifactId>parsers-withNewKeys</artifactId>
+
+ <!-- ************************************************************* -->
+ <!-- *** Project Information ************************************* -->
+ <!-- ************************************************************* -->
+
+ <name>I18n Test :: parsers-new</name>
+
+ <!-- ************************************************************* -->
+ <!-- *** Build Settings ****************************************** -->
+ <!-- ************************************************************* -->
+
+ <packaging>jar</packaging>
+
+ <properties>
+
+ <i18nVersion>@pom.version@</i18nVersion>
+
+ <!-- default encoding -->
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+
+ </properties>
+
+ <build>
+
+ <plugins>
+
+ <plugin>
+ <groupId>org.nuiton.i18n</groupId>
+ <artifactId>maven-i18n-plugin</artifactId>
+ <version>${i18nVersion}</version>
+ <configuration>
+ <keepGetters>true</keepGetters>
+ </configuration>
+ <!--configuration>
+ <treateDefaultEntry>false</treateDefaultEntry>
+ <entries>
+ <entry>
+ <specificGoal>parserValidation</specificGoal>
+ <basedir>${maven.src.dir}/main/java/</basedir>
+ <includes>
+ <param>**/**-validation.xml</param>
+ </includes>
+ </entry>
+ </entries>
+ </configuration-->
+ <executions>
+ <execution>
+ <goals>
+ <goal>parserJava</goal>
+ <goal>parserValidation</goal>
+ <goal>gen</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
+
+
Added: trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/src/main/java/org/nuiton/i18n/test/MyBean.java
===================================================================
--- trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/src/main/java/org/nuiton/i18n/test/MyBean.java (rev 0)
+++ trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/src/main/java/org/nuiton/i18n/test/MyBean.java 2010-03-30 20:35:54 UTC (rev 1731)
@@ -0,0 +1,11 @@
+package org.nuiton.i18n.test;
+
+import static org.nuiton.i18n.I18n._;
+import static org.nuiton.i18n.I18n.n_;
+
+public class MyBean {
+
+ protected String field1 = n_("javaGetter.key1");
+
+ protected String field2 = _("javaGetter.key2");
+}
Property changes on: trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/src/main/java/org/nuiton/i18n/test/MyBean.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/src/main/resources/i18n/parsers-withNewKeys-fr_FR.properties
===================================================================
--- trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/src/main/resources/i18n/parsers-withNewKeys-fr_FR.properties (rev 0)
+++ trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/src/main/resources/i18n/parsers-withNewKeys-fr_FR.properties 2010-03-30 20:35:54 UTC (rev 1731)
@@ -0,0 +1,2 @@
+javaGetter.old.key1=hum1
+javaGetter.old.key2=hum2
Added: trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/src/main/resources/org/nuiton/i18n/test/MyBean-validation.xml
===================================================================
--- trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/src/main/resources/org/nuiton/i18n/test/MyBean-validation.xml (rev 0)
+++ trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/src/main/resources/org/nuiton/i18n/test/MyBean-validation.xml 2010-03-30 20:35:54 UTC (rev 1731)
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE validators PUBLIC
+ "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
+ "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
+<validators>
+
+ <field name="field1">
+
+ <field-validator type="required">
+ <message>validationGetter.key1</message>
+ </field-validator>
+
+ </field>
+
+ <field name="field2">
+
+ <field-validator type="required">
+ <message>validationGetter.key2##${parm1}</message>
+ </field-validator>
+
+ </field>
+
+</validators>
Added: trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/verify.groovy
===================================================================
--- trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/verify.groovy (rev 0)
+++ trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/verify.groovy 2010-03-30 20:35:54 UTC (rev 1731)
@@ -0,0 +1,29 @@
+
+file = new File(basedir, 'target/generated-sources/i18n/java.getter');
+assert file.exists();
+
+content = file.text;
+//assert content.contains( 'javaGetter.old.key1=' );
+//assert content.contains( 'javaGetter.old.key2=' );
+assert content.contains( 'javaGetter.key1=' );
+assert content.contains( 'javaGetter.key2=' );
+
+file = new File(basedir, 'target/generated-sources/i18n/validation.getter');
+assert file.exists();
+
+content = file.text;
+assert content.contains( 'validationGetter.key1=' );
+assert content.contains( 'validationGetter.key2=' );
+
+file = new File(basedir, 'src/main/resources/i18n/parsers-withNewKeys-fr_FR.properties');
+assert file.exists();
+
+content = file.text;
+assert content.contains( 'javaGetter.old.key1=' );
+assert content.contains( 'javaGetter.old.key2=' );
+assert content.contains( 'javaGetter.key1=' );
+assert content.contains( 'javaGetter.key2=' );
+assert content.contains( 'validationGetter.key1=' );
+assert content.contains( 'validationGetter.key2=' );
+
+return true;
Added: trunk/maven-i18n-plugin/src/it/settings.xml
===================================================================
--- trunk/maven-i18n-plugin/src/it/settings.xml (rev 0)
+++ trunk/maven-i18n-plugin/src/it/settings.xml 2010-03-30 20:35:54 UTC (rev 1731)
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<settings>
+
+ <profiles>
+ <profile>
+ <id>it-repo</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <repositories>
+ <repository>
+ <id>local.central</id>
+ <url>file:///@localRepository@</url>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </repository>
+ </repositories>
+ <pluginRepositories>
+ <pluginRepository>
+ <id>local.central</id>
+ <url>file:///@localRepository@</url>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </pluginRepository>
+ </pluginRepositories>
+ </profile>
+ </profiles>
+</settings>
1
0
Author: tchemit
Date: 2010-03-28 21:59:20 +0200 (Sun, 28 Mar 2010)
New Revision: 1725
Log:
add log4j in runtime for debug
Modified:
trunk/maven-i18n-plugin/pom.xml
Modified: trunk/maven-i18n-plugin/pom.xml
===================================================================
--- trunk/maven-i18n-plugin/pom.xml 2010-03-28 12:16:28 UTC (rev 1724)
+++ trunk/maven-i18n-plugin/pom.xml 2010-03-28 19:59:20 UTC (rev 1725)
@@ -78,6 +78,12 @@
<artifactId>plexus-utils</artifactId>
</dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <scope>runtime</scope>
+ </dependency>
+
</dependencies>
<!-- ************************************************************* -->
1
0
r1724 - trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser
by tchemit@users.nuiton.org 28 Mar '10
by tchemit@users.nuiton.org 28 Mar '10
28 Mar '10
Author: tchemit
Date: 2010-03-28 14:16:28 +0200 (Sun, 28 Mar 2010)
New Revision: 1724
Log:
Evolution #423: Improve parser log
Modified:
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/AbstractI18nParserMojo.java
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/AbstractI18nParserMojo.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/AbstractI18nParserMojo.java 2010-03-28 11:57:13 UTC (rev 1723)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/AbstractI18nParserMojo.java 2010-03-28 12:16:28 UTC (rev 1724)
@@ -25,7 +25,6 @@
import org.nuiton.io.SortedProperties;
import org.nuiton.plugin.PluginHelper;
-import java.beans.Introspector;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
@@ -322,14 +321,12 @@
for (ParserEvent event : events) {
event.eventChangeFile(file);
}
-// I18nLogger vLog = getVerboseLog();
-// vLog.setFile(file);
touchFile = false;
int size = result.size();
if (!silent && verbose) {
- getLog().info(print(getParser(this), 0, "parse", null, file.toString()));
-// vLog.infoFile("parse", null);
+ getLog().info(print(0, "parse", null,
+ file.toString()));
}
parseFile(file);
@@ -345,13 +342,14 @@
}
if (touchFile) {
if (showTouchedFiles) {
- getLog().info(print(getParser(this), 0, "touch", null, file.toString()));
-// vLog.infoFile("touch", null);
+ getLog().info(print(0, "touch", null,
+ file.toString()));
}
treadedFiles.add(file);
if (getLog().isDebugEnabled()) {
- getLog().debug(print(getParser(this), 0, "touch", null, file.toString() + " - " + getLogEntry(fileName, i, t000, t00)));
-// vLog.debug(I18nLogger.getLogEntry(fileName, i, t000, t00));
+ String time = getLogEntry(fileName, i, t000, t00);
+ getLog().debug(print(0, "touch", null,
+ file.toString() + " - " + time));
}
}
for (ParserEvent event : events) {
@@ -393,16 +391,10 @@
events.remove(parserEvent);
}
- public static String getParser(AbstractI18nMojo parser) {
- return "i18n:" + Introspector.decapitalize(
- parser.getClass().getSimpleName()) + " on " +
- parser.getArtifactId();
- }
-
- public static String print(String parser, int start, String prefix, String context,
+ public static String print(int start, String prefix, String context,
String content) {
StringBuilder sb = new StringBuilder();
- sb.append("[").append(prefix).append("] [").append(parser).append("] ");
+ sb.append("[").append(prefix).append("] ");
for (int i = 0; i < start; i++) {
sb.append(' ');
1
0
r1723 - trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/bundle
by tchemit@users.nuiton.org 28 Mar '10
by tchemit@users.nuiton.org 28 Mar '10
28 Mar '10
Author: tchemit
Date: 2010-03-28 13:57:13 +0200 (Sun, 28 Mar 2010)
New Revision: 1723
Log:
Evolution #423: Improve parser log
Modified:
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/BundleMojo.java
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/BundleMojo.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/BundleMojo.java 2010-03-28 10:57:23 UTC (rev 1722)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/BundleMojo.java 2010-03-28 11:57:13 UTC (rev 1723)
@@ -138,10 +138,6 @@
File bundleOut = getI18nFile(bundleOutputDir, bundleOutputName,
locale, false);
- if (!silent) {
- getLog().info("generate bundle for locale " + locale);
- }
-
SortedProperties propertiesOut =
new SortedProperties(encoding, false);
StringBuilder buffer = new StringBuilder();
@@ -152,6 +148,11 @@
continue;
}
+ if (!silent) {
+ getLog().info("generate bundle for locale " + locale +
+ " from " + urls.length + " i18n resource(s)");
+ }
+
List<String> bundlesUrls = new ArrayList<String>();
for (URL url : urls) {
long t000 = System.nanoTime();
@@ -174,7 +175,10 @@
if (!bundlesUrls.isEmpty()) {
bundleDico.put(locale, buffer.substring(1));
if (!silent) {
- getLog().info(bundlesUrls.size() + " i18n resource(s) detected");
+ if (getLog().isDebugEnabled()) {
+ getLog().debug(bundlesUrls.size() +
+ " i18n resource(s) detected");
+ }
for (String u : bundlesUrls) {
getLog().info(u);
}
1
0