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
Author: tchemit
Date: 2010-01-01 18:20:49 +0100 (Fri, 01 Jan 2010)
New Revision: 1692
Modified:
trunk/maven-i18n-plugin/pom.xml
Log:
use javadoc configuration from mavenpom
Modified: trunk/maven-i18n-plugin/pom.xml
===================================================================
--- trunk/maven-i18n-plugin/pom.xml 2009-12-29 17:35:17 UTC (rev 1691)
+++ trunk/maven-i18n-plugin/pom.xml 2010-01-01 17:20:49 UTC (rev 1692)
@@ -115,363 +115,13 @@
</plugins>
- <pluginManagement>
- <plugins>
- <plugin>
- <artifactId>maven-javadoc-plugin</artifactId>
- <version>${javadoc.version}</version>
- <configuration>
- <taglets>
- <taglet>
- <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoAggregatorTypeTaglet</tagletClass>
- <tagletArtifact>
- <groupId>org.apache.maven.plugin-tools</groupId>
- <artifactId>maven-plugin-tools-javadoc</artifactId>
- <version>2.4.2</version>
- </tagletArtifact>
- </taglet>
- <taglet>
- <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoComponentFieldTaglet</tagletClass>
- <tagletArtifact>
- <groupId>org.apache.maven.plugin-tools</groupId>
- <artifactId>maven-plugin-tools-javadoc</artifactId>
- <version>2.4.2</version>
- </tagletArtifact>
- </taglet>
- <taglet>
- <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoConfiguratorTypeTaglet</tagletClass>
- <tagletArtifact>
- <groupId>org.apache.maven.plugin-tools</groupId>
- <artifactId>maven-plugin-tools-javadoc</artifactId>
- <version>2.4.2</version>
- </tagletArtifact>
- </taglet>
- <taglet>
- <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoExecuteTypeTaglet</tagletClass>
- <tagletArtifact>
- <groupId>org.apache.maven.plugin-tools</groupId>
- <artifactId>maven-plugin-tools-javadoc</artifactId>
- <version>2.4.2</version>
- </tagletArtifact>
- </taglet>
- <taglet>
- <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoExecutionStrategyTypeTaglet</tagletClass>
- <tagletArtifact>
- <groupId>org.apache.maven.plugin-tools</groupId>
- <artifactId>maven-plugin-tools-javadoc</artifactId>
- <version>2.4.2</version>
- </tagletArtifact>
- </taglet>
- <taglet>
- <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoGoalTypeTaglet</tagletClass>
- <tagletArtifact>
- <groupId>org.apache.maven.plugin-tools</groupId>
- <artifactId>maven-plugin-tools-javadoc</artifactId>
- <version>2.4.2</version>
- </tagletArtifact>
- </taglet>
- <taglet>
- <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoInheritByDefaultTypeTaglet</tagletClass>
- <tagletArtifact>
- <groupId>org.apache.maven.plugin-tools</groupId>
- <artifactId>maven-plugin-tools-javadoc</artifactId>
- <version>2.4.2</version>
- </tagletArtifact>
- </taglet>
- <taglet>
- <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoInstantiationStrategyTypeTaglet</tagletClass>
- <tagletArtifact>
- <groupId>org.apache.maven.plugin-tools</groupId>
- <artifactId>maven-plugin-tools-javadoc</artifactId>
- <version>2.4.2</version>
- </tagletArtifact>
- </taglet>
- <taglet>
- <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoParameterFieldTaglet</tagletClass>
- <tagletArtifact>
- <groupId>org.apache.maven.plugin-tools</groupId>
- <artifactId>maven-plugin-tools-javadoc</artifactId>
- <version>2.4.2</version>
- </tagletArtifact>
- </taglet>
- <taglet>
- <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoPhaseTypeTaglet</tagletClass>
- <tagletArtifact>
- <groupId>org.apache.maven.plugin-tools</groupId>
- <artifactId>maven-plugin-tools-javadoc</artifactId>
- <version>2.4.2</version>
- </tagletArtifact>
- </taglet>
- <taglet>
- <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoReadOnlyFieldTaglet</tagletClass>
- <tagletArtifact>
- <groupId>org.apache.maven.plugin-tools</groupId>
- <artifactId>maven-plugin-tools-javadoc</artifactId>
- <version>2.4.2</version>
- </tagletArtifact>
- </taglet>
- <taglet>
- <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoRequiredFieldTaglet</tagletClass>
- <tagletArtifact>
- <groupId>org.apache.maven.plugin-tools</groupId>
- <artifactId>maven-plugin-tools-javadoc</artifactId>
- <version>2.4.2</version>
- </tagletArtifact>
- </taglet>
- <taglet>
- <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoRequiresDependencyResolutionTypeTaglet</tagletClass>
- <tagletArtifact>
- <groupId>org.apache.maven.plugin-tools</groupId>
- <artifactId>maven-plugin-tools-javadoc</artifactId>
- <version>2.4.2</version>
- </tagletArtifact>
- </taglet>
- <taglet>
- <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoRequiresDirectInvocationTypeTaglet</tagletClass>
- <tagletArtifact>
- <groupId>org.apache.maven.plugin-tools</groupId>
- <artifactId>maven-plugin-tools-javadoc</artifactId>
- <version>2.4.2</version>
- </tagletArtifact>
- </taglet>
- <taglet>
- <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoRequiresOnLineTypeTaglet</tagletClass>
- <tagletArtifact>
- <groupId>org.apache.maven.plugin-tools</groupId>
- <artifactId>maven-plugin-tools-javadoc</artifactId>
- <version>2.4.2</version>
- </tagletArtifact>
- </taglet>
- <taglet>
- <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoRequiresProjectTypeTaglet</tagletClass>
- <tagletArtifact>
- <groupId>org.apache.maven.plugin-tools</groupId>
- <artifactId>maven-plugin-tools-javadoc</artifactId>
- <version>2.4.2</version>
- </tagletArtifact>
- </taglet>
- <taglet>
- <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoRequiresReportsTypeTaglet</tagletClass>
- <tagletArtifact>
- <groupId>org.apache.maven.plugin-tools</groupId>
- <artifactId>maven-plugin-tools-javadoc</artifactId>
- <version>2.4.2</version>
- </tagletArtifact>
- </taglet>
-
- <taglet>
- <tagletClass>org.codehaus.plexus.javadoc.PlexusComponentTaglet</tagletClass>
- <tagletArtifact>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-javadoc</artifactId>
- <version>1.0</version>
- </tagletArtifact>
- </taglet>
- <taglet>
- <tagletClass>org.codehaus.plexus.javadoc.PlexusConfigurationTaglet</tagletClass>
- <tagletArtifact>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-javadoc</artifactId>
- <version>1.0</version>
- </tagletArtifact>
- </taglet>
- <taglet>
- <tagletClass>org.codehaus.plexus.javadoc.PlexusRequirementTaglet</tagletClass>
- <tagletArtifact>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-javadoc</artifactId>
- <version>1.0</version>
- </tagletArtifact>
- </taglet>
- </taglets>
- </configuration>
- <executions>
- <execution>
- <id>attach-javadocs</id>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </pluginManagement>
-
</build>
<reporting>
<plugins>
<plugin>
<artifactId>maven-plugin-plugin</artifactId>
- </plugin>
-
- <plugin>
- <artifactId>maven-javadoc-plugin</artifactId>
- <version>${javadoc.version}</version>
- <configuration>
- <taglets>
- <taglet>
- <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoAggregatorTypeTaglet</tagletClass>
- <tagletArtifact>
- <groupId>org.apache.maven.plugin-tools</groupId>
- <artifactId>maven-plugin-tools-javadoc</artifactId>
- <version>2.4.2</version>
- </tagletArtifact>
- </taglet>
- <taglet>
- <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoComponentFieldTaglet</tagletClass>
- <tagletArtifact>
- <groupId>org.apache.maven.plugin-tools</groupId>
- <artifactId>maven-plugin-tools-javadoc</artifactId>
- <version>2.4.2</version>
- </tagletArtifact>
- </taglet>
- <taglet>
- <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoConfiguratorTypeTaglet</tagletClass>
- <tagletArtifact>
- <groupId>org.apache.maven.plugin-tools</groupId>
- <artifactId>maven-plugin-tools-javadoc</artifactId>
- <version>2.4.2</version>
- </tagletArtifact>
- </taglet>
- <taglet>
- <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoExecuteTypeTaglet</tagletClass>
- <tagletArtifact>
- <groupId>org.apache.maven.plugin-tools</groupId>
- <artifactId>maven-plugin-tools-javadoc</artifactId>
- <version>2.4.2</version>
- </tagletArtifact>
- </taglet>
- <taglet>
- <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoExecutionStrategyTypeTaglet</tagletClass>
- <tagletArtifact>
- <groupId>org.apache.maven.plugin-tools</groupId>
- <artifactId>maven-plugin-tools-javadoc</artifactId>
- <version>2.4.2</version>
- </tagletArtifact>
- </taglet>
- <taglet>
- <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoGoalTypeTaglet</tagletClass>
- <tagletArtifact>
- <groupId>org.apache.maven.plugin-tools</groupId>
- <artifactId>maven-plugin-tools-javadoc</artifactId>
- <version>2.4.2</version>
- </tagletArtifact>
- </taglet>
- <taglet>
- <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoInheritByDefaultTypeTaglet</tagletClass>
- <tagletArtifact>
- <groupId>org.apache.maven.plugin-tools</groupId>
- <artifactId>maven-plugin-tools-javadoc</artifactId>
- <version>2.4.2</version>
- </tagletArtifact>
- </taglet>
- <taglet>
- <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoInstantiationStrategyTypeTaglet</tagletClass>
- <tagletArtifact>
- <groupId>org.apache.maven.plugin-tools</groupId>
- <artifactId>maven-plugin-tools-javadoc</artifactId>
- <version>2.4.2</version>
- </tagletArtifact>
- </taglet>
- <taglet>
- <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoParameterFieldTaglet</tagletClass>
- <tagletArtifact>
- <groupId>org.apache.maven.plugin-tools</groupId>
- <artifactId>maven-plugin-tools-javadoc</artifactId>
- <version>2.4.2</version>
- </tagletArtifact>
- </taglet>
- <taglet>
- <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoPhaseTypeTaglet</tagletClass>
- <tagletArtifact>
- <groupId>org.apache.maven.plugin-tools</groupId>
- <artifactId>maven-plugin-tools-javadoc</artifactId>
- <version>2.4.2</version>
- </tagletArtifact>
- </taglet>
- <taglet>
- <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoReadOnlyFieldTaglet</tagletClass>
- <tagletArtifact>
- <groupId>org.apache.maven.plugin-tools</groupId>
- <artifactId>maven-plugin-tools-javadoc</artifactId>
- <version>2.4.2</version>
- </tagletArtifact>
- </taglet>
- <taglet>
- <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoRequiredFieldTaglet</tagletClass>
- <tagletArtifact>
- <groupId>org.apache.maven.plugin-tools</groupId>
- <artifactId>maven-plugin-tools-javadoc</artifactId>
- <version>2.4.2</version>
- </tagletArtifact>
- </taglet>
- <taglet>
- <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoRequiresDependencyResolutionTypeTaglet</tagletClass>
- <tagletArtifact>
- <groupId>org.apache.maven.plugin-tools</groupId>
- <artifactId>maven-plugin-tools-javadoc</artifactId>
- <version>2.4.2</version>
- </tagletArtifact>
- </taglet>
- <taglet>
- <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoRequiresDirectInvocationTypeTaglet</tagletClass>
- <tagletArtifact>
- <groupId>org.apache.maven.plugin-tools</groupId>
- <artifactId>maven-plugin-tools-javadoc</artifactId>
- <version>2.4.2</version>
- </tagletArtifact>
- </taglet>
- <taglet>
- <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoRequiresOnLineTypeTaglet</tagletClass>
- <tagletArtifact>
- <groupId>org.apache.maven.plugin-tools</groupId>
- <artifactId>maven-plugin-tools-javadoc</artifactId>
- <version>2.4.2</version>
- </tagletArtifact>
- </taglet>
- <taglet>
- <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoRequiresProjectTypeTaglet</tagletClass>
- <tagletArtifact>
- <groupId>org.apache.maven.plugin-tools</groupId>
- <artifactId>maven-plugin-tools-javadoc</artifactId>
- <version>2.4.2</version>
- </tagletArtifact>
- </taglet>
- <taglet>
- <tagletClass>org.apache.maven.tools.plugin.javadoc.MojoRequiresReportsTypeTaglet</tagletClass>
- <tagletArtifact>
- <groupId>org.apache.maven.plugin-tools</groupId>
- <artifactId>maven-plugin-tools-javadoc</artifactId>
- <version>2.4.2</version>
- </tagletArtifact>
- </taglet>
-
- <taglet>
- <tagletClass>org.codehaus.plexus.javadoc.PlexusComponentTaglet</tagletClass>
- <tagletArtifact>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-javadoc</artifactId>
- <version>1.0</version>
- </tagletArtifact>
- </taglet>
- <taglet>
- <tagletClass>org.codehaus.plexus.javadoc.PlexusConfigurationTaglet</tagletClass>
- <tagletArtifact>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-javadoc</artifactId>
- <version>1.0</version>
- </tagletArtifact>
- </taglet>
- <taglet>
- <tagletClass>org.codehaus.plexus.javadoc.PlexusRequirementTaglet</tagletClass>
- <tagletArtifact>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-javadoc</artifactId>
- <version>1.0</version>
- </tagletArtifact>
- </taglet>
- </taglets>
- </configuration>
- </plugin>
-
+ </plugin>
</plugins>
</reporting>
1
0
r1691 - in trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin: . parser parser/impl
by tchemit@users.nuiton.org 29 Dec '09
by tchemit@users.nuiton.org 29 Dec '09
29 Dec '09
Author: tchemit
Date: 2009-12-29 18:35:17 +0100 (Tue, 29 Dec 2009)
New Revision: 1691
Removed:
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJaxxMojo.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserSwixatMojo.java
Modified:
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nBundleMojo.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nMojo.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/BundleMojo.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/CollectI18nArtifactsMojo.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/GetterMojo.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/impl/ParserJavaMojo.java
Log:
use AbstractPlugin
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nBundleMojo.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nBundleMojo.java 2009-12-28 10:27:28 UTC (rev 1690)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nBundleMojo.java 2009-12-29 17:35:17 UTC (rev 1691)
@@ -79,13 +79,4 @@
return bundleOut;
}
- @Override
- public void init() throws Exception {
- super.init();
-
- if (locales == null || locales.length == 0) {
- throw new IllegalStateException("il faut au moins une locale declaree (utiliser la propriete 'bundles')");
- }
- }
-
}
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 2009-12-28 10:27:28 UTC (rev 1690)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nMojo.java 2009-12-29 17:35:17 UTC (rev 1691)
@@ -19,9 +19,9 @@
* ##%* */
package org.nuiton.i18n.plugin;
-import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.project.MavenProject;
import org.nuiton.i18n.I18nUtil;
+import org.nuiton.plugin.AbstractPlugin;
import org.nuiton.plugin.PluginHelper;
import java.io.File;
@@ -36,7 +36,7 @@
*
* @author julien
*/
-public abstract class AbstractI18nMojo extends AbstractMojo {
+public abstract class AbstractI18nMojo extends AbstractPlugin {
/**
* Le nombre de getters détectés pendant le cycle de vie du build.
@@ -119,15 +119,23 @@
* @parameter expression="${i18n.strictMode}" default-value="false"
*/
protected boolean strictMode;
-
+ /**
+ * les locales a traiter
+ */
protected Locale[] locales;
/**
* logger verbeux
*/
protected I18nLogger verboseLog;
+ @Override
+ protected boolean checkPackaging() {
+ // nothing to do on a pom module
+ return !acceptPackaging(Packaging.pom);
+ }
public void init() throws Exception {
+// public boolean init() throws Exception {
verboseLog = new I18nLogger(this);
@@ -135,6 +143,10 @@
getLog().info("config - verbose mode is on");
}
locales = I18nUtil.parseLocales(bundles);
+ if (locales == null || locales.length == 0) {
+ throw new IllegalStateException("Il faut au moins une locale declaree (utiliser la propriete 'bundles')");
+ }
+// return true;
}
public String getArtifactId() {
@@ -175,8 +187,7 @@
public File getI18nFile(File root, String artifactId, Locale locale, boolean create) throws IOException {
File file = new File(root.getAbsolutePath() + File.separatorChar + artifactId + "-" + locale.toString() + ".properties");
if (create && !file.exists()) {
- PluginHelper.createDirectoryIfNecessary(file.getParentFile());
- PluginHelper.createNewFile(file);
+ createNewFile(file);
}
return file;
}
@@ -191,31 +202,31 @@
public File getGetterFile(File root, String getter, boolean create) throws IOException {
File file = new File(root.getAbsolutePath() + File.separatorChar + getter);
if (create && !file.exists()) {
- PluginHelper.createDirectoryIfNecessary(file.getParentFile());
- PluginHelper.createNewFile(file);
+ createNewFile(file);
}
return file;
}
- /**
- * @param root le repertoire ou sont stockes les fichiers getter
- * @param getter le nom du getter
- * @return le fichier i18n
- */
- public File getGetterFileBackup(File root, String getter) {
- return new File(root.getAbsolutePath() + File.separatorChar + getter + '~');
- }
- /**
- * @param root le reertoire ou sont stockes les fichiers i18n
- * @param artifactId le nom de l'artifact
- * @param bundle le nom du bundle
- * @return le fichier i18n de backup
- */
- public File getI18nFileBackup(File root, String artifactId, Locale bundle) {
- return new File(root.getAbsolutePath() + File.separatorChar + artifactId + "-" + bundle.toString() + ".properties~");
- }
+// /**
+// * @param root le repertoire ou sont stockes les fichiers getter
+// * @param getter le nom du getter
+// * @return le fichier i18n
+// */
+// public File getGetterFileBackup(File root, String getter) {
+// return new File(root.getAbsolutePath() + File.separatorChar + getter + '~');
+// }
+// /**
+// * @param root le reertoire ou sont stockes les fichiers i18n
+// * @param artifactId le nom de l'artifact
+// * @param bundle le nom du bundle
+// * @return le fichier i18n de backup
+// */
+// public File getI18nFileBackup(File root, String artifactId, Locale bundle) {
+// return new File(root.getAbsolutePath() + File.separatorChar + artifactId + "-" + bundle.toString() + ".properties~");
+// }
+
protected void checkBundle(Locale locale, Properties propertiesOut, boolean showEmpty) {
// on verifie qu'il n'y a pas de traduction vide
SortedSet<String> emptyEntries = PluginHelper.getEmptyKeys(propertiesOut);
@@ -245,11 +256,42 @@
}
}
+
+ public File getBackupFile(File file) {
+ return new File(file.getAbsolutePath() + "~");
+ }
+
protected void backupFile(File f) throws IOException {
- PluginHelper.copy(f, new File(f.getAbsolutePath() + "~"));
+ File dst = getBackupFile(f);
+ copyFile(f, dst);
}
- protected void copyFile(File src, File dst) throws IOException {
- PluginHelper.copy(src, dst);
+// protected void copyFile(File src, File dst) throws IOException {
+// PluginHelper.copy(src, dst);
+// }
+
+
+ public String getEncoding() {
+ return encoding;
}
+
+ public void setEncoding(String encoding) {
+ this.encoding = encoding;
+ }
+
+ public MavenProject getProject() {
+ return project;
+ }
+
+ public void setProject(MavenProject project) {
+ this.project = project;
+ }
+
+ public boolean isVerbose() {
+ return verbose;
+ }
+
+ public void setVerbose(boolean verbose) {
+ this.verbose = verbose;
+ }
}
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/BundleMojo.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/BundleMojo.java 2009-12-28 10:27:28 UTC (rev 1690)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/BundleMojo.java 2009-12-29 17:35:17 UTC (rev 1691)
@@ -19,9 +19,6 @@
* ##%* */
package org.nuiton.i18n.plugin;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.project.MavenProject;
import org.nuiton.i18n.bundle.I18nBundleEntry;
import org.nuiton.i18n.bundle.I18nBundleFactory;
import org.nuiton.io.SortedProperties;
@@ -95,42 +92,23 @@
* @since 1.0.0
*/
protected boolean showEmpty;
- /**
- * Dependance du projet.
- *
- * @parameter default-value="${project}"
- * @required
- * @since 1.0.0
- */
- protected MavenProject project;
@Override
public void init() throws Exception {
super.init();
- PluginHelper.createDirectoryIfNecessary(bundleOutputDir);
+ createDirectoryIfNecessary(bundleOutputDir);
// ajout de repertoire de generation (le parent en fait)
// dans les resources du projet
- PluginHelper.addResourceDir(bundleOutputDir.getParentFile(), project, "**/*.properties");
+ addResourceDir(bundleOutputDir.getParentFile(), "**/*.properties");
}
@Override
- public void execute() throws MojoExecutionException, MojoFailureException {
-
- if ("pom".equals(project.getPackaging()) || "site".equals(project.getPackaging())) {
- return;
- }
-
+ protected void doAction() throws Exception {
long t00 = System.nanoTime();
- try {
- init();
- } catch (Exception e) {
- throw new MojoExecutionException("could not init gaol for reason " + e.getMessage(), e);
- }
-
if (!silent) {
getLog().info("config - bundle name : " + bundleOutputName);
getLog().info("config - basedir : " + bundleOutputDir);
@@ -139,80 +117,170 @@
Map<Locale, String> bundleDico = new LinkedHashMap<Locale, String>(locales.length);
- try {
+ for (Locale locale : locales) {
- for (Locale locale : locales) {
+ long t0 = System.nanoTime();
- long t0 = System.nanoTime();
+ File bundleOut = getI18nFile(bundleOutputDir, bundleOutputName, locale, false);
- File bundleOut = getI18nFile(bundleOutputDir, bundleOutputName, locale, false);
+ if (!silent) {
+ getLog().info("generate bundle for locale " + locale);
+ }
- if (!silent) {
- getLog().info("generate bundle for locale " + locale);
- }
+ SortedProperties propertiesOut = new SortedProperties(encoding, false);
+ StringBuilder buffer = new StringBuilder();
- SortedProperties propertiesOut = new SortedProperties(encoding, false);
- StringBuilder buffer = new StringBuilder();
+ URL[] urls = getCollectI18nResources(locale);
+ if (urls.length == 0) {
+ getLog().warn("no bundle for locale " + locale);
+ continue;
+ }
- URL[] urls = getCollectI18nResources(locale);
- if (urls.length == 0) {
- getLog().warn("no bundle for locale " + locale);
- continue;
- }
+ for (URL url : urls) {
+ long t000 = System.nanoTime();
+ I18nBundleEntry bundleEntry = new I18nBundleEntry(url, locale, null);
+ bundleEntry.load(propertiesOut);
+ String strPath = bundleEntry.getPath().toString();
+ int index = strPath.indexOf("i18n/");
- for (URL url : urls) {
- long t000 = System.nanoTime();
- I18nBundleEntry bundleEntry = new I18nBundleEntry(url, locale, null);
- bundleEntry.load(propertiesOut);
- String strPath = bundleEntry.getPath().toString();
- int index = strPath.indexOf("i18n/");
-
- buffer.append(',').append(strPath.substring(index));
- if (verbose) {
- getLog().info("loaded " + bundleEntry.getPath() + " in " + PluginHelper.convertTime(t000, System.nanoTime()));
- }
+ buffer.append(',').append(strPath.substring(index));
+ if (verbose) {
+ getLog().info("loaded " + bundleEntry.getPath() + " in " + PluginHelper.convertTime(t000, System.nanoTime()));
}
+ }
- if (buffer.length() > 0) {
- bundleDico.put(locale, buffer.substring(1));
- if (!silent) {
- getLog().info("bundles for locale : " + bundleDico.get(locale));
- }
+ if (buffer.length() > 0) {
+ bundleDico.put(locale, buffer.substring(1));
+ if (!silent) {
+ getLog().info("bundles for locale : " + bundleDico.get(locale));
}
- propertiesOut.store(bundleOut);
- if (!silent && verbose) {
- getLog().info("bundle created in " + PluginHelper.convertTime(t0, System.nanoTime()) + " (detected sentences : " + propertiesOut.size() + ")");
- }
- if (checkBundle) {
- checkBundle(locale, propertiesOut, showEmpty);
- }
}
-
- // ecriture du ficher des definitions i18n (permet de faire une
- // recherche extact sur un fichier puis d'en deduire les bundles a
- // charger
- String f = String.format(I18nBundleFactory.UNIQUE_BUNDLE_DEF, bundleOutputName);
- File defOut = new File(bundleOutputDir, f);
- if (!silent) {
- getLog().info("prepare i18n definition " + defOut.getAbsolutePath());
+ propertiesOut.store(bundleOut);
+ if (!silent && verbose) {
+ getLog().info("bundle created in " + PluginHelper.convertTime(t0, System.nanoTime()) + " (detected sentences : " + propertiesOut.size() + ")");
}
- SortedProperties p = new SortedProperties(encoding, false);
- p.setProperty(I18nBundleFactory.BUNDLE_DEF_LOCALES, bundles);
- for (Entry<Locale, String> e : bundleDico.entrySet()) {
- p.setProperty(I18nBundleFactory.BUNDLES_FOR_LOCALE + e.getKey().toString(), e.getValue());
+ if (checkBundle) {
+ checkBundle(locale, propertiesOut, showEmpty);
}
- p.store(new FileOutputStream(defOut), null);
+ }
- if (!silent && verbose) {
- getLog().info("done in " + PluginHelper.convertTime(t00, System.nanoTime()));
- }
- } catch (IOException e) {
- getLog().error("File Error I/O ", e);
- throw new MojoFailureException("File Error I/O ");
+ // ecriture du ficher des definitions i18n (permet de faire une
+ // recherche extact sur un fichier puis d'en deduire les bundles a
+ // charger
+ String f = String.format(I18nBundleFactory.UNIQUE_BUNDLE_DEF, bundleOutputName);
+ File defOut = new File(bundleOutputDir, f);
+ if (!silent) {
+ getLog().info("prepare i18n definition " + defOut.getAbsolutePath());
}
+ SortedProperties p = new SortedProperties(encoding, false);
+ p.setProperty(I18nBundleFactory.BUNDLE_DEF_LOCALES, bundles);
+ for (Entry<Locale, String> e : bundleDico.entrySet()) {
+ p.setProperty(I18nBundleFactory.BUNDLES_FOR_LOCALE + e.getKey().toString(), e.getValue());
+ }
+ p.store(new FileOutputStream(defOut), null);
+
+ if (!silent && verbose) {
+ getLog().info("done in " + PluginHelper.convertTime(t00, System.nanoTime()));
+ }
}
+// @Override
+// public void execute() throws MojoExecutionException, MojoFailureException {
+//
+// if ("pom".equals(project.getPackaging()) || "site".equals(project.getPackaging())) {
+// return;
+// }
+//
+// long t00 = System.nanoTime();
+//
+// try {
+// init();
+// } catch (Exception e) {
+// throw new MojoExecutionException("could not init gaol for reason " + e.getMessage(), e);
+// }
+//
+// if (!silent) {
+// getLog().info("config - bundle name : " + bundleOutputName);
+// getLog().info("config - basedir : " + bundleOutputDir);
+// getLog().info("config - locales : " + Arrays.toString(locales));
+// }
+//
+// Map<Locale, String> bundleDico = new LinkedHashMap<Locale, String>(locales.length);
+//
+// try {
+//
+// for (Locale locale : locales) {
+//
+// long t0 = System.nanoTime();
+//
+// 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();
+//
+// URL[] urls = getCollectI18nResources(locale);
+// if (urls.length == 0) {
+// getLog().warn("no bundle for locale " + locale);
+// continue;
+// }
+//
+// for (URL url : urls) {
+// long t000 = System.nanoTime();
+// I18nBundleEntry bundleEntry = new I18nBundleEntry(url, locale, null);
+// bundleEntry.load(propertiesOut);
+// String strPath = bundleEntry.getPath().toString();
+// int index = strPath.indexOf("i18n/");
+//
+// buffer.append(',').append(strPath.substring(index));
+// if (verbose) {
+// getLog().info("loaded " + bundleEntry.getPath() + " in " + PluginHelper.convertTime(t000, System.nanoTime()));
+// }
+// }
+//
+// if (buffer.length() > 0) {
+// bundleDico.put(locale, buffer.substring(1));
+// if (!silent) {
+// getLog().info("bundles for locale : " + bundleDico.get(locale));
+// }
+// }
+// propertiesOut.store(bundleOut);
+// if (!silent && verbose) {
+// getLog().info("bundle created in " + PluginHelper.convertTime(t0, System.nanoTime()) + " (detected sentences : " + propertiesOut.size() + ")");
+// }
+// if (checkBundle) {
+// checkBundle(locale, propertiesOut, showEmpty);
+// }
+// }
+//
+// // ecriture du ficher des definitions i18n (permet de faire une
+// // recherche extact sur un fichier puis d'en deduire les bundles a
+// // charger
+// String f = String.format(I18nBundleFactory.UNIQUE_BUNDLE_DEF, bundleOutputName);
+// File defOut = new File(bundleOutputDir, f);
+// if (!silent) {
+// getLog().info("prepare i18n definition " + defOut.getAbsolutePath());
+// }
+// SortedProperties p = new SortedProperties(encoding, false);
+// p.setProperty(I18nBundleFactory.BUNDLE_DEF_LOCALES, bundles);
+// for (Entry<Locale, String> e : bundleDico.entrySet()) {
+// p.setProperty(I18nBundleFactory.BUNDLES_FOR_LOCALE + e.getKey().toString(), e.getValue());
+// }
+// p.store(new FileOutputStream(defOut), null);
+//
+// if (!silent && verbose) {
+// getLog().info("done in " + PluginHelper.convertTime(t00, System.nanoTime()));
+// }
+// } catch (IOException e) {
+// getLog().error("File Error I/O ", e);
+// throw new MojoFailureException("File Error I/O ");
+// }
+// }
+
@Override
protected URL[] getCollectI18nResources(Locale locale) throws IOException {
File file = getCollectOutputFile(locale, false);
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/CollectI18nArtifactsMojo.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/CollectI18nArtifactsMojo.java 2009-12-28 10:27:28 UTC (rev 1690)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/CollectI18nArtifactsMojo.java 2009-12-29 17:35:17 UTC (rev 1691)
@@ -27,8 +27,6 @@
import org.apache.maven.artifact.resolver.ArtifactCollector;
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
import org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.shared.dependency.tree.DependencyNode;
import org.apache.maven.shared.dependency.tree.DependencyTreeBuilder;
import org.apache.maven.shared.dependency.tree.DependencyTreeBuilderException;
@@ -56,7 +54,6 @@
* $Author: tchemit $
* @goal collect-i18n-artifacts
* @phase generate-resources
- * @execute goal=gen
* @requiresProject true
* @requiresDependencyResolution runtime
* @since 1.0.2
@@ -106,62 +103,89 @@
public void init() throws Exception {
super.init();
- if (locales == null || locales.length == 0) {
- throw new IllegalStateException("il faut au moins une locale declaree (utiliser la propriete 'bundles')");
- }
-
PluginHelper.createDirectoryIfNecessary(collectOutputDir);
}
@Override
- public void execute() throws MojoExecutionException, MojoFailureException {
+ protected void doAction() throws Exception {
- if ("pom".equals(project.getPackaging()) || "site".equals(project.getPackaging())) {
- getLog().info("skip goal for none java-based packaging.");
+ // detects the i18n artifacts (only once since it cost some times)...
+ i18nArtifacts = detectI18nArtifacts();
+
+ if (i18nArtifacts.length == 0) {
+ getLog().warn("no i18n artifact detected.");
return;
}
- try {
- init();
- } catch (Exception e) {
- throw new MojoExecutionException("could not init goal for reason " + e.getMessage(), e);
- }
+ for (Locale locale : locales) {
- try {
+ if (!silent) {
+ getLog().info("generate collected i18n artifacts for locale " + locale);
+ }
+ URL[] urls = getCollectI18nResources(locale);
- // detects the i18n artifacts (only once since it cost some times)...
- i18nArtifacts = detectI18nArtifacts();
-
- if (i18nArtifacts.length == 0) {
- getLog().warn("no i18n artifact detected.");
+ if (urls.length == 0) {
+ getLog().warn("no i18n bundles for locale " + locale);
return;
}
- for (Locale locale : locales) {
+ File bundleOut = getCollectOutputFile(locale, true);
- if (!silent) {
- getLog().info("generate collected i18n artifacts for locale " + locale);
- }
- URL[] urls = getCollectI18nResources(locale);
+ storeCollectI18nResources(bundleOut, urls);
- if (urls.length == 0) {
- getLog().warn("no i18n bundles for locale " + locale);
- return;
- }
-
- File bundleOut = getCollectOutputFile(locale, true);
-
- storeCollectI18nResources(bundleOut, urls);
-
- getLog().info("collected " + urls.length + " i18n artifacts for locale " + locale + " stored in " + bundleOut);
- }
- } catch (IOException e) {
- throw new MojoExecutionException("could not treate i18n artifacts", e);
- } catch (DependencyTreeBuilderException e) {
- throw new MojoExecutionException("could not obtain i18n artifacts", e);
+ getLog().info("collected " + urls.length + " i18n artifacts for locale " + locale + " stored in " + bundleOut);
}
}
+// @Override
+// public void execute() throws MojoExecutionException, MojoFailureException {
+//
+// if ("pom".equals(project.getPackaging()) || "site".equals(project.getPackaging())) {
+// getLog().info("skip goal for none java-based packaging.");
+// return;
+// }
+//
+// try {
+// init();
+// } catch (Exception e) {
+// throw new MojoExecutionException("could not init goal for reason " + e.getMessage(), e);
+// }
+//
+// try {
+//
+// // detects the i18n artifacts (only once since it cost some times)...
+// i18nArtifacts = detectI18nArtifacts();
+//
+// if (i18nArtifacts.length == 0) {
+// getLog().warn("no i18n artifact detected.");
+// return;
+// }
+//
+// for (Locale locale : locales) {
+//
+// if (!silent) {
+// getLog().info("generate collected i18n artifacts for locale " + locale);
+// }
+// URL[] urls = getCollectI18nResources(locale);
+//
+// if (urls.length == 0) {
+// getLog().warn("no i18n bundles for locale " + locale);
+// return;
+// }
+//
+// File bundleOut = getCollectOutputFile(locale, true);
+//
+// storeCollectI18nResources(bundleOut, urls);
+//
+// getLog().info("collected " + urls.length + " i18n artifacts for locale " + locale + " stored in " + bundleOut);
+// }
+// } catch (IOException e) {
+// throw new MojoExecutionException("could not treate i18n artifacts", e);
+// } catch (DependencyTreeBuilderException e) {
+// throw new MojoExecutionException("could not obtain i18n artifacts", e);
+// }
+// }
+
@Override
protected URL[] getCollectI18nResources(Locale locale) throws IOException, DependencyTreeBuilderException {
@@ -194,7 +218,7 @@
getLog().info("add " + path);
}
}
- PluginHelper.writeString(bundleOut, buffer.toString(), encoding);
+ writeFile(bundleOut, buffer.toString(), encoding);
}
/**
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 2009-12-28 10:27:28 UTC (rev 1690)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/GenerateMojo.java 2009-12-29 17:35:17 UTC (rev 1691)
@@ -19,13 +19,10 @@
* ##%* */
package org.nuiton.i18n.plugin;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
import org.nuiton.io.SortedProperties;
import java.io.File;
import java.io.FileOutputStream;
-import java.io.IOException;
import java.util.Arrays;
import java.util.Locale;
@@ -64,19 +61,16 @@
protected boolean keepBackup;
@Override
- public void execute() throws MojoExecutionException, MojoFailureException {
-
- try {
- init();
- } catch (Exception e) {
- throw new MojoExecutionException("could not init goal for reason " + e.getMessage(), e);
- }
-
+ protected boolean checkSkip() {
if (!needGeneration()) {
- getLog().info("Nothing to generate - all files are up to date.");
- return;
+ getLog().info("No getter detected - all files are up to date.");
+ return false;
}
+ return true;
+ }
+ @Override
+ protected void doAction() throws Exception {
if (!silent) {
getLog().info("config - src basedir : " + src.getAbsolutePath());
getLog().info("config - out basedir : " + out.getAbsolutePath());
@@ -86,72 +80,156 @@
if (!silent) {
getLog().info("prepare bundle for locale " + locale);
}
- try {
- // Merge
- File bundleSrc = getI18nFile(src, artifactId, locale, false);
- File bundleOut = getI18nFile(out, artifactId, locale, false);
+ // Merge
+ File bundleSrc = getI18nFile(src, artifactId, locale, false);
+ File bundleOut = getI18nFile(out, artifactId, locale, false);
- SortedProperties propertiesSrc = new SortedProperties(encoding);
+ SortedProperties propertiesSrc = new SortedProperties(encoding);
- if (bundleSrc.exists()) {
- propertiesSrc.load(bundleSrc);
- }
+ if (bundleSrc.exists()) {
+ propertiesSrc.load(bundleSrc);
+ }
- SortedProperties propertiesOut = new SortedProperties(encoding);
+ SortedProperties propertiesOut = new SortedProperties(encoding);
- if (!strictMode) {
- // si on n'est pas en mode strict, on doit push back in bundle out, all the bundle src keys
- propertiesOut.putAll(propertiesSrc);
- }
- propertiesOut.load(bundleOut);
+ if (!strictMode) {
+ // si on n'est pas en mode strict, on doit push back in bundle out, all the bundle src keys
+ propertiesOut.putAll(propertiesSrc);
+ }
+ propertiesOut.load(bundleOut);
- // Parcours des clés
- for (Object key : propertiesOut.keySet()) {
- Object oldKey = propertiesOut.get(key);
- Object value = propertiesSrc.get(oldKey);
+ // Parcours des clés
+ for (Object key : propertiesOut.keySet()) {
+ Object oldKey = propertiesOut.get(key);
+ Object value = propertiesSrc.get(oldKey);
- // Récupération de la clé si elle a été renommée
- if (!key.equals(oldKey) && value == null) {
- value = propertiesSrc.get(key);
- }
+ // Récupération de la clé si elle a été renommée
+ if (!key.equals(oldKey) && value == null) {
+ value = propertiesSrc.get(key);
+ }
- if (value != null) {
- propertiesOut.put(key, value);
- } else {
- propertiesOut.put(key, "");
- }
+ if (value != null) {
+ propertiesOut.put(key, value);
+ } else {
+ propertiesOut.put(key, "");
}
+ }
- //fixme : on devrait laisser le fichier en utf8 ?
- //propertiesOut.store(bundleOut);
- propertiesOut.store(new FileOutputStream(bundleOut));
+ //fixme : on devrait laisser le fichier en utf8 ?
+ //propertiesOut.store(bundleOut);
+ propertiesOut.store(new FileOutputStream(bundleOut));
- // Sauvegarde avant copie
- if (genSrc && keepBackup) {
- backupFile(bundleSrc);
- }
- if (!silent) {
- getLog().info("merge bundle " + locale + " to out");
- }
+ // Sauvegarde avant copie
+ if (genSrc && keepBackup) {
+ backupFile(bundleSrc);
+ }
+ if (!silent) {
+ getLog().info("merge bundle " + locale + " to out");
+ }
- if (checkBundle) {
- checkBundle(locale, propertiesOut, showEmpty);
- }
+ if (checkBundle) {
+ checkBundle(locale, propertiesOut, showEmpty);
+ }
- if (genSrc) {
- // Copie des fichiers dans les sources
- copyFile(bundleOut, bundleSrc);
- //if (verbose) {
- if (!silent) {
- getLog().info("copy bundle " + locale + " to src");
- }
- //}
+ if (genSrc) {
+ // Copie des fichiers dans les sources
+ copyFile(bundleOut, bundleSrc);
+ if (!silent) {
+ getLog().info("copy bundle " + locale + " to src");
}
-
- } catch (IOException e) {
- getLog().error("File Error I/O ", e);
- throw new MojoFailureException("File Error I/O ");
}
}
}
+
+// @Override
+// public void execute() throws MojoExecutionException, MojoFailureException {
+//
+// try {
+// init();
+// } catch (Exception e) {
+// throw new MojoExecutionException("could not init goal for reason " + e.getMessage(), e);
+// }
+//
+// if (!needGeneration()) {
+// getLog().info("Nothing to generate - all files are up to date.");
+// return;
+// }
+//
+// if (!silent) {
+// getLog().info("config - src basedir : " + src.getAbsolutePath());
+// getLog().info("config - out basedir : " + out.getAbsolutePath());
+// getLog().info("config - locales : " + Arrays.toString(locales));
+// }
+// for (Locale locale : locales) {
+// if (!silent) {
+// getLog().info("prepare bundle for locale " + locale);
+// }
+// try {
+// // Merge
+// File bundleSrc = getI18nFile(src, artifactId, locale, false);
+// File bundleOut = getI18nFile(out, artifactId, locale, false);
+//
+// SortedProperties propertiesSrc = new SortedProperties(encoding);
+//
+// if (bundleSrc.exists()) {
+// propertiesSrc.load(bundleSrc);
+// }
+//
+// SortedProperties propertiesOut = new SortedProperties(encoding);
+//
+// if (!strictMode) {
+// // si on n'est pas en mode strict, on doit push back in bundle out, all the bundle src keys
+// propertiesOut.putAll(propertiesSrc);
+// }
+// propertiesOut.load(bundleOut);
+//
+// // Parcours des clés
+// for (Object key : propertiesOut.keySet()) {
+// Object oldKey = propertiesOut.get(key);
+// Object value = propertiesSrc.get(oldKey);
+//
+// // Récupération de la clé si elle a été renommée
+// if (!key.equals(oldKey) && value == null) {
+// value = propertiesSrc.get(key);
+// }
+//
+// if (value != null) {
+// propertiesOut.put(key, value);
+// } else {
+// propertiesOut.put(key, "");
+// }
+// }
+//
+// //fixme : on devrait laisser le fichier en utf8 ?
+// //propertiesOut.store(bundleOut);
+// propertiesOut.store(new FileOutputStream(bundleOut));
+//
+// // Sauvegarde avant copie
+// if (genSrc && keepBackup) {
+// backupFile(bundleSrc);
+// }
+// if (!silent) {
+// getLog().info("merge bundle " + locale + " to out");
+// }
+//
+// if (checkBundle) {
+// checkBundle(locale, propertiesOut, showEmpty);
+// }
+//
+// if (genSrc) {
+// // Copie des fichiers dans les sources
+// copyFile(bundleOut, bundleSrc);
+// //if (verbose) {
+// if (!silent) {
+// getLog().info("copy bundle " + locale + " to src");
+// }
+// //}
+// }
+//
+// } catch (IOException e) {
+// getLog().error("File Error I/O ", e);
+// throw new MojoFailureException("File Error I/O ");
+// }
+// }
+// }
}
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/GetterMojo.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/GetterMojo.java 2009-12-28 10:27:28 UTC (rev 1690)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/GetterMojo.java 2009-12-29 17:35:17 UTC (rev 1691)
@@ -19,8 +19,6 @@
* ##%* */
package org.nuiton.i18n.plugin;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
import org.codehaus.plexus.util.DirectoryScanner;
import org.nuiton.io.SortedProperties;
import org.nuiton.plugin.PluginHelper;
@@ -40,69 +38,124 @@
public class GetterMojo extends AbstractI18nMojo {
@Override
- public void execute() throws MojoExecutionException, MojoFailureException {
+ protected boolean checkSkip() {
- try {
- init();
- } catch (Exception e) {
- throw new MojoExecutionException("could not init goal for reason " + e.getMessage(), e);
+ if (!needGeneration()) {
+// if (verbose) {
+ getLog().info("No getter detected - all files are up to date.");
+// }
+ return false;
}
+ return true;
+ }
- if (!needGeneration()) {
- if (verbose) {
- getLog().info("Nothing to generate - all files are up to date.");
- }
- return;
- }
+ @Override
+ protected void doAction() throws Exception {
+
if (!silent) {
getLog().info("config - basedir : " + out.getAbsolutePath());
getLog().info("config - locales : " + Arrays.toString(locales));
}
- try {
- File bundleGetters = new File(out.getAbsolutePath() + File.separatorChar + artifactId + ".properties");
- boolean b = bundleGetters.createNewFile();
- if (!b) {
- throw new IOException("could not create file " + bundleGetters);
- }
- DirectoryScanner ds = new DirectoryScanner();
- ds.setBasedir(out);
- ds.setIncludes(new String[]{"*.getter"});
- ds.scan();
- String[] files = ds.getIncludedFiles();
+ File bundleGetters = new File(out.getAbsolutePath() + File.separatorChar + artifactId + ".properties");
+ createNewFile(bundleGetters);
+ DirectoryScanner ds = new DirectoryScanner();
+ ds.setBasedir(out);
+ ds.setIncludes(new String[]{"*.getter"});
+ ds.scan();
+ String[] files = ds.getIncludedFiles();
- // Fusion des fichiers propriétés des différents parsers
- for (String file : files) {
- long t0 = System.nanoTime();
- File bundleGetter = getGetterFile(out, file, false);
- concactProperties(bundleGetter, bundleGetters);
- if (genSrc) {
- PluginHelper.deleteFile(bundleGetter);
- }
- if (!silent) {
- getLog().info("import getter " + bundleGetter.getName() + " in " + PluginHelper.convertTime(System.nanoTime() - t0));
- }
+ // Fusion des fichiers propriétés des différents parsers
+ for (String file : files) {
+ long t0 = System.nanoTime();
+ File bundleGetter = getGetterFile(out, file, false);
+ concactProperties(bundleGetter, bundleGetters);
+ if (genSrc) {
+ deleteFile(bundleGetter);
}
+ if (!silent) {
+ getLog().info("import getter " + bundleGetter.getName() + " in " + PluginHelper.convertTime(System.nanoTime() - t0));
+ }
+ }
- // Création des bundles
- for (Locale locale : locales) {
- if (getLog().isDebugEnabled()) {
- getLog().debug("generate bundle for locale " + locale);
- }
- File bundleOut = getI18nFile(out, artifactId, locale, false);
- copyFile(bundleGetters, bundleOut);
- if (!silent && verbose) {
- getLog().info("generate bundle " + locale);
- }
+ // Création des bundles
+ for (Locale locale : locales) {
+ if (getLog().isDebugEnabled()) {
+ getLog().debug("generate bundle for locale " + locale);
}
- PluginHelper.deleteFile(bundleGetters);
- } catch (IOException e) {
- getLog().error("File Error I/O ", e);
- throw new MojoFailureException("File Error I/O");
+ File bundleOut = getI18nFile(out, artifactId, locale, false);
+ copyFile(bundleGetters, bundleOut);
+ if (!silent && verbose) {
+ getLog().info("generate bundle " + locale);
+ }
}
+ deleteFile(bundleGetters);
}
+// @Override
+// public void execute() throws MojoExecutionException, MojoFailureException {
+//
+// try {
+// init();
+// } catch (Exception e) {
+// throw new MojoExecutionException("could not init goal for reason " + e.getMessage(), e);
+// }
+//
+// if (!needGeneration()) {
+// if (verbose) {
+// getLog().info("Nothing to generate - all files are up to date.");
+// }
+// return;
+// }
+// if (!silent) {
+// getLog().info("config - basedir : " + out.getAbsolutePath());
+// getLog().info("config - locales : " + Arrays.toString(locales));
+// }
+//
+// try {
+// File bundleGetters = new File(out.getAbsolutePath() + File.separatorChar + artifactId + ".properties");
+// boolean b = bundleGetters.createNewFile();
+// if (!b) {
+// throw new IOException("could not create file " + bundleGetters);
+// }
+// DirectoryScanner ds = new DirectoryScanner();
+// ds.setBasedir(out);
+// ds.setIncludes(new String[]{"*.getter"});
+// ds.scan();
+// String[] files = ds.getIncludedFiles();
+//
+// // Fusion des fichiers propriétés des différents parsers
+// for (String file : files) {
+// long t0 = System.nanoTime();
+// File bundleGetter = getGetterFile(out, file, false);
+// concactProperties(bundleGetter, bundleGetters);
+// if (genSrc) {
+// PluginHelper.deleteFile(bundleGetter);
+// }
+// if (!silent) {
+// getLog().info("import getter " + bundleGetter.getName() + " in " + PluginHelper.convertTime(System.nanoTime() - t0));
+// }
+// }
+//
+// // Création des bundles
+// for (Locale locale : locales) {
+// if (getLog().isDebugEnabled()) {
+// getLog().debug("generate bundle for locale " + locale);
+// }
+// File bundleOut = getI18nFile(out, artifactId, locale, false);
+// copyFile(bundleGetters, bundleOut);
+// if (!silent && verbose) {
+// getLog().info("generate bundle " + locale);
+// }
+// }
+// PluginHelper.deleteFile(bundleGetters);
+// } catch (IOException e) {
+// getLog().error("File Error I/O ", e);
+// throw new MojoFailureException("File Error I/O");
+// }
+// }
+
/**
* Concatene deux fichiers de proprietes
*
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 2009-12-28 10:27:28 UTC (rev 1690)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/AbstractI18nParserMojo.java 2009-12-29 17:35:17 UTC (rev 1691)
@@ -19,14 +19,11 @@
* ##%* */
package org.nuiton.i18n.plugin.parser;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
import org.nuiton.i18n.plugin.AbstractI18nMojo;
import org.nuiton.i18n.plugin.I18nLogger;
import org.nuiton.i18n.plugin.SourceEntry;
import org.nuiton.io.FileUpdater;
import org.nuiton.io.SortedProperties;
-import org.nuiton.plugin.PluginHelper;
import java.io.File;
import java.io.IOException;
@@ -110,6 +107,15 @@
*/
protected boolean safeMode;
/**
+ * flag to save previous getter in a backup before doing parsing.
+ * <p/>
+ * Note: by default, do not perform backup (but it was here originaly so let it possible...)
+ *
+ * @parameter expression="${i18n.backupGetter}" default-value="false"
+ * @since 1.0.2
+ */
+ protected boolean backupGetter;
+ /**
* Liste des évènements
*/
protected List<ParserEvent> events = new ArrayList<ParserEvent>();
@@ -132,12 +138,19 @@
result = new SortedProperties(encoding);
oldParser = new SortedProperties(encoding);
oldLanguage = new SortedProperties(encoding);
- PluginHelper.createDirectoryIfNecessary(out);
+ createDirectoryIfNecessary(out);
// out.mkdirs();
// evenements
if (keysModifier) {
addParserEvent(KeysModifier.getInstance(getKeyModifierStart(), getKeyModifierEnd(), encoding));
}
+
+ // check there is something to treate
+ if (entries == null || entries.length == 0 && !treateDefaultEntry) {
+ // nothing to do
+ throw new IllegalStateException("No entry defined and treateDefaultEntry is false, will skip the goal.");
+ }
+
treadedFiles = new ArrayList<File>();
if (!silent && verbose) {
showTouchedFiles = true;
@@ -145,19 +158,7 @@
}
@Override
- public void execute() throws MojoExecutionException, MojoFailureException {
-
- try {
- init();
- } catch (Exception e) {
- throw new MojoExecutionException("could not init goal for reason " + e.getMessage(), e);
- }
-
- if (entries == null || entries.length == 0 && !treateDefaultEntry) {
- // nothing to do
- return;
- }
-
+ protected void doAction() throws Exception {
if (!silent && safeMode) {
getLog().info("config - safeMode is on (could be slower).");
}
@@ -165,48 +166,108 @@
getLog().info("config - strictMode is on (all files will be parsed).");
}
- try {
- // Reprise sur un ancien parsing
- File oldParserFile = getGetterFile(out, getOutGetter(), true);
- File saveFile = getGetterFileBackup(out, getOutGetter());
+ // Reprise sur un ancien parsing
+ File oldParserFile = getGetterFile(out, getOutGetter(), true);
+ File saveFile = getBackupFile(oldParserFile);
+// File saveFile = getGetterFileBackup(out, getOutGetter());
- oldParser.load(oldParserFile);
- copyFile(oldParserFile, saveFile);
+ oldParser.load(oldParserFile);
+ if (backupGetter) {
+ backupFile(oldParserFile);
+// copyFile(oldParserFile, saveFile);
+ }
- // Anciennes cles disponnibles
- //fixme : pourquoi on utilise un bundle precis ? le premier ici, je ne comprends pas
- File oldLanguageFile = getI18nFile(src, artifactId, locales[0], true);
+ // Anciennes cles disponnibles
+ //fixme : pourquoi on utilise un bundle precis ? le premier ici, je ne comprends pas
+ File oldLanguageFile = getI18nFile(src, artifactId, locales[0], true);
- oldLanguage.load(oldLanguageFile);
+ oldLanguage.load(oldLanguageFile);
- // Parsing
- parse();
+ // Parsing
+ parse();
- // Suppression du fichier sauvegarder
- boolean b = saveFile.delete();
- if (!b) {
- throw new IOException("could not delete file " + saveFile);
- }
+ // Suppression du fichier sauvegarder
+ if (!backupGetter) {
+ deleteFile(saveFile);
+ }
- int i = treadedFiles.size();
- if (fileTreated == 0) {
- if (!silent) {
- getLog().info("Nothing to generate - all files are up to date.");
- }
- } else {
- if (!silent) {
- getLog().info(getVerboseLog().getLogEntry("parsing is done. [treated file(s) : " + i + '/' + fileTreated + "]", fileTreated, 0, t0));
- }
- addGetter();
+ int i = treadedFiles.size();
+
+ if (fileTreated == 0) {
+ if (!silent) {
+ getLog().info("Nothing was parsed - all files are up to date.");
}
-
- } catch (Exception e) {
- getLog().error("Error code parsing ", e);
- throw new MojoFailureException("Error code parsing");
+ } else {
+ if (!silent) {
+ getLog().info(getVerboseLog().getLogEntry("Parsing is done. [treated file(s) : " + i + '/' + fileTreated + "]", fileTreated, 0, t0));
+ }
+ addGetter();
}
-
}
+// @Override
+// public void execute() throws MojoExecutionException, MojoFailureException {
+//
+// try {
+// init();
+// } catch (Exception e) {
+// throw new MojoExecutionException("could not init goal for reason " + e.getMessage(), e);
+// }
+//
+// if (entries == null || entries.length == 0 && !treateDefaultEntry) {
+// // nothing to do
+// return;
+// }
+//
+// if (!silent && safeMode) {
+// getLog().info("config - safeMode is on (could be slower).");
+// }
+// if (!silent && strictMode) {
+// getLog().info("config - strictMode is on (all files will be parsed).");
+// }
+//
+// try {
+// // Reprise sur un ancien parsing
+// File oldParserFile = getGetterFile(out, getOutGetter(), true);
+// File saveFile = getGetterFileBackup(out, getOutGetter());
+//
+// oldParser.load(oldParserFile);
+// copyFile(oldParserFile, saveFile);
+//
+// // Anciennes cles disponnibles
+// //fixme : pourquoi on utilise un bundle precis ? le premier ici, je ne comprends pas
+// File oldLanguageFile = getI18nFile(src, artifactId, locales[0], true);
+//
+// oldLanguage.load(oldLanguageFile);
+//
+// // Parsing
+// parse();
+//
+// // Suppression du fichier sauvegarder
+// boolean b = saveFile.delete();
+// if (!b) {
+// throw new IOException("could not delete file " + saveFile);
+// }
+//
+// int i = treadedFiles.size();
+// if (fileTreated == 0) {
+// if (!silent) {
+// getLog().info("Nothing to generate - all files are up to date.");
+// }
+// } else {
+// if (!silent) {
+// getLog().info(getVerboseLog().getLogEntry("parsing is done. [treated file(s) : " + i + '/' + fileTreated + "]", fileTreated, 0, t0));
+// }
+// addGetter();
+// }
+//
+// } catch (Exception e) {
+// getLog().error("Error code parsing ", e);
+// throw new MojoFailureException("Error code parsing");
+// }
+//
+// }
+
@Override
public void parse() throws IOException {
if (treateDefaultEntry) {
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 2009-12-28 10:27:28 UTC (rev 1690)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJavaMojo.java 2009-12-29 17:35:17 UTC (rev 1691)
@@ -20,7 +20,6 @@
package org.nuiton.i18n.plugin.parser.impl;
-import org.apache.maven.project.MavenProject;
import org.nuiton.i18n.plugin.SourceEntry;
import org.nuiton.i18n.plugin.parser.AbstractI18nParserMojo;
import org.nuiton.i18n.plugin.parser.ParserEvent;
@@ -58,14 +57,6 @@
protected File defaultBasedir;
/**
- * Dependance du projet.
- *
- * @parameter default-value="${project}"
- * @readonly
- */
- protected MavenProject project;
-
- /**
* Repertoire sources des fichiers i18n.
*
* @parameter expression="${i18n.cp}" default-value="${basedir}/target/classes"
@@ -118,7 +109,7 @@
@Override
public void parseFile(File srcFile) {
- LineNumberReader lnr = null;
+ LineNumberReader lnr;
String line = null;
try {
lnr = new LineNumberReader(new InputStreamReader(new FileInputStream(srcFile)));
Deleted: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJaxxMojo.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJaxxMojo.java 2009-12-28 10:27:28 UTC (rev 1690)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJaxxMojo.java 2009-12-29 17:35:17 UTC (rev 1691)
@@ -1,111 +0,0 @@
-/*
- * *##%
- * I18n :: Maven Plugin
- * Copyright (C) 2007 - 2009 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * ##%* */
-
-package org.nuiton.i18n.plugin.parser.impl;
-
-import org.nuiton.i18n.plugin.SourceEntry;
-import org.nuiton.io.FileUpdater;
-import org.nuiton.io.FileUpdaterHelper;
-
-import java.io.File;
-
-/**
- * Récupération des chaine à traduire depuis les fichiers xml Jaxx.
- *
- * @author julien
- * @goal parserJaxx
- * @phase generate-resources
- * @deprecated since 1.0.0, prefer use the java parser since xml parser can not
- * be easly extendable
- */
-@Deprecated
-public class ParserJaxxMojo extends ParserXmlMojo {
-
- /**
- * Source entries (src+includes+excludes) .
- *
- * @parameter expression="${i18n.defaultIncludes}" default-value="**\/*.jaxx"
- */
- protected String defaultIncludes;
-
- /**
- * Where jaxx files should have been generated.
- *
- * @parameter expression="${i18n.defaultGenerateBasedir}" default-value="${basedir}/target/generated-sources/java"
- */
- protected File defaultGenerateBasedir;
-
- /**
- * Regles xml.
- *
- * @parameter expression="${i18n.rulesJaxx}" default-value="jaxx.rules"
- */
- protected String rulesJaxx;
-
- @Override
- public String[] getDefaultIncludes() {
- return new String[]{defaultIncludes};
- }
-
- @Override
- public String[] getDefaultExcludes() {
- return new String[]{};
- }
-
- @Override
- public FileUpdater newFileUpdater(SourceEntry entry) {
- return FileUpdaterHelper.newJavaFileUpdater(entry.getBasedir(), defaultGenerateBasedir);
- }
-
- @Override
- protected String getOutGetter() {
- return "jaxx.getter";
- }
-
- @Override
- protected String getKeyModifierStart() {
- return "=\\s*[\"\']";
- }
-
- @Override
- protected String getKeyModifierEnd() {
- return "[\"\']";
- }
-
- @Override
- protected String getFileRules() {
- return rulesJaxx;
- }
-
- @Override
- protected String getCoreFileRules() {
- return "jaxx.rules";
- }
-
- public void setRulesJaxx(String rulesJaxx) {
- this.rulesJaxx = rulesJaxx;
- }
-
- @Override
- public String extract(String i18nString) {
- return i18nString.length() == 0 ? null : i18nString;
- }
-
-}
Deleted: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserSwixatMojo.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserSwixatMojo.java 2009-12-28 10:27:28 UTC (rev 1690)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserSwixatMojo.java 2009-12-29 17:35:17 UTC (rev 1691)
@@ -1,102 +0,0 @@
-/*
- * *##%
- * I18n :: Maven Plugin
- * Copyright (C) 2007 - 2009 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * ##%* */
-
-package org.nuiton.i18n.plugin.parser.impl;
-
-import org.nuiton.i18n.plugin.SourceEntry;
-import org.nuiton.io.FileUpdater;
-
-/**
- * Recuperation des chaines à traduire depuis les fichiers xml Swixat.
- *
- * @author julien
- * @goal parserSwixat
- * @phase generate-resources
- * @deprecated since 1.0.0 : swixat is dead...
- */
-@Deprecated
-public class ParserSwixatMojo extends ParserXmlMojo {
-
- /**
- * Source entries (src+includes) .
- *
- * @parameter expression="${i18n.defaultIncludes}" default-value="**\/*.xml"
- */
- protected String defaultIncludes;
-
- /**
- * Source entries (src+excludes) .
- *
- * @parameter expression="${i18n.defaultIncludes}" default-value="**\/context.xml"
- */
- protected String defaultExcludes;
-
- /**
- * Regles xml.
- *
- * @parameter expression="${i18n.rulesSwixat}" default-value="swixat.rules"
- */
- protected String rulesSwixat;
-
- @Override
- public String[] getDefaultIncludes() {
- return new String[]{defaultIncludes};
- }
-
- @Override
- public String[] getDefaultExcludes() {
- return new String[]{defaultExcludes};
- }
-
- @Override
- public FileUpdater newFileUpdater(SourceEntry entry) {
- return null;
- }
-
- @Override
- protected String getKeyModifierStart() {
- return "=\\s*[\"\']";
- }
-
- @Override
- protected String getKeyModifierEnd() {
- return "[\"\']";
- }
-
- @Override
- protected String getOutGetter() {
- return "swixat.getter";
- }
-
- @Override
- protected String getFileRules() {
- return rulesSwixat;
- }
-
- @Override
- protected String getCoreFileRules() {
- return "swixat.rules";
- }
-
- @Override
- public String extract(String i18nString) {
- return i18nString;
- }
-}
1
0
r1690 - in trunk/maven-i18n-plugin: . src/main/java/org/nuiton/i18n/plugin src/main/java/org/nuiton/i18n/plugin/parser src/main/java/org/nuiton/i18n/plugin/parser/impl src/site src/site/apt
by tchemit@users.nuiton.org 28 Dec '09
by tchemit@users.nuiton.org 28 Dec '09
28 Dec '09
Author: tchemit
Date: 2009-12-28 11:27:28 +0100 (Mon, 28 Dec 2009)
New Revision: 1690
Added:
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nBundleMojo.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nMojo.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/BundleMojo.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/CollectI18nArtifactsMojo.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/GetterMojo.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/KeysModifier.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJavaActionConfigMojo.java
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/ParserJavaTabConfigMojo.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJaxxMojo.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserSwixatMojo.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserValidationMojo.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserXmlMojo.java
Removed:
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nPlugin.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/Bundle.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/Generate.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/Getter.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/AbstractI18nParser.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/event/
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/ParserJavaActionConfig.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJavaTabConfig.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
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserXml.java
Modified:
trunk/maven-i18n-plugin/pom.xml
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/I18nArtifact.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/I18nLogger.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/SourceEntry.java
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/Parser.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/ParserEvent.java
trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/ParserException.java
trunk/maven-i18n-plugin/src/site/apt/index.apt
trunk/maven-i18n-plugin/src/site/site_fr.xml
Log:
- introduce collect-i18n-artifacts mojo to obtain all i18n resources throught project dependencies
- refactor mojo (using new maven-helper-plugin io api)
- normalized mojo names (always ends by Mojo)
Modified: trunk/maven-i18n-plugin/pom.xml
===================================================================
--- trunk/maven-i18n-plugin/pom.xml 2009-12-28 10:26:01 UTC (rev 1689)
+++ trunk/maven-i18n-plugin/pom.xml 2009-12-28 10:27:28 UTC (rev 1690)
@@ -85,7 +85,7 @@
<!-- ************************************************************* -->
<name>I18n :: Maven Plugin</name>
<description>
- Plugin pour maven 2 de génération des bundles pour l'internationnalisation (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>
Added: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nBundleMojo.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nBundleMojo.java (rev 0)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nBundleMojo.java 2009-12-28 10:27:28 UTC (rev 1690)
@@ -0,0 +1,91 @@
+/*
+ * *##%
+ * I18n :: Maven Plugin
+ * Copyright (C) 2007 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%*
+ */
+package org.nuiton.i18n.plugin;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+import java.util.Locale;
+
+/**
+ * Created: 26 déc. 2009
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com> Copyright Code Lutin
+ * @version $Revision$
+ * <p/>
+ * Mise a jour: $Date$ par :
+ * $Author: tchemit $
+ */
+public abstract class AbstractI18nBundleMojo extends AbstractI18nMojo {
+
+ /**
+ * Repertoire ou generer les bundles.
+ *
+ * @parameter expression="${i18n.collectOutputDir}" default-value="${basedir}/target/i18n"
+ * @required
+ * @since 1.0.2
+ */
+ protected File collectOutputDir;
+ /**
+ * Nom de base des fichiers qui contient les localisations des bundles.
+ *
+ * @parameter expression="${i18n.collectOutputName}" default-value="collect-${project.artifactId}-i18n"
+ * @required
+ * @since 1.0.2
+ */
+ protected String collectOutputName;
+
+ /**
+ * Pour obtenir les urls des fichiers i18n d'un projet (avec recherche
+ * dans ses dépendances).
+ * <p/>
+ * <b>Note:</b> L'ordre des urls reflète l'ordre des dépendances.
+ *
+ * @param locale la locale a traiter
+ * @return les urls des bundles i18n detectees pour le projet.
+ * @throws Exception pour tout problème
+ */
+ protected abstract URL[] getCollectI18nResources(Locale locale) throws Exception;
+
+ /**
+ * Pour obtenir le fichier contenant les localisation des bundles i18n du projet
+ * pour une {@code locale} donnée.
+ *
+ * @param locale la locale
+ * @param create un drapeau pour forcer la création du fichier s'il n'existe pas
+ * @return le fichier qui contient les urls des bundles i18n pour la locale donnée.
+ * @throws IOException pour tout pb
+ */
+ protected File getCollectOutputFile(Locale locale, boolean create) throws IOException {
+ File bundleOut = getI18nFile(collectOutputDir, collectOutputName, locale, create);
+ return bundleOut;
+ }
+
+ @Override
+ public void init() throws Exception {
+ super.init();
+
+ if (locales == null || locales.length == 0) {
+ throw new IllegalStateException("il faut au moins une locale declaree (utiliser la propriete 'bundles')");
+ }
+ }
+
+}
Property changes on: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nBundleMojo.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Copied: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nMojo.java (from rev 1687, trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nPlugin.java)
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nMojo.java (rev 0)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nMojo.java 2009-12-28 10:27:28 UTC (rev 1690)
@@ -0,0 +1,255 @@
+/*
+ * *##%
+ * I18n :: Maven Plugin
+ * Copyright (C) 2007 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%* */
+package org.nuiton.i18n.plugin;
+
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.project.MavenProject;
+import org.nuiton.i18n.I18nUtil;
+import org.nuiton.plugin.PluginHelper;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Locale;
+import java.util.Properties;
+import java.util.SortedSet;
+
+/**
+ * Classe permettant d'obenir les parametres pendant les différentes phases
+ * du plugin.
+ *
+ * @author julien
+ */
+public abstract class AbstractI18nMojo extends AbstractMojo {
+
+ /**
+ * Le nombre de getters détectés pendant le cycle de vie du build.
+ */
+ private static int NB_GETTER_FILES = 0;
+ /**
+ * Dependance du projet.
+ *
+ * @parameter default-value="${project}"
+ * @required
+ * @since 1.0.2
+ */
+ protected MavenProject project;
+ /**
+ * Nom du projet.
+ *
+ * @parameter expression="${i18n.artifactId}" default-value="${project.artifactId}"
+ * @readonly
+ */
+ protected String artifactId;
+ /**
+ * Langues des bundles generes.
+ * <p/>
+ *
+ * @parameter expression="${i18n.bundles}" default-value="fr_FR,en_GB"
+ * @required
+ */
+ protected String bundles;
+ /**
+ * Repertoire sources des fichiers i18n.
+ *
+ * @parameter expression="${i18n.src}" default-value="${basedir}/src/main/resources/i18n"
+ * @required
+ */
+ protected File src;
+ /**
+ * Repertoire des fichiers generes i18n.
+ *
+ * @parameter expression="${i18n.out}" default-value="${basedir}/target/generated-sources/i18n"
+ * @required
+ */
+ protected File out;
+ /**
+ * encoding a utiliser pour charger et sauver les bundles
+ *
+ * @parameter expression="${i18n.encoding}" default-value="${project.build.sourceEncoding}"
+ * @required
+ */
+ protected String encoding;
+ /**
+ * Met les fichiers generes dans le repertoire des sources i18n.
+ * <p/>
+ * Note: Par défaut active, pour pouvoir paquager avec les bundles mis a jour.
+ *
+ * @parameter expression="${i18n.genSrc}" default-value="true"
+ */
+ protected boolean genSrc;
+ /**
+ * verbose flag
+ * <p/>
+ * Note: si non renseigne, on utilise la propiété <code>maven.verbose</code>.
+ *
+ * @parameter expression="${i18n.verbose}" default-value="${maven.verbose}"
+ */
+ protected boolean verbose;
+ /**
+ * silent flag
+ *
+ * @parameter expression="${i18n.silent}" default-value="false"
+ * @since 1.0.0-rc-5
+ */
+ protected boolean silent;
+ /**
+ * ne conserve que les clef scannees (et donc traite tous les fichiers)
+ * <p/>
+ * <p/>
+ * Note : par default, on ne l'active car rescanne tous les fichiers.
+ * s
+ *
+ * @parameter expression="${i18n.strictMode}" default-value="false"
+ */
+ protected boolean strictMode;
+
+ protected Locale[] locales;
+ /**
+ * logger verbeux
+ */
+ protected I18nLogger verboseLog;
+
+
+ public void init() throws Exception {
+
+ verboseLog = new I18nLogger(this);
+
+ if (verbose) {
+ getLog().info("config - verbose mode is on");
+ }
+ locales = I18nUtil.parseLocales(bundles);
+ }
+
+ public String getArtifactId() {
+ return artifactId;
+ }
+
+ /**
+ * @return <code>true</code> si des getters ont etes enregistres pendant
+ * le cycle de vie, <code>false</code> sinon.
+ */
+ protected boolean needGeneration() {
+ boolean needGeneration = NB_GETTER_FILES > 0;
+ return needGeneration;
+ }
+
+ /**
+ * Prend en compte qu'un getter a été détecté.
+ * <p/>
+ * Cela veut dire qu'un goal de parser a détecté des clefs. Il
+ * faudra donc activer les goal get et gen.
+ */
+ protected void addGetter() {
+ NB_GETTER_FILES++;
+ }
+
+ protected I18nLogger getVerboseLog() {
+ return verboseLog;
+ }
+
+ /**
+ * @param root le repertoire ou sont stockes les fichiers i18n
+ * @param artifactId le nom de l'artifact
+ * @param locale le nom du bundle
+ * @param create <code>true</code> pour creer le fichier si non present
+ * @return le fichier i18n
+ * @throws java.io.IOException si probleme lors de la creation du fichier
+ */
+ public File getI18nFile(File root, String artifactId, Locale locale, boolean create) throws IOException {
+ File file = new File(root.getAbsolutePath() + File.separatorChar + artifactId + "-" + locale.toString() + ".properties");
+ if (create && !file.exists()) {
+ PluginHelper.createDirectoryIfNecessary(file.getParentFile());
+ PluginHelper.createNewFile(file);
+ }
+ return file;
+ }
+
+ /**
+ * @param root le repertoire ou sont stockes les fichiers getter
+ * @param getter le nom du getter
+ * @param create <code>true</code> pour creer le fichier si non present
+ * @return le fichier i18n
+ * @throws java.io.IOException si probleme lors de la creation du fichier
+ */
+ public File getGetterFile(File root, String getter, boolean create) throws IOException {
+ File file = new File(root.getAbsolutePath() + File.separatorChar + getter);
+ if (create && !file.exists()) {
+ PluginHelper.createDirectoryIfNecessary(file.getParentFile());
+ PluginHelper.createNewFile(file);
+ }
+ return file;
+ }
+
+ /**
+ * @param root le repertoire ou sont stockes les fichiers getter
+ * @param getter le nom du getter
+ * @return le fichier i18n
+ */
+ public File getGetterFileBackup(File root, String getter) {
+ return new File(root.getAbsolutePath() + File.separatorChar + getter + '~');
+ }
+
+ /**
+ * @param root le reertoire ou sont stockes les fichiers i18n
+ * @param artifactId le nom de l'artifact
+ * @param bundle le nom du bundle
+ * @return le fichier i18n de backup
+ */
+ public File getI18nFileBackup(File root, String artifactId, Locale bundle) {
+ return new File(root.getAbsolutePath() + File.separatorChar + artifactId + "-" + bundle.toString() + ".properties~");
+ }
+
+ protected void checkBundle(Locale locale, Properties propertiesOut, boolean showEmpty) {
+ // on verifie qu'il n'y a pas de traduction vide
+ SortedSet<String> emptyEntries = PluginHelper.getEmptyKeys(propertiesOut);
+ if (!emptyEntries.isEmpty()) {
+ StringBuilder buffer = new StringBuilder();
+ int size = emptyEntries.size();
+ buffer.append("bundle ");
+ buffer.append(locale);
+ buffer.append(" contains ");
+ buffer.append(size);
+ buffer.append("/");
+ buffer.append(propertiesOut.size());
+ buffer.append(" empty entries!");
+ if (showEmpty) {
+ int index = 0;
+ for (String key : emptyEntries) {
+ buffer.append("\n - ").append(index++).append("/").append(size).append(" : ").append(key);
+ }
+ } else {
+ buffer.append(" (use -Di18n.showEmpty to see these entries)");
+ }
+ getLog().warn(buffer.toString());
+ } else {
+ if (!silent && verbose) {
+ getLog().info("bundle " + locale + " is valid (no empty entries).");
+ }
+ }
+ }
+
+ protected void backupFile(File f) throws IOException {
+ PluginHelper.copy(f, new File(f.getAbsolutePath() + "~"));
+ }
+
+ protected void copyFile(File src, File dst) throws IOException {
+ PluginHelper.copy(src, dst);
+ }
+}
Property changes on: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nMojo.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:mergeinfo
+
Added: svn:eol-style
+ native
Deleted: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nPlugin.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nPlugin.java 2009-12-28 10:26:01 UTC (rev 1689)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nPlugin.java 2009-12-28 10:27:28 UTC (rev 1690)
@@ -1,282 +0,0 @@
-/*
- * *##% Plugin maven pour i18n
- * Copyright (C) 2007 - 2009 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%* */
-package org.nuiton.i18n.plugin;
-
-import org.apache.maven.plugin.AbstractMojo;
-import org.nuiton.i18n.plugin.parser.ParserEvent;
-import org.nuiton.i18n.I18nUtil;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Locale;
-import java.util.Properties;
-import java.util.SortedSet;
-import org.nuiton.plugin.PluginHelper;
-
-/**
- * Classe permettant d'obenir les parametres pendant les différentes phases
- * du plugin.
- *
- * @author julien
- */
-public abstract class AbstractI18nPlugin extends AbstractMojo {
-
- /**
- * Le nombre de getters détectés pendant le cycle de vie du build.
- */
- private static int NB_GETTER_FILES = 0;
- /**
- * Répertoire de stockage des fichiers i18n pour la recuperation des fichiers
- * de traduction entre librairie
- */
- protected static final String DIRECTORY_INSTALL = "i18n" + File.separatorChar;
- /**
- * Nom du projet.
- *
- * @parameter expression="${i18n.artifactId}" default-value="${project.artifactId}"
- * @readonly
- */
- protected String artifactId;
- /**
- * Langues des bundles generes.
- * <p/>
- *
- * @parameter expression="${i18n.bundles}" default-value="fr_FR,en_GB"
- * @required
- */
- protected String bundles;
- /**
- * Repertoire sources des fichiers i18n.
- *
- * @parameter expression="${i18n.src}" default-value="${basedir}/src/main/resources/i18n"
- * @required
- */
- protected File src;
- /**
- * Repertoire des fichiers generes i18n.
- *
- * @parameter expression="${i18n.out}" default-value="${basedir}/target/generated-sources/i18n"
- * @required
- */
- protected File out;
- /**
- * encoding a utiliser pour charger et sauver les bundles
- *
- * @parameter expression="${i18n.encoding}" default-value="${project.build.sourceEncoding}"
- * @required
- */
- protected String encoding;
- /**
- * Met les fichiers generes dans le repertoire des sources i18n.
- * <p/>
- * Note: Par défaut active, pour pouvoir paquager avec les bundles mis a jour.
- *
- * @parameter expression="${i18n.genSrc}" default-value="true"
- */
- protected boolean genSrc;
- /**
- * Active la modification de cle.
- * <p/>
- * Note: par defaut, on ne l'active pas (build sur serveur non ui).
- *
- * @parameter expression="${i18n.keysModifier}" default-value="false"
- */
- protected boolean keysModifier;
- /**
- * verbose flag
- * <p/>
- * Note: si non renseigne, on utilise la propiété <code>maven.verbose</code>.
- *
- * @parameter expression="${i18n.verbose}" default-value="${maven.verbose}"
- */
- protected boolean verbose;
- /**
- * silent flag
- *
- * @parameter expression="${i18n.silent}" default-value="false"
- * @since 1.0.0-rc-5
- */
- protected boolean silent;
- /**
- * conserve les anciens fichiers de traduction avec un suffix ~
- * <p/>
- * Note: par defaut, on ne l'active pas.
- *
- * @parameter expression="${i18n.keepBackup}" default-value="false"
- */
- protected boolean keepBackup;
- /**
- * ne conserve que les clef scannees (et donc traite tous les fichiers)
- *
- * <p/>
- * Note : par default, on ne l'active car rescanne tous les fichiers.
- *s
- * @parameter expression="${i18n.strictMode}" default-value="false"
- */
- protected boolean strictMode;
- /** Liste des évènements */
- protected List<ParserEvent> events = new ArrayList<ParserEvent>();
- protected Locale[] locales;
- /**logger verbeux */
- protected I18nLogger verboseLog;
-
- /**
- * Ajoute un évènement
- *
- * @param parserEvent l'évènement d'ajout
- */
- protected void addParserEvent(ParserEvent parserEvent) {
- this.events.add(parserEvent);
- }
-
- /**
- * Supprime un évènement
- *
- * @param parserEvent l'évènement de suppression
- */
- protected void removeParserEvent(ParserEvent parserEvent) {
- this.events.remove(parserEvent);
- }
-
- public void init() {
-
- verboseLog = new I18nLogger(this);
-
- if (verbose) {
- getLog().info("config - verbose mode is on");
- }
- locales = I18nUtil.parseLocales(bundles);
- }
-
- public String getArtifactId() {
- return artifactId;
- }
-
- /**
- *
- * @return <code>true</code> si des getters ont etes enregistres pendant
- * le cycle de vie, <code>false</code> sinon.
- */
- protected boolean needGeneration() {
- boolean needGeneration = NB_GETTER_FILES > 0;
- return needGeneration;
- }
-
- /**
- * Prend en compte qu'un getter a été détecté.
- *
- * Cela veut dire qu'un goal de parser a détecté des clefs. Il
- * faudra donc activer les goal get et gen.
- */
- protected void addGetter() {
- NB_GETTER_FILES++;
- }
-
- protected I18nLogger getVerboseLog() {
- return verboseLog;
- }
-
- /**
- * @param root le repertoire ou sont stockes les fichiers i18n
- * @param artifactId le nom de l'artifact
- * @param locale le nom du bundle
- * @param create <code>true</code> pour creer le fichier si non present
- * @return le fichier i18n
- * @throws java.io.IOException si probleme lors de la creation du fichier
- */
- public File getI18nFile(File root, String artifactId, Locale locale, boolean create) throws IOException {
- File file = new File(root.getAbsolutePath() + File.separatorChar + artifactId + "-" + locale.toString() + ".properties");
- if (create && !file.exists()) {
- if (!file.exists()) {
- file.getParentFile().mkdirs();
- }
- file.createNewFile();
- }
- return file;
- }
-
- /**
- * @param root le repertoire ou sont stockes les fichiers getter
- * @param getter le nom du getter
- * @param create <code>true</code> pour creer le fichier si non present
- * @return le fichier i18n
- * @throws java.io.IOException si probleme lors de la creation du fichier
- */
- public File getGetterFile(File root, String getter, boolean create) throws IOException {
- File file = new File(root.getAbsolutePath() + File.separatorChar + getter);
- if (create && !file.exists()) {
- if (!file.exists()) {
- file.getParentFile().mkdirs();
- }
- file.createNewFile();
- }
- return file;
- }
-
- /**
- * @param root le repertoire ou sont stockes les fichiers getter
- * @param getter le nom du getter
- * @return le fichier i18n
- */
- public File getGetterFileBackup(File root, String getter) {
- return new File(root.getAbsolutePath() + File.separatorChar + getter + '~');
- }
-
- /**
- * @param root le reertoire ou sont stockes les fichiers i18n
- * @param artifactId le nom de l'artifact
- * @param bundle le nom du bundle
- * @return le fichier i18n de backup
- */
- public File getI18nFileBackup(File root, String artifactId, Locale bundle) {
- return new File(root.getAbsolutePath() + File.separatorChar + artifactId + "-" + bundle.toString() + ".properties~");
- }
-
- protected void checkBundle(Locale locale, Properties propertiesOut, boolean showEmpty) {
- // on verifie qu'il n'y a pas de traduction vide
- SortedSet<String> emptyEntries = PluginHelper.getEmptyKeys(propertiesOut);
- if (!emptyEntries.isEmpty()) {
- StringBuilder buffer = new StringBuilder();
- int size = emptyEntries.size();
- buffer.append("bundle " + locale + " contains " + size + "/" + propertiesOut.size() + " empty entries!");
- if (showEmpty) {
- int index = 0;
- for (String key : emptyEntries) {
- buffer.append("\n - " + (index++) + "/" + size + " : " + key);
- }
- } else {
- buffer.append(" (use -Di18n.showEmpty to see these entries)");
- }
- getLog().warn(buffer.toString());
- } else {
- if (!silent && verbose) {
- getLog().info("bundle " + locale + " is valid (no empty entries).");
- }
- }
- }
-
- protected void backupFile(File f) throws IOException {
- PluginHelper.copy(f, new File(f.getAbsolutePath() + "~"));
- }
-
- protected void copyFile(File src, File dst) throws IOException {
- PluginHelper.copy(src, dst);
- }
-}
Deleted: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/Bundle.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/Bundle.java 2009-12-28 10:26:01 UTC (rev 1689)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/Bundle.java 2009-12-28 10:27:28 UTC (rev 1690)
@@ -1,361 +0,0 @@
-/*
- * *##% Plugin maven pour i18n
- * Copyright (C) 2007 - 2009 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%* */
-package org.nuiton.i18n.plugin;
-
-import java.net.MalformedURLException;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.net.URL;
-import java.util.Arrays;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Map.Entry;
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.factory.ArtifactFactory;
-import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
-import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.artifact.resolver.ArtifactCollector;
-import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
-import org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter;
-import org.apache.maven.project.MavenProject;
-import org.apache.maven.project.MavenProjectBuilder;
-import org.apache.maven.shared.dependency.tree.DependencyNode;
-import org.apache.maven.shared.dependency.tree.DependencyTreeBuilder;
-import org.apache.maven.shared.dependency.tree.DependencyTreeBuilderException;
-import org.nuiton.i18n.bundle.I18nBundleEntry;
-import org.nuiton.io.SortedProperties;
-import org.nuiton.i18n.bundle.I18nBundleFactory;
-import org.nuiton.plugin.DependencyUtil;
-import org.nuiton.plugin.PluginHelper;
-
-/**
- * Créer un bundle pour une application finale.
- *
- * Cela génère un merge de tous les fichiers i18n utilisés en un seul.
- *
- * On utilise la dépendance sur les artifacts pour connaitre l'ordre le chargement
- * des bundles.
- *
- * Si dans un bundle childs, la valeur de la clef est vide, on conserve alors celui
- * du parent,
- *
- * Ainsi on obtient un bundle dont toutes les clefs sont traduites.
- *
- * Le but aussi d'utiliser un unique bundle est de gagner du temps au runtime
- * car la recherche des bundles devient trop couteuse en temps lorsque l'on a de
- * nombreuses dépendances (au dessus de 100 deps cela peut prendre plusieurs
- * secondes, ce qui 'est pas acceptable).
- *
- * On a ajoute un second mode d'initialisation dans la clesse I18n pour n'utiliser
- * qu'un seul bundle et courcircuiter le chargement couteux...
- * *
- *
- * @author chemit
- * @goal bundle
- * @phase generate-resources
- * @execute goal=gen
- * @requiresProject true
- * @requiresDependencyResolution runtime
- *
- * @since 0.12
- */
-public class Bundle extends AbstractI18nPlugin {
-
- /**
- * Repertoire ou generer les bundles.
- *
- * @parameter expression="${i18n.bundleOutputDir}" default-value="${basedir}/target/generated-sources/resources/META-INF"
- * @required
- * @since 1.0.0
- */
- protected File bundleOutputDir;
- /**
- * Nom du bundle a generer.
- *
- * @parameter expression="${i18n.bundleOutputName}" default-value="${project.artifactId}-i18n"
- * @required
- * @since 1.0.0
- */
- protected String bundleOutputName;
- /**
- * Un drapeau pour vérifier que les bundles ne contiennent pas d'entrées vides.
- *
- * @parameter expression="${i18n.checkBundle}" default-value="true"
- * @required
- * @since 1.0.0
- */
- protected boolean checkBundle;
- /**
- * Un drapeau pour afficher les entrées vides. (nécessite {@link #checkBundle} activé).
- *
- * @parameter expression="${i18n.showEmpty}" default-value="false"
- * @required
- * @since 1.0.0
- */
- protected boolean showEmpty;
- /**
- * Dependance du projet.
- *
- * @parameter default-value="${project}"
- * @required
- * @since 1.0.0
- */
- protected MavenProject project;
- /**
- * Local Repository.
- *
- * @parameter expression="${localRepository}"
- * @required
- * @readonly
- * @since 1.0.0
- */
- protected ArtifactRepository localRepository;
- /**
- * Remote repositories used for the project.
- *
- * @parameter expression="${project.remoteArtifactRepositories}"
- * @required
- * @readonly
- * @since 1.0.0
- */
- protected List<?> remoteRepositories;
- /**
- * Dependency tree builder component.
- *
- * @component
- */
- protected DependencyTreeBuilder dependencyTreeBuilder;
- /**
- * Artifact Factory component.
- *
- * @component
- */
- protected ArtifactFactory factory;
- /**
- * Artifact metadata source component.
- *
- * @component
- */
- protected ArtifactMetadataSource artifactMetadataSource;
- /**
- * Artifact collector component.
- *
- * @component
- */
- protected ArtifactCollector collector;
- /**
- * Maven Project Builder component.
- *
- * @component
- */
- protected MavenProjectBuilder mavenProjectBuilder;
- protected I18nArtifact[] i18nArtifacts;
- protected ClassLoader loader;
- protected URL[] urls;
-
- @Override
- public void init() {
- super.init();
-
- if (locales == null || locales.length == 0) {
- throw new IllegalStateException("il faut au moins une locale declaree (utiliser la propriete 'bundles')");
- }
-
- if (!bundleOutputDir.exists()) {
- bundleOutputDir.mkdirs();
- }
-
- try {
- // calcul des artifacts qui ont un bundle i18n et trie selon les
- // dependances
-
- i18nArtifacts = detectI18nArtifacts();
-
- if (!silent) {
- getLog().info("detected " + i18nArtifacts.length + " i18n artifact(s) : ");
- for (I18nArtifact a : i18nArtifacts) {
- getLog().info(" - " + a);
- }
- }
- } catch (Exception ex) {
- throw new RuntimeException(ex);
- }
-
- // ajout de repertoire de generation (le parent en fait)
- // dans les resources du projet
-
- String newresourceDir = bundleOutputDir.getParentFile().getAbsolutePath();
-
- PluginHelper.addResourceDir(newresourceDir, project);
- }
-
- @Override
- public void execute() throws MojoExecutionException, MojoFailureException {
-
- if ("pom".equals(project.getPackaging()) || "site".equals(project.getPackaging())) {
- return;
- }
-
-
- long t00 = System.nanoTime();
-
- init();
-
- if (!silent) {
- getLog().info("config - bundle name : " + bundleOutputName);
- getLog().info("config - baseidr : " + bundleOutputDir);
- getLog().info("config - locales : " + Arrays.toString(locales));
- }
- // la locale par defaut est la première
- Locale defaultLocale = locales[0];
-
- Map<Locale, String> bundleDico = new LinkedHashMap<Locale, String>(locales.length);
-
- try {
-
- for (Locale locale : locales) {
-
- long t0 = System.nanoTime();
-
- 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();
- for (I18nArtifact artifact : i18nArtifacts) {
- I18nBundleEntry[] bundleEntries = artifact.getBundleEntries(locale, defaultLocale);
- for (I18nBundleEntry bundleEntry : bundleEntries) {
-
- bundleEntry.load(propertiesOut);
- String strPath = bundleEntry.getPath().toString();
- int index = strPath.indexOf("i18n/");
-
- buffer.append(',').append(strPath.substring(index));
- if (verbose) {
- getLog().info("loaded " + bundleEntry.getPath() + " in " + PluginHelper.convertTime(t0, System.nanoTime()));
- }
- }
- }
- if (buffer.length() > 0) {
- bundleDico.put(locale, buffer.substring(1));
- if (!silent) {
- getLog().info("bundles for locale : " + bundleDico.get(locale));
- }
- }
- propertiesOut.store(bundleOut);
- if (!silent && verbose) {
- getLog().info("bundle created in " + PluginHelper.convertTime(t0, System.nanoTime()) + " (detected sentences : " + propertiesOut.size() + ")");
- }
- if (checkBundle) {
- checkBundle(locale, propertiesOut, showEmpty);
- }
- }
-
- // ecriture du ficher des definitions i18n (permet de faire une
- // recherche extact sur un fichier puis d'en deduire les bundles a
- // charger
- String f = String.format(I18nBundleFactory.UNIQUE_BUNDLE_DEF, bundleOutputName);
- File defOut = new File(bundleOutputDir, f);
- if (!silent) {
- getLog().info("prepare i18n definition " + defOut.getAbsolutePath());
- }
- SortedProperties p = new SortedProperties(encoding, false);
- p.setProperty(I18nBundleFactory.BUNDLE_DEF_LOCALES, bundles);
- for (Entry<Locale, String> e : bundleDico.entrySet()) {
- p.setProperty(I18nBundleFactory.BUNDLES_FOR_LOCALE + e.getKey().toString(), e.getValue());
- }
- p.store(new FileOutputStream(defOut), null);
-
- if (!silent && verbose) {
- getLog().info("done in " + PluginHelper.convertTime(t00, System.nanoTime()));
- }
- } catch (IOException e) {
- getLog().error("File Error I/O ", e);
- throw new MojoFailureException("File Error I/O ");
- }
- }
-
- /**
- * Detecte les {@link I18nArtifact} et les retourne dans l'ordre de chargement
- * dans le système i18n, i.e l'ordre des dependances entre artifacts.
- *
- * @return les artifacts i18nables triés par leur ordre de chargement dans le système i18n.
- *
- * @throws MalformedURLException
- * @throws IOException
- * @throws DependencyTreeBuilderException
- */
- protected I18nArtifact[] detectI18nArtifacts() throws MalformedURLException, IOException, DependencyTreeBuilderException {
-
- Map<Artifact, I18nArtifact> dico = new java.util.HashMap<Artifact, I18nArtifact>();
-
- I18nArtifact i18nArtifact;
- for (Object o : project.getArtifacts()) {
- i18nArtifact = new I18nArtifact((Artifact) o);
- if (i18nArtifact.detectBundles()) {
- if (!silent && getLog().isDebugEnabled()) {
- getLog().debug("detected artifact " + i18nArtifact);
- }
- dico.put(i18nArtifact.getArtifact(), i18nArtifact);
- } else {
- if (!silent && getLog().isDebugEnabled()) {
- getLog().debug("reject artifact " + i18nArtifact);
- }
- }
- }
-
- ArtifactFilter artifactFilter = new ScopeArtifactFilter(Artifact.SCOPE_RUNTIME);
-
- DependencyNode rootNode = dependencyTreeBuilder.buildDependencyTree(project, localRepository, factory,
- artifactMetadataSource, artifactFilter, collector);
-
- List<Artifact> artifacts = new java.util.ArrayList<Artifact>(dico.keySet());
-
- DependencyUtil.sortArtifacts(rootNode, artifacts, getLog().isDebugEnabled());
-
- // l'artifact du projet est traite en dernier car s'il possède des
- // bundles alors ils doivent etre charge en dernier
-
- Artifact projectArtifact = project.getArtifact();
- i18nArtifact = new I18nArtifact(projectArtifact, src.getParentFile());
-
- if (i18nArtifact.detectBundles()) {
- if (!silent && verbose) {
- getLog().info("detected artifact " + i18nArtifact);
- }
- artifacts.add(i18nArtifact.getArtifact());
- dico.put(i18nArtifact.getArtifact(), i18nArtifact);
- }
-
- I18nArtifact[] result = new I18nArtifact[artifacts.size()];
- int i = 0;
- for (Artifact artifact : artifacts) {
- result[i++] = dico.get(artifact);
- }
- return result;
- }
-}
Copied: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/BundleMojo.java (from rev 1687, trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/Bundle.java)
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/BundleMojo.java (rev 0)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/BundleMojo.java 2009-12-28 10:27:28 UTC (rev 1690)
@@ -0,0 +1,234 @@
+/*
+ * *##%
+ * I18n :: Maven Plugin
+ * Copyright (C) 2007 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%* */
+package org.nuiton.i18n.plugin;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.project.MavenProject;
+import org.nuiton.i18n.bundle.I18nBundleEntry;
+import org.nuiton.i18n.bundle.I18nBundleFactory;
+import org.nuiton.io.SortedProperties;
+import org.nuiton.plugin.PluginHelper;
+
+import java.io.*;
+import java.net.URL;
+import java.util.*;
+import java.util.Map.Entry;
+
+/**
+ * Créer un bundle pour une application finale.
+ * <p/>
+ * Cela génère un merge de tous les fichiers i18n utilisés en un seul.
+ * <p/>
+ * On utilise la dépendance sur les artifacts pour connaitre l'ordre le chargement
+ * des bundles.
+ * <p/>
+ * Si dans un bundle childs, la valeur de la clef est vide, on conserve alors celui
+ * du parent,
+ * <p/>
+ * Ainsi on obtient un bundle dont toutes les clefs sont traduites.
+ * <p/>
+ * Le but aussi d'utiliser un unique bundle est de gagner du temps au runtime
+ * car la recherche des bundles devient trop couteuse en temps lorsque l'on a de
+ * nombreuses dépendances (au dessus de 100 deps cela peut prendre plusieurs
+ * secondes, ce qui 'est pas acceptable).
+ * <p/>
+ * On a ajoute un second mode d'initialisation dans la clesse I18n pour n'utiliser
+ * qu'un seul bundle et courcircuiter le chargement couteux...
+ * *
+ *
+ * @author chemit
+ * @goal bundle
+ * @phase generate-resources
+ * @execute goal=collect-i18n-artifacts
+ * @requiresProject true
+ * @requiresDependencyResolution runtime
+ * @since 0.12
+ */
+public class BundleMojo extends AbstractI18nBundleMojo {
+ /**
+ * Repertoire ou generer les bundles.
+ *
+ * @parameter expression="${i18n.bundleOutputDir}" default-value="${basedir}/target/generated-sources/resources/META-INF"
+ * @required
+ * @since 1.0.0
+ */
+ protected File bundleOutputDir;
+ /**
+ * Nom du bundle a generer.
+ *
+ * @parameter expression="${i18n.bundleOutputName}" default-value="${project.artifactId}-i18n"
+ * @required
+ * @since 1.0.2
+ */
+ protected String bundleOutputName;
+ /**
+ * Un drapeau pour vérifier que les bundles ne contiennent pas d'entrées vides.
+ *
+ * @parameter expression="${i18n.checkBundle}" default-value="true"
+ * @required
+ * @since 1.0.0
+ */
+ protected boolean checkBundle;
+ /**
+ * Un drapeau pour afficher les entrées vides. (nécessite {@link #checkBundle} activé).
+ *
+ * @parameter expression="${i18n.showEmpty}" default-value="false"
+ * @required
+ * @since 1.0.0
+ */
+ protected boolean showEmpty;
+ /**
+ * Dependance du projet.
+ *
+ * @parameter default-value="${project}"
+ * @required
+ * @since 1.0.0
+ */
+ protected MavenProject project;
+
+ @Override
+ public void init() throws Exception {
+ super.init();
+
+ PluginHelper.createDirectoryIfNecessary(bundleOutputDir);
+
+ // ajout de repertoire de generation (le parent en fait)
+ // dans les resources du projet
+
+ PluginHelper.addResourceDir(bundleOutputDir.getParentFile(), project, "**/*.properties");
+ }
+
+ @Override
+ public void execute() throws MojoExecutionException, MojoFailureException {
+
+ if ("pom".equals(project.getPackaging()) || "site".equals(project.getPackaging())) {
+ return;
+ }
+
+ long t00 = System.nanoTime();
+
+ try {
+ init();
+ } catch (Exception e) {
+ throw new MojoExecutionException("could not init gaol for reason " + e.getMessage(), e);
+ }
+
+ if (!silent) {
+ getLog().info("config - bundle name : " + bundleOutputName);
+ getLog().info("config - basedir : " + bundleOutputDir);
+ getLog().info("config - locales : " + Arrays.toString(locales));
+ }
+
+ Map<Locale, String> bundleDico = new LinkedHashMap<Locale, String>(locales.length);
+
+ try {
+
+ for (Locale locale : locales) {
+
+ long t0 = System.nanoTime();
+
+ 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();
+
+ URL[] urls = getCollectI18nResources(locale);
+ if (urls.length == 0) {
+ getLog().warn("no bundle for locale " + locale);
+ continue;
+ }
+
+ for (URL url : urls) {
+ long t000 = System.nanoTime();
+ I18nBundleEntry bundleEntry = new I18nBundleEntry(url, locale, null);
+ bundleEntry.load(propertiesOut);
+ String strPath = bundleEntry.getPath().toString();
+ int index = strPath.indexOf("i18n/");
+
+ buffer.append(',').append(strPath.substring(index));
+ if (verbose) {
+ getLog().info("loaded " + bundleEntry.getPath() + " in " + PluginHelper.convertTime(t000, System.nanoTime()));
+ }
+ }
+
+ if (buffer.length() > 0) {
+ bundleDico.put(locale, buffer.substring(1));
+ if (!silent) {
+ getLog().info("bundles for locale : " + bundleDico.get(locale));
+ }
+ }
+ propertiesOut.store(bundleOut);
+ if (!silent && verbose) {
+ getLog().info("bundle created in " + PluginHelper.convertTime(t0, System.nanoTime()) + " (detected sentences : " + propertiesOut.size() + ")");
+ }
+ if (checkBundle) {
+ checkBundle(locale, propertiesOut, showEmpty);
+ }
+ }
+
+ // ecriture du ficher des definitions i18n (permet de faire une
+ // recherche extact sur un fichier puis d'en deduire les bundles a
+ // charger
+ String f = String.format(I18nBundleFactory.UNIQUE_BUNDLE_DEF, bundleOutputName);
+ File defOut = new File(bundleOutputDir, f);
+ if (!silent) {
+ getLog().info("prepare i18n definition " + defOut.getAbsolutePath());
+ }
+ SortedProperties p = new SortedProperties(encoding, false);
+ p.setProperty(I18nBundleFactory.BUNDLE_DEF_LOCALES, bundles);
+ for (Entry<Locale, String> e : bundleDico.entrySet()) {
+ p.setProperty(I18nBundleFactory.BUNDLES_FOR_LOCALE + e.getKey().toString(), e.getValue());
+ }
+ p.store(new FileOutputStream(defOut), null);
+
+ if (!silent && verbose) {
+ getLog().info("done in " + PluginHelper.convertTime(t00, System.nanoTime()));
+ }
+ } catch (IOException e) {
+ getLog().error("File Error I/O ", e);
+ throw new MojoFailureException("File Error I/O ");
+ }
+ }
+
+
+ @Override
+ protected URL[] getCollectI18nResources(Locale locale) throws IOException {
+ File file = getCollectOutputFile(locale, false);
+ if (!file.exists()) {
+ return new URL[0];
+ }
+
+ List<URL> urls = new ArrayList<URL>();
+ BufferedReader stream = new BufferedReader(new InputStreamReader(new FileInputStream(file)));
+ while (stream.ready()) {
+ String line = stream.readLine().trim();
+ if (!line.isEmpty()) {
+ URL f = new URL(line);
+ urls.add(f);
+ }
+ }
+ return urls.toArray(new URL[urls.size()]);
+ }
+}
Property changes on: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/BundleMojo.java
___________________________________________________________________
Added: svn:mergeinfo
+
Added: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/CollectI18nArtifactsMojo.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/CollectI18nArtifactsMojo.java (rev 0)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/CollectI18nArtifactsMojo.java 2009-12-28 10:27:28 UTC (rev 1690)
@@ -0,0 +1,262 @@
+/*
+ * *##%
+ * I18n :: Maven Plugin
+ * Copyright (C) 2007 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%*
+ */
+package org.nuiton.i18n.plugin;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.factory.ArtifactFactory;
+import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.resolver.ArtifactCollector;
+import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
+import org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.shared.dependency.tree.DependencyNode;
+import org.apache.maven.shared.dependency.tree.DependencyTreeBuilder;
+import org.apache.maven.shared.dependency.tree.DependencyTreeBuilderException;
+import org.nuiton.i18n.bundle.I18nBundleEntry;
+import org.nuiton.plugin.DependencyUtil;
+import org.nuiton.plugin.PluginHelper;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+
+/**
+ * Detects any i18n artifacts and store the result as a file.
+ * <p/>
+ * Created: 24 déc. 2009
+ *
+ * @author Tony Chemit <chemit(a)codelutin.com> Copyright Code Lutin
+ * @version $Revision$
+ * <p/>
+ * Mise a jour: $Date$ par :
+ * $Author: tchemit $
+ * @goal collect-i18n-artifacts
+ * @phase generate-resources
+ * @execute goal=gen
+ * @requiresProject true
+ * @requiresDependencyResolution runtime
+ * @since 1.0.2
+ */
+public class CollectI18nArtifactsMojo extends AbstractI18nBundleMojo {
+ /**
+ * Local Repository.
+ *
+ * @parameter expression="${localRepository}"
+ * @required
+ * @readonly
+ * @since 1.0.2
+ */
+ protected ArtifactRepository localRepository;
+ /**
+ * Dependency tree builder component.
+ *
+ * @component
+ * @since 1.0.2
+ */
+ protected DependencyTreeBuilder dependencyTreeBuilder;
+ /**
+ * Artifact Factory component.
+ *
+ * @component
+ * @since 1.0.2
+ */
+ protected ArtifactFactory factory;
+ /**
+ * Artifact metadata source component.
+ *
+ * @component
+ * @since 1.0.2
+ */
+ protected ArtifactMetadataSource artifactMetadataSource;
+ /**
+ * Artifact collector component.
+ *
+ * @component
+ * @since 1.0.2
+ */
+ protected ArtifactCollector collector;
+
+ I18nArtifact[] i18nArtifacts;
+
+ @Override
+ public void init() throws Exception {
+ super.init();
+
+ if (locales == null || locales.length == 0) {
+ throw new IllegalStateException("il faut au moins une locale declaree (utiliser la propriete 'bundles')");
+ }
+
+ PluginHelper.createDirectoryIfNecessary(collectOutputDir);
+ }
+
+ @Override
+ public void execute() throws MojoExecutionException, MojoFailureException {
+
+ if ("pom".equals(project.getPackaging()) || "site".equals(project.getPackaging())) {
+ getLog().info("skip goal for none java-based packaging.");
+ return;
+ }
+
+ try {
+ init();
+ } catch (Exception e) {
+ throw new MojoExecutionException("could not init goal for reason " + e.getMessage(), e);
+ }
+
+ try {
+
+ // detects the i18n artifacts (only once since it cost some times)...
+ i18nArtifacts = detectI18nArtifacts();
+
+ if (i18nArtifacts.length == 0) {
+ getLog().warn("no i18n artifact detected.");
+ return;
+ }
+
+ for (Locale locale : locales) {
+
+ if (!silent) {
+ getLog().info("generate collected i18n artifacts for locale " + locale);
+ }
+ URL[] urls = getCollectI18nResources(locale);
+
+ if (urls.length == 0) {
+ getLog().warn("no i18n bundles for locale " + locale);
+ return;
+ }
+
+ File bundleOut = getCollectOutputFile(locale, true);
+
+ storeCollectI18nResources(bundleOut, urls);
+
+ getLog().info("collected " + urls.length + " i18n artifacts for locale " + locale + " stored in " + bundleOut);
+ }
+ } catch (IOException e) {
+ throw new MojoExecutionException("could not treate i18n artifacts", e);
+ } catch (DependencyTreeBuilderException e) {
+ throw new MojoExecutionException("could not obtain i18n artifacts", e);
+ }
+ }
+
+ @Override
+ protected URL[] getCollectI18nResources(Locale locale) throws IOException, DependencyTreeBuilderException {
+
+ // la locale par defaut est la première
+ Locale defaultLocale = locales[0];
+
+ List<URL> urls = new ArrayList<URL>();
+ for (I18nArtifact artifact : i18nArtifacts) {
+ I18nBundleEntry[] bundleEntries = artifact.getBundleEntries(locale, defaultLocale);
+ for (I18nBundleEntry bundleEntry : bundleEntries) {
+
+ URL path = bundleEntry.getPath();
+ urls.add(path);
+ if (verbose) {
+ getLog().info("add " + path);
+ }
+ }
+ }
+ return urls.toArray(new URL[urls.size()]);
+ }
+
+ protected void storeCollectI18nResources(File bundleOut, URL[] urls) throws IOException {
+ StringBuilder buffer = new StringBuilder();
+
+ for (URL path : urls) {
+
+ buffer.append(path).append("\n");
+
+ if (verbose) {
+ getLog().info("add " + path);
+ }
+ }
+ PluginHelper.writeString(bundleOut, buffer.toString(), encoding);
+ }
+
+ /**
+ * Detecte les {@link I18nArtifact} et les retourne dans l'ordre de chargement
+ * dans le système i18n, i.e l'ordre des dependances entre artifacts.
+ *
+ * @return les artifacts i18nables triés par leur ordre de chargement dans le système i18n.
+ * @throws java.io.IOException while detecting bundles from artifacts
+ * @throws org.apache.maven.shared.dependency.tree.DependencyTreeBuilderException
+ * if any error while building the depencendy tree
+ */
+ protected I18nArtifact[] detectI18nArtifacts() throws IOException, DependencyTreeBuilderException {
+
+ Map<Artifact, I18nArtifact> dico = new java.util.HashMap<Artifact, I18nArtifact>();
+
+ I18nArtifact i18nArtifact;
+ for (Object o : project.getArtifacts()) {
+ i18nArtifact = new I18nArtifact((Artifact) o);
+ if (i18nArtifact.detectBundles()) {
+ if (!silent) {
+ getLog().info("detected i18n artifact " + i18nArtifact);
+ }
+ dico.put(i18nArtifact.getArtifact(), i18nArtifact);
+ } else {
+ if (getLog().isDebugEnabled()) {
+ getLog().debug("reject artifact " + i18nArtifact);
+ }
+ }
+ }
+
+ ArtifactFilter artifactFilter = new ScopeArtifactFilter(Artifact.SCOPE_RUNTIME);
+
+ DependencyNode rootNode = dependencyTreeBuilder.buildDependencyTree(project, localRepository, factory,
+ artifactMetadataSource, artifactFilter, collector);
+
+ List<Artifact> artifacts = new java.util.ArrayList<Artifact>(dico.keySet());
+
+ DependencyUtil.sortArtifacts(rootNode, artifacts, getLog().isDebugEnabled());
+
+ // l'artifact du projet est traite en dernier car s'il possède des
+ // bundles alors ils doivent etre charge en dernier
+
+ Artifact projectArtifact = project.getArtifact();
+ i18nArtifact = new I18nArtifact(projectArtifact, src.getParentFile());
+
+ if (i18nArtifact.detectBundles()) {
+ if (!silent) {
+ getLog().info("detected i18n artifact " + i18nArtifact);
+ }
+ artifacts.add(i18nArtifact.getArtifact());
+ dico.put(i18nArtifact.getArtifact(), i18nArtifact);
+ } else {
+ if (getLog().isDebugEnabled()) {
+ getLog().debug("reject artifact " + i18nArtifact);
+ }
+ }
+
+ I18nArtifact[] result = new I18nArtifact[artifacts.size()];
+ int i = 0;
+ for (Artifact artifact : artifacts) {
+ result[i++] = dico.get(artifact);
+ }
+ return result;
+ }
+}
Property changes on: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/CollectI18nArtifactsMojo.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Deleted: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/Generate.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/Generate.java 2009-12-28 10:26:01 UTC (rev 1689)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/Generate.java 2009-12-28 10:27:28 UTC (rev 1690)
@@ -1,144 +0,0 @@
-/*
- * *##% Plugin maven pour i18n
- * Copyright (C) 2007 - 2009 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%* */
-package org.nuiton.i18n.plugin;
-
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
-import org.nuiton.io.SortedProperties;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.Locale;
-
-/**
- * Merge des fichiers de propriétés avec les anciens.
- *
- * @author julien
- * @goal gen
- * @phase generate-resources
- * @execute goal=get
- */
-public class Generate extends AbstractI18nPlugin {
-
- /**
- * Un drapeau pour vérifier que les bundles ne contiennent pas d'entrées vides.
- *
- * @parameter expression="${i18n.checkBundle}" default-value="true"
- * @required
- * @since 1.0.0
- */
- protected boolean checkBundle;
- /**
- * Un drapeau pour afficher les entrées vides. (nécessite {@link #checkBundle} activé).
- *
- * @parameter expression="${i18n.showEmpty}" default-value="false"
- * @required
- * @since 1.0.0
- */
- protected boolean showEmpty;
-
- @Override
- public void execute() throws MojoExecutionException, MojoFailureException {
-
- init();
-
- if (!needGeneration()) {
- getLog().info("Nothing to generate - all files are up to date.");
- return;
- }
-
- if (!silent) {
- getLog().info("config - src basedir : " + src.getAbsolutePath());
- getLog().info("config - out basedir : " + out.getAbsolutePath());
- getLog().info("config - locales : " + Arrays.toString(locales));
- }
- for (Locale locale : locales) {
- if (!silent) {
- getLog().info("prepare bundle for locale " + locale);
- }
- try {
- // Merge
- File bundleSrc = getI18nFile(src, artifactId, locale, false);
- File bundleOut = getI18nFile(out, artifactId, locale, false);
-
- SortedProperties propertiesSrc = new SortedProperties(encoding);
-
- if (bundleSrc.exists()) {
- propertiesSrc.load(bundleSrc);
- }
-
- SortedProperties propertiesOut = new SortedProperties(encoding);
-
- if (!strictMode) {
- // si on n'est pas en mode strict, on doit push back in bundle out, all the bundle src keys
- propertiesOut.putAll(propertiesSrc);
- }
- propertiesOut.load(bundleOut);
-
- // Parcours des clés
- for (Object key : propertiesOut.keySet()) {
- Object oldKey = propertiesOut.get(key);
- Object value = propertiesSrc.get(oldKey);
-
- // Récupération de la clé si elle a été renommée
- if (!key.equals(oldKey) && value == null) {
- value = propertiesSrc.get(key);
- }
-
- if (value != null) {
- propertiesOut.put(key, value);
- } else {
- propertiesOut.put(key, "");
- }
- }
-
- //fixme : on devrait laisser le fichier en utf8 ?
- //propertiesOut.store(bundleOut);
- propertiesOut.store(new FileOutputStream(bundleOut));
-
- // Sauvegarde avant copie
- if (genSrc && keepBackup) {
- backupFile(bundleSrc);
- }
- if (!silent) {
- getLog().info("merge bundle " + locale + " to out");
- }
-
- if (checkBundle) {
- checkBundle(locale, propertiesOut, showEmpty);
- }
-
- if (genSrc) {
- // Copie des fichiers dans les sources
- copyFile(bundleOut, bundleSrc);
- //if (verbose) {
- if (!silent) {
- getLog().info("copy bundle " + locale + " to src");
- }
- //}
- }
-
- } catch (IOException e) {
- getLog().error("File Error I/O ", e);
- throw new MojoFailureException("File Error I/O ");
- }
- }
- }
-}
Copied: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/GenerateMojo.java (from rev 1687, trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/Generate.java)
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/GenerateMojo.java (rev 0)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/GenerateMojo.java 2009-12-28 10:27:28 UTC (rev 1690)
@@ -0,0 +1,157 @@
+/*
+ * *##%
+ * I18n :: Maven Plugin
+ * Copyright (C) 2007 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%* */
+package org.nuiton.i18n.plugin;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.nuiton.io.SortedProperties;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Locale;
+
+/**
+ * Merge des fichiers de propriétés avec les anciens.
+ *
+ * @author julien
+ * @goal gen
+ * @phase generate-resources
+ * @execute goal=get
+ */
+public class GenerateMojo extends AbstractI18nMojo {
+ /**
+ * Un drapeau pour vérifier que les bundles ne contiennent pas d'entrées vides.
+ *
+ * @parameter expression="${i18n.checkBundle}" default-value="true"
+ * @required
+ * @since 1.0.0
+ */
+ protected boolean checkBundle;
+ /**
+ * Un drapeau pour afficher les entrées vides. (nécessite {@link #checkBundle} activé).
+ *
+ * @parameter expression="${i18n.showEmpty}" default-value="false"
+ * @required
+ * @since 1.0.0
+ */
+ protected boolean showEmpty;
+ /**
+ * conserve les anciens fichiers de traduction avec un suffix ~
+ * <p/>
+ * Note: par defaut, on ne l'active pas.
+ *
+ * @parameter expression="${i18n.keepBackup}" default-value="false"
+ */
+ protected boolean keepBackup;
+
+ @Override
+ public void execute() throws MojoExecutionException, MojoFailureException {
+
+ try {
+ init();
+ } catch (Exception e) {
+ throw new MojoExecutionException("could not init goal for reason " + e.getMessage(), e);
+ }
+
+ if (!needGeneration()) {
+ getLog().info("Nothing to generate - all files are up to date.");
+ return;
+ }
+
+ if (!silent) {
+ getLog().info("config - src basedir : " + src.getAbsolutePath());
+ getLog().info("config - out basedir : " + out.getAbsolutePath());
+ getLog().info("config - locales : " + Arrays.toString(locales));
+ }
+ for (Locale locale : locales) {
+ if (!silent) {
+ getLog().info("prepare bundle for locale " + locale);
+ }
+ try {
+ // Merge
+ File bundleSrc = getI18nFile(src, artifactId, locale, false);
+ File bundleOut = getI18nFile(out, artifactId, locale, false);
+
+ SortedProperties propertiesSrc = new SortedProperties(encoding);
+
+ if (bundleSrc.exists()) {
+ propertiesSrc.load(bundleSrc);
+ }
+
+ SortedProperties propertiesOut = new SortedProperties(encoding);
+
+ if (!strictMode) {
+ // si on n'est pas en mode strict, on doit push back in bundle out, all the bundle src keys
+ propertiesOut.putAll(propertiesSrc);
+ }
+ propertiesOut.load(bundleOut);
+
+ // Parcours des clés
+ for (Object key : propertiesOut.keySet()) {
+ Object oldKey = propertiesOut.get(key);
+ Object value = propertiesSrc.get(oldKey);
+
+ // Récupération de la clé si elle a été renommée
+ if (!key.equals(oldKey) && value == null) {
+ value = propertiesSrc.get(key);
+ }
+
+ if (value != null) {
+ propertiesOut.put(key, value);
+ } else {
+ propertiesOut.put(key, "");
+ }
+ }
+
+ //fixme : on devrait laisser le fichier en utf8 ?
+ //propertiesOut.store(bundleOut);
+ propertiesOut.store(new FileOutputStream(bundleOut));
+
+ // Sauvegarde avant copie
+ if (genSrc && keepBackup) {
+ backupFile(bundleSrc);
+ }
+ if (!silent) {
+ getLog().info("merge bundle " + locale + " to out");
+ }
+
+ if (checkBundle) {
+ checkBundle(locale, propertiesOut, showEmpty);
+ }
+
+ if (genSrc) {
+ // Copie des fichiers dans les sources
+ copyFile(bundleOut, bundleSrc);
+ //if (verbose) {
+ if (!silent) {
+ getLog().info("copy bundle " + locale + " to src");
+ }
+ //}
+ }
+
+ } catch (IOException e) {
+ getLog().error("File Error I/O ", e);
+ throw new MojoFailureException("File Error I/O ");
+ }
+ }
+ }
+}
Property changes on: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/GenerateMojo.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:mergeinfo
+
Added: svn:eol-style
+ native
Deleted: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/Getter.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/Getter.java 2009-12-28 10:26:01 UTC (rev 1689)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/Getter.java 2009-12-28 10:27:28 UTC (rev 1690)
@@ -1,115 +0,0 @@
-/*
- * *##% Plugin maven pour i18n
- * Copyright (C) 2007 - 2009 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%* */
-package org.nuiton.i18n.plugin;
-
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
-import org.codehaus.plexus.util.DirectoryScanner;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.Locale;
-import org.nuiton.plugin.PluginHelper;
-import org.nuiton.io.SortedProperties;
-
-/**
- * Recupere les différents fichiers des parsers en un fichier de proprietes.
- *
- * @author julien
- * @goal get
- * @phase generate-resources
- */
-public class Getter extends AbstractI18nPlugin {
-
- /*
- * (non-Javadoc)
- * @see org.apache.maven.plugin.AbstractMojo#execute()
- */
- @Override
- public void execute() throws MojoExecutionException, MojoFailureException {
-
- init();
-
- if (!needGeneration()) {
- if (verbose) {
- getLog().info("Nothing to generate - all files are up to date.");
- }
- return;
- }
- if (!silent) {
- getLog().info("config - basedir : " + out.getAbsolutePath());
- getLog().info("config - locales : " + Arrays.toString(locales));
- }
-
- try {
- File bundleGetters = new File(out.getAbsolutePath() + File.separatorChar + artifactId + ".properties");
- bundleGetters.createNewFile();
-
- DirectoryScanner ds = new DirectoryScanner();
- ds.setBasedir(out);
- ds.setIncludes(new String[]{"*.getter"});
- ds.scan();
- String[] files = ds.getIncludedFiles();
-
- // Fusion des fichiers propriétés des différents parsers
- for (String file : files) {
- long t0 = System.nanoTime();
- File bundleGetter = getGetterFile(out, file, false);
- concactProperties(bundleGetter, bundleGetters);
- if (genSrc) {
- bundleGetter.delete();
- }
- if (!silent) {
- getLog().info("import getter " + bundleGetter.getName() + " in " + PluginHelper.convertTime(System.nanoTime() - t0));
- }
- }
-
- // Création des bundles
- for (Locale locale : locales) {
- if (!silent && getLog().isDebugEnabled()) {
- getLog().debug("generate bundle for locale " + locale);
- }
- File bundleOut = getI18nFile(out, artifactId, locale, false);
- copyFile(bundleGetters, bundleOut);
- if (!silent && verbose) {
- getLog().info("generate bundle " + locale);
- }
- }
-
- bundleGetters.delete();
- } catch (IOException e) {
- getLog().error("File Error I/O ", e);
- throw new MojoFailureException("File Error I/O");
- }
- }
-
- /**
- * Concatene deux fichiers de proprietes
- *
- * @param in le fichier entrant
- * @param out le fichier sortant
- * @throws IOException si problème pendant la sauvegarde ou fichier non trouvé.
- */
- protected void concactProperties(File in, File out) throws IOException {
- SortedProperties propertiesIn = new SortedProperties(encoding).load(in);
- SortedProperties propertiesOut = new SortedProperties(encoding).load(out);
- propertiesOut.putAll(propertiesIn);
- propertiesOut.store(out);
- }
-}
Copied: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/GetterMojo.java (from rev 1687, trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/Getter.java)
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/GetterMojo.java (rev 0)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/GetterMojo.java 2009-12-28 10:27:28 UTC (rev 1690)
@@ -0,0 +1,119 @@
+/*
+ * *##%
+ * I18n :: Maven Plugin
+ * Copyright (C) 2007 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%* */
+package org.nuiton.i18n.plugin;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.codehaus.plexus.util.DirectoryScanner;
+import org.nuiton.io.SortedProperties;
+import org.nuiton.plugin.PluginHelper;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Locale;
+
+/**
+ * Recupere les différents fichiers des parsers en un fichier de proprietes.
+ *
+ * @author julien
+ * @goal get
+ * @phase generate-resources
+ */
+public class GetterMojo extends AbstractI18nMojo {
+
+ @Override
+ public void execute() throws MojoExecutionException, MojoFailureException {
+
+ try {
+ init();
+ } catch (Exception e) {
+ throw new MojoExecutionException("could not init goal for reason " + e.getMessage(), e);
+ }
+
+ if (!needGeneration()) {
+ if (verbose) {
+ getLog().info("Nothing to generate - all files are up to date.");
+ }
+ return;
+ }
+ if (!silent) {
+ getLog().info("config - basedir : " + out.getAbsolutePath());
+ getLog().info("config - locales : " + Arrays.toString(locales));
+ }
+
+ try {
+ File bundleGetters = new File(out.getAbsolutePath() + File.separatorChar + artifactId + ".properties");
+ boolean b = bundleGetters.createNewFile();
+ if (!b) {
+ throw new IOException("could not create file " + bundleGetters);
+ }
+ DirectoryScanner ds = new DirectoryScanner();
+ ds.setBasedir(out);
+ ds.setIncludes(new String[]{"*.getter"});
+ ds.scan();
+ String[] files = ds.getIncludedFiles();
+
+ // Fusion des fichiers propriétés des différents parsers
+ for (String file : files) {
+ long t0 = System.nanoTime();
+ File bundleGetter = getGetterFile(out, file, false);
+ concactProperties(bundleGetter, bundleGetters);
+ if (genSrc) {
+ PluginHelper.deleteFile(bundleGetter);
+ }
+ if (!silent) {
+ getLog().info("import getter " + bundleGetter.getName() + " in " + PluginHelper.convertTime(System.nanoTime() - t0));
+ }
+ }
+
+ // Création des bundles
+ for (Locale locale : locales) {
+ if (getLog().isDebugEnabled()) {
+ getLog().debug("generate bundle for locale " + locale);
+ }
+ File bundleOut = getI18nFile(out, artifactId, locale, false);
+ copyFile(bundleGetters, bundleOut);
+ if (!silent && verbose) {
+ getLog().info("generate bundle " + locale);
+ }
+ }
+ PluginHelper.deleteFile(bundleGetters);
+ } catch (IOException e) {
+ getLog().error("File Error I/O ", e);
+ throw new MojoFailureException("File Error I/O");
+ }
+ }
+
+
+ /**
+ * Concatene deux fichiers de proprietes
+ *
+ * @param in le fichier entrant
+ * @param out le fichier sortant
+ * @throws IOException si problème pendant la sauvegarde ou fichier non trouvé.
+ */
+ protected void concactProperties(File in, File out) throws IOException {
+ SortedProperties propertiesIn = new SortedProperties(encoding).load(in);
+ SortedProperties propertiesOut = new SortedProperties(encoding).load(out);
+ propertiesOut.putAll(propertiesIn);
+ propertiesOut.store(out);
+ }
+}
Property changes on: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/GetterMojo.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:mergeinfo
+
Added: svn:eol-style
+ native
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/I18nArtifact.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/I18nArtifact.java 2009-12-28 10:26:01 UTC (rev 1689)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/I18nArtifact.java 2009-12-28 10:27:28 UTC (rev 1690)
@@ -1,5 +1,6 @@
/**
- * *##% Plugin maven pour i18n
+ * *##%
+ * I18n :: Maven Plugin
* Copyright (C) 2007 - 2009 CodeLutin
*
* This program is free software: you can redistribute it and/or modify
@@ -14,16 +15,11 @@
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%*
*/
package org.nuiton.i18n.plugin;
-import java.io.File;
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.List;
-import java.util.Locale;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.maven.artifact.Artifact;
@@ -31,8 +27,14 @@
import org.nuiton.i18n.bundle.I18nBundleEntry;
import org.nuiton.i18n.bundle.I18nBundleFactory;
+import java.io.File;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.List;
+import java.util.Locale;
+
/**
- *
* @author chemit
* @since 0.12
*/
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/I18nLogger.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/I18nLogger.java 2009-12-28 10:26:01 UTC (rev 1689)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/I18nLogger.java 2009-12-28 10:27:28 UTC (rev 1690)
@@ -1,5 +1,6 @@
/**
- * *##% Plugin maven pour i18n
+ * *##%
+ * I18n :: Maven Plugin
* Copyright (C) 2007 - 2009 CodeLutin
*
* This program is free software: you can redistribute it and/or modify
@@ -14,15 +15,17 @@
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%*
*/
package org.nuiton.i18n.plugin;
import org.apache.maven.plugin.logging.SystemStreamLog;
+import org.nuiton.plugin.PluginHelper;
import java.beans.Introspector;
import java.io.File;
-import org.nuiton.plugin.PluginHelper;
+
/**
* Le logger utilisé par les mojo.
*
@@ -31,16 +34,22 @@
*/
public class I18nLogger extends SystemStreamLog {
- /** l'entrée en cours de traitement (pour les parseurs) */
+ /**
+ * l'entrée en cours de traitement (pour les parseurs)
+ */
private SourceEntry entry;
- /** le fichier en cours de traitement (pour les parseurs) */
+ /**
+ * le fichier en cours de traitement (pour les parseurs)
+ */
protected File file;
- /** le prefix du mojo courant a ajouter dans les logs. */
+ /**
+ * le prefix du mojo courant a ajouter dans les logs.
+ */
protected String parser;
- public I18nLogger(AbstractI18nPlugin parser) {
+ public I18nLogger(AbstractI18nMojo parser) {
this.parser = "i18n:" + Introspector.decapitalize(parser.getClass().getSimpleName()) + " on " + parser.getArtifactId();
}
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/SourceEntry.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/SourceEntry.java 2009-12-28 10:26:01 UTC (rev 1689)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/SourceEntry.java 2009-12-28 10:27:28 UTC (rev 1690)
@@ -1,7 +1,7 @@
/*
* *##%
- * Maven helper plugin
- * Copyright (C) 2009 CodeLutin
+ * I18n :: Maven Plugin
+ * Copyright (C) 2007 - 2009 CodeLutin
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
@@ -20,9 +20,9 @@
*/
package org.nuiton.i18n.plugin;
-import org.nuiton.io.FileUpdater;
import org.apache.maven.plugin.logging.Log;
import org.codehaus.plexus.util.DirectoryScanner;
+import org.nuiton.io.FileUpdater;
import java.io.File;
import java.lang.annotation.Annotation;
@@ -59,7 +59,9 @@
protected String[] includes;
protected String[] excludes;
- /** Files to be find */
+ /**
+ * Files to be find
+ */
protected String[] files;
protected String[] skipFiles;
Deleted: 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-12-28 10:26:01 UTC (rev 1689)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/AbstractI18nParser.java 2009-12-28 10:27:28 UTC (rev 1690)
@@ -1,313 +0,0 @@
-/*
- * *##% Plugin maven pour i18n
- * Copyright (C) 2007 - 2009 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%* */
-package org.nuiton.i18n.plugin.parser;
-
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
-import org.nuiton.i18n.plugin.AbstractI18nPlugin;
-import org.nuiton.i18n.plugin.I18nLogger;
-import org.nuiton.io.SortedProperties;
-import org.nuiton.i18n.plugin.parser.event.KeysModifier;
-import org.nuiton.io.FileUpdater;
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import org.nuiton.i18n.plugin.SourceEntry;
-
-/**
- * Abstract implementation for parsing goal.
- *
- * @author tony
- */
-public abstract class AbstractI18nParser extends AbstractI18nPlugin implements Parser {
-
- /** @return the outGetter to use for the instance (java.getter,...) */
- protected abstract String getOutGetter();
-
- /** @return the starting regex expression to catch keys in key modifier */
- protected abstract String getKeyModifierStart();
-
- /** @return the ending regex expression to catch keys in key modifier */
- protected abstract String getKeyModifierEnd();
-
- /** @return the default includes to add to directory scanner */
- protected abstract String[] getDefaultIncludes();
-
- /** @return the default excludes to add to directory scanner */
- protected abstract String[] getDefaultExcludes();
-
- /** @return the default src directory to use in directory scanner */
- protected abstract File getDefaultBasedir();
-
- public abstract FileUpdater newFileUpdater(SourceEntry entry);
- /**
- * treate default entry
- *
- * @parameter expression="${i18n.treateDefaultEntry}" default-value="true"
- */
- protected boolean treateDefaultEntry;
- /**
- * Source entries (src+includes+excludes) .
- *
- * @parameter expression="${i18n.entries}"
- */
- protected I18nSourceEntry[] entries;
- /**
- * flag to display touched files while parsing.
- * <p/>
- * Note: the value will be always <code>true</code> if {@link #verbose} is set
- * at <code>true</code>.
- *
- * @parameter expression="${i18n.showTouchedFiles}" default-value="${maven.verbose}"
- * @since 0.9
- */
- protected boolean showTouchedFiles;
- /**
- * flag to save at eachfile treated the getter file
- *
- * @parameter expression="${i18n.safeMode}" default-value="false"
- * @since 0.9
- */
- protected boolean safeMode;
- protected SortedProperties result;
- protected SortedProperties oldParser;
- protected SortedProperties oldLanguage;
- protected int fileTreated = 0;
- protected long t0;
- protected boolean touchFile;
- protected List<File> treadedFiles;
-
- public boolean isStrictMode() {
- return strictMode;
- }
-
- @Override
- public void init() {
- super.init();
- t0 = System.nanoTime();
- result = new SortedProperties(encoding);
- oldParser = new SortedProperties(encoding);
- oldLanguage = new SortedProperties(encoding);
- out.mkdirs();
- // evenements
- if (keysModifier) {
- addParserEvent(KeysModifier.getInstance(getKeyModifierStart(), getKeyModifierEnd(), encoding));
- }
- treadedFiles = new ArrayList<File>();
- if (!silent && verbose) {
- showTouchedFiles = true;
- }
- }
-
-
- /*
- * (non-Javadoc)
- * @see org.apache.maven.plugin.AbstractMojo#execute()
- */
- @Override
- public void execute() throws MojoExecutionException, MojoFailureException {
-
- init();
- if (entries == null || entries.length == 0 && !treateDefaultEntry) {
- // nothing to do
- return;
- }
-
- if (!silent && safeMode) {
- getLog().info("config - safeMode is on (could be slower).");
- }
- if (!silent && strictMode) {
- getLog().info("config - strictMode is on (all files will be parsed).");
- }
-
- try {
- // Reprise sur un ancien parsing
- File oldParserFile = getGetterFile(out, getOutGetter(), true);
- File saveFile = getGetterFileBackup(out, getOutGetter());
-
- oldParser.load(oldParserFile);
- copyFile(oldParserFile, saveFile);
-
- // Anciennes cles disponnibles
- //fixme : pourquoi on utilise un bundle precis ? le premier ici, je ne comprends pas
- File oldLanguageFile = getI18nFile(src, artifactId, locales[0], true);
-
- oldLanguage.load(oldLanguageFile);
-
- // Parsing
- parse();
-
- // Suppression du fichier sauvegarder
- saveFile.delete();
-
- int i = treadedFiles.size();
- if (fileTreated == 0) {
- if (!silent) {
- getLog().info("Nothing to generate - all files are up to date.");
- }
- } else {
- if (!silent) {
- getLog().info(getVerboseLog().getLogEntry("parsing is done. [treated file(s) : " + i + '/' + fileTreated + "]", fileTreated, 0, t0));
- }
- addGetter();
- }
-
- } catch (Exception e) {
- getLog().error("Error code parsing ", e);
- throw new MojoFailureException("Error code parsing");
- }
-
- }
-
- /**
- * launch the parse on every given entries.
- *
- * @throws IOException if any io pb
- */
- @Override
- public void parse() throws IOException {
- if (treateDefaultEntry) {
- addDefaultEntry();
- }
- long t00 = System.nanoTime();
- for (I18nSourceEntry entry : this.entries) {
- I18nLogger vLog = getVerboseLog();
-
- vLog.setEntry(entry);
-
- boolean skip = entry.init(this);
-
- if (skip) {
- if (!silent && verbose) {
- getLog().info("skip - " + entry.getSkipMessage());
- }
- continue;
- }
-
- long t000 = System.nanoTime();
- int nbFiles = entry.getFiles().length;
- if (!silent && verbose) {
- vLog.infoEntry("start", vLog.getLogEntry("[incoming file(s) : " + entry.getFoudFiles() + "]", 0, 0, 0));
- }
-
- // launch parser for found files
- parseEntry(entry);
-
- if (!silent && verbose) {
- // log skipped files
- for (String skipFile : entry.getSkipFiles()) {
- vLog.setFile(new File(entry.getBasedir(), skipFile));
- vLog.infoFile("skip", null);
- }
- }
- fileTreated += nbFiles;
- if (!silent && verbose) {
- vLog.infoEntry("end", vLog.getLogEntry("[treated file(s) : " + nbFiles + "]", nbFiles, t000, t00));
- }
- t00 = System.nanoTime();
- }
- }
-
- /**
- * Add the default entry to entries given in configuration.
- * <p/>
- * This is a convinient method to simplify the configuration of the plugin.
- */
- protected void addDefaultEntry() {
-// List<MySourceEntry> list;
- if (verbose) {
- getLog().info("add default entry");
- }
- 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;
- }
-
- /**
- * launch parsing on a given entry.
- *
- * @param entry currentEntry to treate
- * @throws IOException if any io pb.
- */
- protected final void parseEntry(SourceEntry entry) throws IOException {
- long t00 = System.nanoTime();
- String[] files = entry.getFiles();
- int beforeEntryResultSize = result.size();
- for (int i = 0, max = files.length; i < max; i++) {
- String file1 = files[i];
- long t000 = System.nanoTime();
- String fileName = entry.getBasedir().getAbsolutePath() + File.separator + file1;
- File file = new File(fileName);
- for (ParserEvent event : events) {
- event.eventChangeFile(file);
- }
- I18nLogger vLog = getVerboseLog();
- vLog.setFile(file);
-
- touchFile = false;
- int size = result.size();
- if (!silent && verbose) {
- vLog.infoFile("parse", null);
- }
- parseFile(file);
-
- //TC-20090214 pour des questions de performance, on ne sauvegarde pas
- // a chaque traitement de fichier, les clefs mais une fois pour chaque
- // source entry
- // Detection de nouvelles cles, sauvegarde du fichier pour pouvoir le restaurer en cas de plantage
- if (safeMode) {
- if (size != result.size()) {
- saveGetterFile();
- }
- }
- if (touchFile) {
- if (showTouchedFiles) {
- vLog.infoFile("touch", null);
- }
- treadedFiles.add(file);
- if (getLog().isDebugEnabled()) {
- vLog.debug(vLog.getLogEntry(fileName, i, t000, t00));
- }
- }
- for (ParserEvent event : events) {
- event.eventNextFile(file);
- }
- }
-
- if (!safeMode && beforeEntryResultSize < result.size()) {
- // Detection de nouvelles cles, sauvegarde du fichier
- saveGetterFile();
- }
- }
-
- /**
- * Save the result in the getter file.
- *
- * @throws IOException if any io pb
- */
- protected void saveGetterFile() throws IOException {
- File getterFile = getGetterFile(out, getOutGetter(), false);
- result.store(getterFile);
- }
-
-}
Copied: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/AbstractI18nParserMojo.java (from rev 1687, 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/AbstractI18nParserMojo.java (rev 0)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/AbstractI18nParserMojo.java 2009-12-28 10:27:28 UTC (rev 1690)
@@ -0,0 +1,358 @@
+/*
+ * *##%
+ * I18n :: Maven Plugin
+ * Copyright (C) 2007 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%* */
+package org.nuiton.i18n.plugin.parser;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.nuiton.i18n.plugin.AbstractI18nMojo;
+import org.nuiton.i18n.plugin.I18nLogger;
+import org.nuiton.i18n.plugin.SourceEntry;
+import org.nuiton.io.FileUpdater;
+import org.nuiton.io.SortedProperties;
+import org.nuiton.plugin.PluginHelper;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Abstract implementation for parsing goal.
+ *
+ * @author tony
+ */
+public abstract class AbstractI18nParserMojo extends AbstractI18nMojo implements Parser {
+
+ /**
+ * @return the outGetter to use for the instance (java.getter,...)
+ */
+ protected abstract String getOutGetter();
+
+ /**
+ * @return the starting regex expression to catch keys in key modifier
+ */
+ protected abstract String getKeyModifierStart();
+
+ /**
+ * @return the ending regex expression to catch keys in key modifier
+ */
+ protected abstract String getKeyModifierEnd();
+
+ /**
+ * @return the default includes to add to directory scanner
+ */
+ protected abstract String[] getDefaultIncludes();
+
+ /**
+ * @return the default excludes to add to directory scanner
+ */
+ protected abstract String[] getDefaultExcludes();
+
+ /**
+ * @return the default src directory to use in directory scanner
+ */
+ protected abstract File getDefaultBasedir();
+
+ public abstract FileUpdater newFileUpdater(SourceEntry entry);
+
+ /**
+ * Active la modification de cle.
+ * <p/>
+ * Note: par defaut, on ne l'active pas (build sur serveur non ui).
+ *
+ * @parameter expression="${i18n.keysModifier}" default-value="false"
+ */
+ protected boolean keysModifier;
+ /**
+ * treate default entry
+ *
+ * @parameter expression="${i18n.treateDefaultEntry}" default-value="true"
+ */
+ protected boolean treateDefaultEntry;
+ /**
+ * Source entries (src+includes+excludes) .
+ *
+ * @parameter expression="${i18n.entries}"
+ */
+ protected I18nSourceEntry[] entries;
+ /**
+ * flag to display touched files while parsing.
+ * <p/>
+ * Note: the value will be always <code>true</code> if {@link #verbose} is set
+ * at <code>true</code>.
+ *
+ * @parameter expression="${i18n.showTouchedFiles}" default-value="${maven.verbose}"
+ * @since 0.9
+ */
+ protected boolean showTouchedFiles;
+ /**
+ * flag to save at eachfile treated the getter file
+ *
+ * @parameter expression="${i18n.safeMode}" default-value="false"
+ * @since 0.9
+ */
+ protected boolean safeMode;
+ /**
+ * Liste des évènements
+ */
+ protected List<ParserEvent> events = new ArrayList<ParserEvent>();
+ protected SortedProperties result;
+ protected SortedProperties oldParser;
+ protected SortedProperties oldLanguage;
+ protected int fileTreated = 0;
+ protected long t0;
+ protected boolean touchFile;
+ protected List<File> treadedFiles;
+
+ public boolean isStrictMode() {
+ return strictMode;
+ }
+
+ @Override
+ public void init() throws Exception {
+ super.init();
+ t0 = System.nanoTime();
+ result = new SortedProperties(encoding);
+ oldParser = new SortedProperties(encoding);
+ oldLanguage = new SortedProperties(encoding);
+ PluginHelper.createDirectoryIfNecessary(out);
+// out.mkdirs();
+ // evenements
+ if (keysModifier) {
+ addParserEvent(KeysModifier.getInstance(getKeyModifierStart(), getKeyModifierEnd(), encoding));
+ }
+ treadedFiles = new ArrayList<File>();
+ if (!silent && verbose) {
+ showTouchedFiles = true;
+ }
+ }
+
+ @Override
+ public void execute() throws MojoExecutionException, MojoFailureException {
+
+ try {
+ init();
+ } catch (Exception e) {
+ throw new MojoExecutionException("could not init goal for reason " + e.getMessage(), e);
+ }
+
+ if (entries == null || entries.length == 0 && !treateDefaultEntry) {
+ // nothing to do
+ return;
+ }
+
+ if (!silent && safeMode) {
+ getLog().info("config - safeMode is on (could be slower).");
+ }
+ if (!silent && strictMode) {
+ getLog().info("config - strictMode is on (all files will be parsed).");
+ }
+
+ try {
+ // Reprise sur un ancien parsing
+ File oldParserFile = getGetterFile(out, getOutGetter(), true);
+ File saveFile = getGetterFileBackup(out, getOutGetter());
+
+ oldParser.load(oldParserFile);
+ copyFile(oldParserFile, saveFile);
+
+ // Anciennes cles disponnibles
+ //fixme : pourquoi on utilise un bundle precis ? le premier ici, je ne comprends pas
+ File oldLanguageFile = getI18nFile(src, artifactId, locales[0], true);
+
+ oldLanguage.load(oldLanguageFile);
+
+ // Parsing
+ parse();
+
+ // Suppression du fichier sauvegarder
+ boolean b = saveFile.delete();
+ if (!b) {
+ throw new IOException("could not delete file " + saveFile);
+ }
+
+ int i = treadedFiles.size();
+ if (fileTreated == 0) {
+ if (!silent) {
+ getLog().info("Nothing to generate - all files are up to date.");
+ }
+ } else {
+ if (!silent) {
+ getLog().info(getVerboseLog().getLogEntry("parsing is done. [treated file(s) : " + i + '/' + fileTreated + "]", fileTreated, 0, t0));
+ }
+ addGetter();
+ }
+
+ } catch (Exception e) {
+ getLog().error("Error code parsing ", e);
+ throw new MojoFailureException("Error code parsing");
+ }
+
+ }
+
+ @Override
+ public void parse() throws IOException {
+ if (treateDefaultEntry) {
+ addDefaultEntry();
+ }
+ long t00 = System.nanoTime();
+ for (I18nSourceEntry entry : this.entries) {
+ I18nLogger vLog = getVerboseLog();
+
+ vLog.setEntry(entry);
+
+ boolean skip = entry.init(this);
+
+ if (skip) {
+ if (!silent && verbose) {
+ getLog().info("skip - " + entry.getSkipMessage());
+ }
+ continue;
+ }
+
+ long t000 = System.nanoTime();
+ int nbFiles = entry.getFiles().length;
+ if (!silent && verbose) {
+ vLog.infoEntry("start", vLog.getLogEntry("[incoming file(s) : " + entry.getFoudFiles() + "]", 0, 0, 0));
+ }
+
+ // launch parser for found files
+ parseEntry(entry);
+
+ if (!silent && verbose) {
+ // log skipped files
+ for (String skipFile : entry.getSkipFiles()) {
+ vLog.setFile(new File(entry.getBasedir(), skipFile));
+ vLog.infoFile("skip", null);
+ }
+ }
+ fileTreated += nbFiles;
+ if (!silent && verbose) {
+ vLog.infoEntry("end", vLog.getLogEntry("[treated file(s) : " + nbFiles + "]", nbFiles, t000, t00));
+ }
+ t00 = System.nanoTime();
+ }
+ }
+
+ /**
+ * Add the default entry to entries given in configuration.
+ * <p/>
+ * This is a convinient method to simplify the configuration of the plugin.
+ */
+ protected void addDefaultEntry() {
+// List<MySourceEntry> list;
+ if (verbose) {
+ getLog().info("add default entry");
+ }
+ 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;
+ }
+
+ /**
+ * launch parsing on a given entry.
+ *
+ * @param entry currentEntry to treate
+ * @throws IOException if any io pb.
+ */
+ protected final void parseEntry(SourceEntry entry) throws IOException {
+ long t00 = System.nanoTime();
+ String[] files = entry.getFiles();
+ int beforeEntryResultSize = result.size();
+ for (int i = 0, max = files.length; i < max; i++) {
+ String file1 = files[i];
+ long t000 = System.nanoTime();
+ String fileName = entry.getBasedir().getAbsolutePath() + File.separator + file1;
+ File file = new File(fileName);
+ for (ParserEvent event : events) {
+ event.eventChangeFile(file);
+ }
+ I18nLogger vLog = getVerboseLog();
+ vLog.setFile(file);
+
+ touchFile = false;
+ int size = result.size();
+ if (!silent && verbose) {
+ vLog.infoFile("parse", null);
+ }
+ parseFile(file);
+
+ //TC-20090214 pour des questions de performance, on ne sauvegarde pas
+ // a chaque traitement de fichier, les clefs mais une fois pour chaque
+ // source entry
+ // Detection de nouvelles cles, sauvegarde du fichier pour pouvoir le restaurer en cas de plantage
+ if (safeMode) {
+ if (size != result.size()) {
+ saveGetterFile();
+ }
+ }
+ if (touchFile) {
+ if (showTouchedFiles) {
+ vLog.infoFile("touch", null);
+ }
+ treadedFiles.add(file);
+ if (getLog().isDebugEnabled()) {
+ vLog.debug(vLog.getLogEntry(fileName, i, t000, t00));
+ }
+ }
+ for (ParserEvent event : events) {
+ event.eventNextFile(file);
+ }
+ }
+
+ if (!safeMode && beforeEntryResultSize < result.size()) {
+ // Detection de nouvelles cles, sauvegarde du fichier
+ saveGetterFile();
+ }
+ }
+
+ /**
+ * Save the result in the getter file.
+ *
+ * @throws IOException if any io pb
+ */
+ protected void saveGetterFile() throws IOException {
+ File getterFile = getGetterFile(out, getOutGetter(), false);
+ result.store(getterFile);
+ }
+
+ /**
+ * Ajoute un évènement
+ *
+ * @param parserEvent l'évènement d'ajout
+ */
+ protected void addParserEvent(ParserEvent parserEvent) {
+ this.events.add(parserEvent);
+ }
+
+ /**
+ * Supprime un évènement
+ *
+ * @param parserEvent l'évènement de suppression
+ */
+ protected void removeParserEvent(ParserEvent parserEvent) {
+ this.events.remove(parserEvent);
+ }
+
+}
Property changes on: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/AbstractI18nParserMojo.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:mergeinfo
+
Added: svn:eol-style
+ native
Modified: 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 2009-12-28 10:26:01 UTC (rev 1689)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/I18nSourceEntry.java 2009-12-28 10:27:28 UTC (rev 1690)
@@ -1,18 +1,39 @@
+/*
+ * *##%
+ * I18n :: Maven Plugin
+ * Copyright (C) 2007 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%*
+ */
package org.nuiton.i18n.plugin.parser;
+import org.nuiton.i18n.plugin.SourceEntry;
+
import java.io.File;
import java.util.ArrayList;
import java.util.List;
-import org.nuiton.i18n.plugin.SourceEntry;
/**
* Customized {@link SourceEntry} for parsers goals.
- *
+ *
* @author chemit
*/
public class I18nSourceEntry extends SourceEntry {
- public boolean init(AbstractI18nParser mojo) {
+ public boolean init(AbstractI18nParserMojo mojo) {
if (!useForGoal(mojo.getClass().getSimpleName())) {
// skip not for this goal
skipMessage = "exclude for this goal.";
@@ -66,7 +87,7 @@
* @param mojo the given mojo
* @return the list of relative path of files for the given entry
*/
- protected String[] getFilesForEntry(AbstractI18nParser mojo) {
+ protected String[] getFilesForEntry(AbstractI18nParserMojo mojo) {
return getIncludedFiles(mojo.getDefaultBasedir(), mojo.getDefaultIncludes(), mojo.getDefaultExcludes());
}
}
Copied: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/KeysModifier.java (from rev 1687, trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/event/KeysModifier.java)
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/KeysModifier.java (rev 0)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/KeysModifier.java 2009-12-28 10:27:28 UTC (rev 1690)
@@ -0,0 +1,214 @@
+/*
+ * *##%
+ * I18n :: Maven Plugin
+ * Copyright (C) 2007 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%* */
+
+package org.nuiton.i18n.plugin.parser;
+
+import org.nuiton.plugin.PluginHelper;
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * IHM permettant de modifier les clés de traduction en direct dans les fichiers
+ * parsés et les fichiers de propriétés.
+ *
+ * @author julien
+ */
+public class KeysModifier extends JFrame implements ParserEvent {
+
+ private static final long serialVersionUID = 1L;
+
+ // Modification des clés dans le fichier
+ protected List<String> newKeys;
+ protected boolean needModifiedFile;
+ protected String patternLeft;
+ protected String patternRight;
+ protected String encoding;
+
+ // Interface
+ protected JLabel name = new JLabel();
+ protected JLabel path = new JLabel();
+ protected JTextField key = new JTextField();
+ protected JTextField pattern = new JTextField(".*");
+ protected JCheckBox onlyNewKey = new JCheckBox();
+
+
+ protected JButton next = new JButton("Next >>");
+ private static KeysModifier keysModifier;
+
+ /**
+ * Récupération d'une instance de l'interface
+ *
+ * @param patternLeft left pattern
+ * @param patternRight right pattern
+ * @param encoding encoding
+ * @return the shared instance with new config
+ */
+ public static KeysModifier getInstance(String patternLeft, String patternRight, String encoding) {
+ if (keysModifier == null) {
+ keysModifier = new KeysModifier();
+ }
+
+
+ keysModifier.encoding = encoding;
+ keysModifier.patternLeft = patternLeft;
+ keysModifier.patternRight = patternRight;
+
+ return keysModifier;
+ }
+
+ /** Contructeur de l'interface */
+ private KeysModifier() {
+ setLayout(new GridLayout(9, 2, 10, 10));
+
+ Container pane = getContentPane();
+ pane.add(new JLabel("--- File information ---"));
+ pane.add(new JLabel());
+
+ pane.add(new JLabel("Name :"));
+ pane.add(name);
+
+ pane.add(new JLabel("Path : "));
+ pane.add(path);
+
+ pane.add(new JLabel("--- Files language ---"));
+ pane.add(new JLabel());
+
+ pane.add(new JLabel("Key :"));
+ pane.add(key);
+
+ pane.add(new JLabel("--- Filters ---"));
+ pane.add(new JLabel());
+
+ pane.add(new JLabel("Pattern :"));
+ pane.add(pattern);
+
+ pane.add(new JLabel("Only new key :"));
+ pane.add(onlyNewKey);
+
+ pane.add(new JLabel());
+ pane.add(next);
+
+ next.addActionListener(new EventNextKey());
+ addWindowListener(new EventWindows());
+
+ setTitle("Keys modifier");
+ setSize(800, 400);
+// pack();
+ setVisible(true);
+ }
+
+ @Override
+ public void eventChangeFile(File file) {
+ name.setText(file.getName());
+ path.setText(file.getPath());
+ key.setText("");
+ repaint();
+
+ newKeys = new ArrayList<String>();
+ needModifiedFile = false;
+ }
+
+ @Override
+ public void eventNextFile(File file) {
+ if (needModifiedFile) {
+ String content;
+ int region = 0;
+
+ try {
+ content = PluginHelper.readAsString(file, encoding);
+ } catch (IOException e) {
+ throw new ParserException(e);
+ }
+
+ for (Iterator<String> iterator = newKeys.iterator(); iterator.hasNext();) {
+ String oldKey = iterator.next();
+ String realKey = iterator.next();
+ Pattern p = Pattern.compile("(" + patternLeft + ")(" + Pattern.quote(oldKey) + ")(" + patternRight + ")");
+ Matcher matcher = p.matcher(content);
+ matcher.region(region, content.length());
+ matcher.find();
+ region = matcher.start();
+ content = matcher.replaceFirst("$1" + realKey + "$3");
+ }
+
+ try {
+ PluginHelper.writeString(file, content, encoding);
+ } catch (IOException e) {
+ throw new ParserException(e);
+ }
+ }
+ }
+
+ @Override
+ public synchronized void eventChangeKey(String keyI18n, boolean newKey) {
+ key.setText(keyI18n);
+ newKeys.add(key.getText());
+ repaint();
+ if (isVisible() && keyI18n.matches(pattern.getText()) && (!onlyNewKey.isSelected() || newKey)) {
+ try {
+ wait();
+ } catch (InterruptedException e) {
+ throw new ParserException(e);
+ }
+ }
+ }
+
+ @Override
+ public String eventGetRealKey() {
+ newKeys.add(key.getText());
+ needModifiedFile |= !newKeys.get(newKeys.size() - 1).equals(newKeys.get(newKeys.size() - 2));
+ return key.getText();
+ }
+
+ /** Action sur le boutton pour passer � la cl� suivante */
+ class EventNextKey implements ActionListener {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ eventNextKey();
+ }
+ }
+
+ /** Action sur la fermeture de la frame */
+ class EventWindows extends WindowAdapter {
+
+ @Override
+ public void windowClosing(WindowEvent e) {
+ setVisible(false);
+ eventNextKey();
+ }
+ }
+
+ /** Permet de passer à la clé suivante */
+ public synchronized void eventNextKey() {
+ notifyAll();
+ }
+}
Property changes on: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/KeysModifier.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:mergeinfo
+
Added: svn:eol-style
+ native
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/Parser.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/Parser.java 2009-12-28 10:26:01 UTC (rev 1689)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/Parser.java 2009-12-28 10:27:28 UTC (rev 1690)
@@ -1,5 +1,6 @@
/*
- * *##% Plugin maven pour i18n
+ * *##%
+ * I18n :: Maven Plugin
* Copyright (C) 2007 - 2009 CodeLutin
*
* This program is free software: you can redistribute it and/or modify
@@ -14,7 +15,8 @@
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%* */
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%* */
package org.nuiton.i18n.plugin.parser;
@@ -24,7 +26,7 @@
/**
* Interface type pour la définition d'un nouveau parser.
* <p/>
- * Une implantation abstraite est proposée : {@link AbstractI18nParser}.
+ * Une implantation abstraite est proposée : {@link AbstractI18nParserMojo}.
*
* @author julien
*/
@@ -35,14 +37,14 @@
*
* @throws java.io.IOException if any io pb
*/
- public void parse() throws IOException;
+ void parse() throws IOException;
/**
* Parse sur un fichier
*
* @param file le fichier à parser
*/
- public void parseFile(File file);
+ void parseFile(File file);
/**
* Parse une partie du fichier
@@ -50,6 +52,6 @@
* @param file le fichier à parser
* @param args ? TODO
*/
- public void parseLine(File file, String args);
+ void parseLine(File file, String args);
}
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/ParserEvent.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/ParserEvent.java 2009-12-28 10:26:01 UTC (rev 1689)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/ParserEvent.java 2009-12-28 10:27:28 UTC (rev 1690)
@@ -1,5 +1,6 @@
/*
- * *##% Plugin maven pour i18n
+ * *##%
+ * I18n :: Maven Plugin
* Copyright (C) 2007 - 2009 CodeLutin
*
* This program is free software: you can redistribute it and/or modify
@@ -14,7 +15,8 @@
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%* */
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%* */
package org.nuiton.i18n.plugin.parser;
@@ -32,28 +34,28 @@
*
* @param file
*/
- public void eventChangeFile(File file);
+ void eventChangeFile(File file);
/**
* Méthode appelée après le parsing du fichier
*
* @param file
*/
- public void eventNextFile(File file);
+ void eventNextFile(File file);
/**
- * M�thode appelée quand on change de clé
+ * Méthode appelée quand on change de clé
*
* @param keyI18n
* @param newKey
*/
- public void eventChangeKey(String keyI18n, boolean newKey);
+ void eventChangeKey(String keyI18n, boolean newKey);
/**
* Méthode appelée pour récupérer la nouvelle valeur de clé
*
* @return la nouvelle clé
*/
- public String eventGetRealKey();
+ String eventGetRealKey();
}
Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/ParserException.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/ParserException.java 2009-12-28 10:26:01 UTC (rev 1689)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/ParserException.java 2009-12-28 10:27:28 UTC (rev 1690)
@@ -1,5 +1,6 @@
/*
- * *##% Plugin maven pour i18n
+ * *##%
+ * I18n :: Maven Plugin
* Copyright (C) 2007 - 2009 CodeLutin
*
* This program is free software: you can redistribute it and/or modify
@@ -14,7 +15,8 @@
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%* */
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%* */
package org.nuiton.i18n.plugin.parser;
Deleted: 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-12-28 10:26:01 UTC (rev 1689)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJava.java 2009-12-28 10:27:28 UTC (rev 1690)
@@ -1,160 +0,0 @@
-/*
- * *##% Plugin maven pour i18n
- * Copyright (C) 2007 - 2009 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%* */
-
-package org.nuiton.i18n.plugin.parser.impl;
-
-import org.apache.maven.project.MavenProject;
-import org.nuiton.i18n.plugin.SourceEntry;
-import org.nuiton.i18n.plugin.parser.AbstractI18nParser;
-import org.nuiton.i18n.plugin.parser.ParserEvent;
-import org.nuiton.i18n.plugin.parser.ParserException;
-import org.nuiton.io.FileUpdater;
-import org.nuiton.io.FileUpdaterHelper;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.InputStreamReader;
-import java.io.LineNumberReader;
-import org.nuiton.processor.filters.I18nFilter;
-
-/**
- * Récupération des chaine a traduire depuis les fichiers java.
- *
- * @author julien
- * @goal parserJava
- * @phase generate-resources
- */
-public class ParserJava extends AbstractI18nParser {
-
- /**
- * Source entries (src+includes+excludes) .
- *
- * @parameter expression="${i18n.defaultIncludes}" default-value="**\/*.java"
- */
- protected String defaultIncludes;
-
- /**
- * default src for an entry.
- *
- * @parameter expression="${i18n.defaultBasedir}" default-value="${basedir}/src/main/java"
- */
- protected File defaultBasedir;
-
- /**
- * Dependance du projet.
- *
- * @parameter default-value="${project}"
- * @readonly
- */
- protected MavenProject project;
-
- /**
- * Repertoire sources des fichiers i18n.
- *
- * @parameter expression="${i18n.cp}" default-value="${basedir}/target/classes"
- * @required
- */
- protected File cp;
-
- @Override
- public String[] getDefaultIncludes() {
- return new String[]{defaultIncludes};
- }
-
- @Override
- public String[] getDefaultExcludes() {
- return new String[]{};
- }
-
- @Override
- public File getDefaultBasedir() {
- return defaultBasedir;
- }
-
- @Override
- public FileUpdater newFileUpdater(SourceEntry entry) {
- return FileUpdaterHelper.newJavaFileUpdater(entry.getBasedir(), cp);
- }
-
- @Override
- protected String getKeyModifierStart() {
- return "_\\(\\s*\"";
- }
-
- @Override
- protected String getKeyModifierEnd() {
- return "\"\\s*(\\)|,|\\+|$)";
- }
-
- @Override
- protected String getOutGetter() {
- return "java.getter";
- }
-
- protected I18nFilter filter;
-
- @Override
- public void init() {
- super.init();
- filter = new I18nFilter();
- }
-
- @Override
- public void parseFile(File srcFile) {
- LineNumberReader lnr=null;
- String line=null;
- try {
- lnr = new LineNumberReader(new InputStreamReader(new FileInputStream(srcFile)));
-
- while (lnr.ready()) {
- line = lnr.readLine();
- parseLine(srcFile, line);
- }
-
- } catch (Exception e) {
- if (line!=null) {
- getLog().error("could not parse line "+line);
- }
- throw new ParserException(e);
- }
- }
-
- @Override
- public void parseLine(File srcFile, String line) {
- String keysSet = filter.parse(line);
-
- if (!keysSet.equals(I18nFilter.EMPTY_STRING)) {
- touchFile = true;
- // Found a set of i18n Strings, split it.
- String[] keys = keysSet.split("=");
- for (String key : keys) {
- String keyModified = key;
- for (ParserEvent event : events) {
- event.eventChangeKey(key, !oldLanguage.containsKey(key));
- keyModified = event.eventGetRealKey();
- }
- if (oldParser.containsKey(key)) {
- result.put(keyModified, oldParser.get(key));
- } else {
- result.put(keyModified, key);
- }
- }
- }
- }
-
-}
Deleted: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJavaActionConfig.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJavaActionConfig.java 2009-12-28 10:26:01 UTC (rev 1689)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJavaActionConfig.java 2009-12-28 10:27:28 UTC (rev 1690)
@@ -1,78 +0,0 @@
-/*
-* *##% Plugin maven pour i18n
- * Copyright (C) 2007 - 2009 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%* */
-package org.nuiton.i18n.plugin.parser.impl;
-
-import org.nuiton.i18n.plugin.parser.ParserEvent;
-
-import java.io.File;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * Un parseur java pour scanner les annotations ActionConfig
- *
- * @author chemit
- * @goal parserJavaActionConfig
- * @phase generate-resources
- */
-public class ParserJavaActionConfig extends ParserJava {
-
- protected static final Pattern MATCH_PATTERN = Pattern.compile("(name|shortDescription|longDescription|name2|shortDescription2|longDescription2)\\s*=\\s*\"([\\w|\\.]+)\"(|\\s*|\\s*,\\s*$)");
-
- @Override
- protected String getKeyModifierStart() {
- return "[\\w|\\.]+\\s*=\\s*\"";
- }
-
- @Override
- protected String getKeyModifierEnd() {
- return "\"\\s*(\\)|,|\\+|$)";
- }
-
- @Override
- protected String getOutGetter() {
- return "java-action-config.getter";
- }
-
- public String extract(String i18nString) {
- Matcher matcher = MATCH_PATTERN.matcher(i18nString.trim());
- if (matcher.matches()) {
- return matcher.group(2);
- }
- return null;
- }
-
- @Override
- public void parseLine(File srcFile, String line) {
- String key = extract(line);
- if (key != null) {
- touchFile = true;
- String keyModified = key;
- for (ParserEvent event : events) {
- event.eventChangeKey(key, !oldLanguage.containsKey(key));
- keyModified = event.eventGetRealKey();
- }
- if (oldParser.containsKey(key)) {
- result.put(keyModified, oldParser.get(key));
- } else {
- result.put(keyModified, key);
- }
- }
- }
-
-}
Copied: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJavaActionConfigMojo.java (from rev 1687, trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJavaActionConfig.java)
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJavaActionConfigMojo.java (rev 0)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJavaActionConfigMojo.java 2009-12-28 10:27:28 UTC (rev 1690)
@@ -0,0 +1,80 @@
+/*
+* *##%
+ * I18n :: Maven Plugin
+ * Copyright (C) 2007 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%* */
+package org.nuiton.i18n.plugin.parser.impl;
+
+import org.nuiton.i18n.plugin.parser.ParserEvent;
+
+import java.io.File;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * Un parseur java pour scanner les annotations ActionConfig
+ *
+ * @author chemit
+ * @goal parserJavaActionConfig
+ * @phase generate-resources
+ */
+public class ParserJavaActionConfigMojo extends ParserJavaMojo {
+
+ protected static final Pattern MATCH_PATTERN = Pattern.compile("(name|shortDescription|longDescription|name2|shortDescription2|longDescription2)\\s*=\\s*\"([\\w|\\.]+)\"(|\\s*|\\s*,\\s*$)");
+
+ @Override
+ protected String getKeyModifierStart() {
+ return "[\\w|\\.]+\\s*=\\s*\"";
+ }
+
+ @Override
+ protected String getKeyModifierEnd() {
+ return "\"\\s*(\\)|,|\\+|$)";
+ }
+
+ @Override
+ protected String getOutGetter() {
+ return "java-action-config.getter";
+ }
+
+ public String extract(String i18nString) {
+ Matcher matcher = MATCH_PATTERN.matcher(i18nString.trim());
+ if (matcher.matches()) {
+ return matcher.group(2);
+ }
+ return null;
+ }
+
+ @Override
+ public void parseLine(File srcFile, String line) {
+ String key = extract(line);
+ if (key != null) {
+ touchFile = true;
+ String keyModified = key;
+ for (ParserEvent event : events) {
+ event.eventChangeKey(key, !oldLanguage.containsKey(key));
+ keyModified = event.eventGetRealKey();
+ }
+ if (oldParser.containsKey(key)) {
+ result.put(keyModified, oldParser.get(key));
+ } else {
+ result.put(keyModified, key);
+ }
+ }
+ }
+
+}
Property changes on: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJavaActionConfigMojo.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:mergeinfo
+
Added: svn:eol-style
+ native
Copied: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJavaMojo.java (from rev 1687, 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/ParserJavaMojo.java (rev 0)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJavaMojo.java 2009-12-28 10:27:28 UTC (rev 1690)
@@ -0,0 +1,162 @@
+/*
+ * *##%
+ * I18n :: Maven Plugin
+ * Copyright (C) 2007 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%* */
+
+package org.nuiton.i18n.plugin.parser.impl;
+
+import org.apache.maven.project.MavenProject;
+import org.nuiton.i18n.plugin.SourceEntry;
+import org.nuiton.i18n.plugin.parser.AbstractI18nParserMojo;
+import org.nuiton.i18n.plugin.parser.ParserEvent;
+import org.nuiton.i18n.plugin.parser.ParserException;
+import org.nuiton.io.FileUpdater;
+import org.nuiton.io.FileUpdaterHelper;
+import org.nuiton.processor.filters.I18nFilter;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStreamReader;
+import java.io.LineNumberReader;
+
+/**
+ * Récupération des chaine a traduire depuis les fichiers java.
+ *
+ * @author julien
+ * @goal parserJava
+ * @phase generate-resources
+ */
+public class ParserJavaMojo extends AbstractI18nParserMojo {
+
+ /**
+ * Source entries (src+includes+excludes) .
+ *
+ * @parameter expression="${i18n.defaultIncludes}" default-value="**\/*.java"
+ */
+ protected String defaultIncludes;
+
+ /**
+ * default src for an entry.
+ *
+ * @parameter expression="${i18n.defaultBasedir}" default-value="${basedir}/src/main/java"
+ */
+ protected File defaultBasedir;
+
+ /**
+ * Dependance du projet.
+ *
+ * @parameter default-value="${project}"
+ * @readonly
+ */
+ protected MavenProject project;
+
+ /**
+ * Repertoire sources des fichiers i18n.
+ *
+ * @parameter expression="${i18n.cp}" default-value="${basedir}/target/classes"
+ * @required
+ */
+ protected File cp;
+
+ @Override
+ public String[] getDefaultIncludes() {
+ return new String[]{defaultIncludes};
+ }
+
+ @Override
+ public String[] getDefaultExcludes() {
+ return new String[]{};
+ }
+
+ @Override
+ public File getDefaultBasedir() {
+ return defaultBasedir;
+ }
+
+ @Override
+ public FileUpdater newFileUpdater(SourceEntry entry) {
+ return FileUpdaterHelper.newJavaFileUpdater(entry.getBasedir(), cp);
+ }
+
+ @Override
+ protected String getKeyModifierStart() {
+ return "_\\(\\s*\"";
+ }
+
+ @Override
+ protected String getKeyModifierEnd() {
+ return "\"\\s*(\\)|,|\\+|$)";
+ }
+
+ @Override
+ protected String getOutGetter() {
+ return "java.getter";
+ }
+
+ protected I18nFilter filter;
+
+ @Override
+ public void init() throws Exception {
+ super.init();
+ filter = new I18nFilter();
+ }
+
+ @Override
+ public void parseFile(File srcFile) {
+ LineNumberReader lnr = null;
+ String line = null;
+ try {
+ lnr = new LineNumberReader(new InputStreamReader(new FileInputStream(srcFile)));
+
+ while (lnr.ready()) {
+ line = lnr.readLine();
+ parseLine(srcFile, line);
+ }
+
+ } catch (Exception e) {
+ if (line != null) {
+ getLog().error("could not parse line " + line);
+ }
+ throw new ParserException(e);
+ }
+ }
+
+ @Override
+ public void parseLine(File srcFile, String line) {
+ String keysSet = filter.parse(line);
+
+ if (!keysSet.equals(I18nFilter.EMPTY_STRING)) {
+ touchFile = true;
+ // Found a set of i18n Strings, split it.
+ String[] keys = keysSet.split("=");
+ for (String key : keys) {
+ String keyModified = key;
+ for (ParserEvent event : events) {
+ event.eventChangeKey(key, !oldLanguage.containsKey(key));
+ keyModified = event.eventGetRealKey();
+ }
+ if (oldParser.containsKey(key)) {
+ result.put(keyModified, oldParser.get(key));
+ } else {
+ result.put(keyModified, key);
+ }
+ }
+ }
+ }
+
+}
Property changes on: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJavaMojo.java
___________________________________________________________________
Added: svn:executable
+ *
Added: svn:keywords
+ Author Date Id Revision
Added: svn:mergeinfo
+
Added: svn:eol-style
+ native
Deleted: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJavaTabConfig.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJavaTabConfig.java 2009-12-28 10:26:01 UTC (rev 1689)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJavaTabConfig.java 2009-12-28 10:27:28 UTC (rev 1690)
@@ -1,35 +0,0 @@
-/**
- * *##% Plugin maven pour i18n
- * Copyright (C) 2007 - 2009 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
- */
-package org.nuiton.i18n.plugin.parser.impl;
-
-/**
- * Un parseur java pour scanner les annotations TabContentConfig.
- *
- * @author chemit
- * @goal parserJavaTabConfig
- * @phase generate-resources
- */
-public class ParserJavaTabConfig extends ParserJavaActionConfig {
-
- @Override
- protected String getOutGetter() {
- return "java-tab-config.getter";
- }
-
-}
Copied: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJavaTabConfigMojo.java (from rev 1687, trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJavaTabConfig.java)
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJavaTabConfigMojo.java (rev 0)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJavaTabConfigMojo.java 2009-12-28 10:27:28 UTC (rev 1690)
@@ -0,0 +1,37 @@
+/**
+ * *##%
+ * I18n :: Maven Plugin
+ * Copyright (C) 2007 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%*
+ */
+package org.nuiton.i18n.plugin.parser.impl;
+
+/**
+ * Un parseur java pour scanner les annotations TabContentConfig.
+ *
+ * @author chemit
+ * @goal parserJavaTabConfig
+ * @phase generate-resources
+ */
+public class ParserJavaTabConfigMojo extends ParserJavaActionConfigMojo {
+
+ @Override
+ protected String getOutGetter() {
+ return "java-tab-config.getter";
+ }
+
+}
Property changes on: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJavaTabConfigMojo.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:mergeinfo
+
Added: svn:eol-style
+ native
Deleted: 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-12-28 10:26:01 UTC (rev 1689)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJaxx.java 2009-12-28 10:27:28 UTC (rev 1690)
@@ -1,109 +0,0 @@
-/*
- * *##% Plugin maven pour i18n
- * Copyright (C) 2007 - 2009 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%* */
-
-package org.nuiton.i18n.plugin.parser.impl;
-
-import org.nuiton.i18n.plugin.SourceEntry;
-import org.nuiton.io.FileUpdater;
-import org.nuiton.io.FileUpdaterHelper;
-
-import java.io.File;
-
-/**
- * Récupération des chaine à traduire depuis les fichiers xml Jaxx.
- *
- * @author julien
- * @goal parserJaxx
- * @phase generate-resources
- * @deprecated since 1.0.0, prefer use the java parser since xml parser can not
- * be easly extendable
- */
-@Deprecated
-public class ParserJaxx extends ParserXml {
-
- /**
- * Source entries (src+includes+excludes) .
- *
- * @parameter expression="${i18n.defaultIncludes}" default-value="**\/*.jaxx"
- */
- protected String defaultIncludes;
-
- /**
- * Where jaxx files should have been generated.
- *
- * @parameter expression="${i18n.defaultGenerateBasedir}" default-value="${basedir}/target/generated-sources/java"
- */
- protected File defaultGenerateBasedir;
-
- /**
- * Regles xml.
- *
- * @parameter expression="${i18n.rulesJaxx}" default-value="jaxx.rules"
- */
- protected String rulesJaxx;
-
- @Override
- public String[] getDefaultIncludes() {
- return new String[]{defaultIncludes};
- }
-
- @Override
- public String[] getDefaultExcludes() {
- return new String[]{};
- }
-
- @Override
- public FileUpdater newFileUpdater(SourceEntry entry) {
- return FileUpdaterHelper.newJavaFileUpdater(entry.getBasedir(), defaultGenerateBasedir);
- }
-
- @Override
- protected String getOutGetter() {
- return "jaxx.getter";
- }
-
- @Override
- protected String getKeyModifierStart() {
- return "=\\s*[\"\']";
- }
-
- @Override
- protected String getKeyModifierEnd() {
- return "[\"\']";
- }
-
- @Override
- protected String getFileRules() {
- return rulesJaxx;
- }
-
- @Override
- protected String getCoreFileRules() {
- return "jaxx.rules";
- }
-
- public void setRulesJaxx(String rulesJaxx) {
- this.rulesJaxx = rulesJaxx;
- }
-
- @Override
- public String extract(String i18nString) {
- return i18nString.length() == 0 ? null : i18nString;
- }
-
-}
Copied: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJaxxMojo.java (from rev 1687, 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/ParserJaxxMojo.java (rev 0)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJaxxMojo.java 2009-12-28 10:27:28 UTC (rev 1690)
@@ -0,0 +1,111 @@
+/*
+ * *##%
+ * I18n :: Maven Plugin
+ * Copyright (C) 2007 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%* */
+
+package org.nuiton.i18n.plugin.parser.impl;
+
+import org.nuiton.i18n.plugin.SourceEntry;
+import org.nuiton.io.FileUpdater;
+import org.nuiton.io.FileUpdaterHelper;
+
+import java.io.File;
+
+/**
+ * Récupération des chaine à traduire depuis les fichiers xml Jaxx.
+ *
+ * @author julien
+ * @goal parserJaxx
+ * @phase generate-resources
+ * @deprecated since 1.0.0, prefer use the java parser since xml parser can not
+ * be easly extendable
+ */
+@Deprecated
+public class ParserJaxxMojo extends ParserXmlMojo {
+
+ /**
+ * Source entries (src+includes+excludes) .
+ *
+ * @parameter expression="${i18n.defaultIncludes}" default-value="**\/*.jaxx"
+ */
+ protected String defaultIncludes;
+
+ /**
+ * Where jaxx files should have been generated.
+ *
+ * @parameter expression="${i18n.defaultGenerateBasedir}" default-value="${basedir}/target/generated-sources/java"
+ */
+ protected File defaultGenerateBasedir;
+
+ /**
+ * Regles xml.
+ *
+ * @parameter expression="${i18n.rulesJaxx}" default-value="jaxx.rules"
+ */
+ protected String rulesJaxx;
+
+ @Override
+ public String[] getDefaultIncludes() {
+ return new String[]{defaultIncludes};
+ }
+
+ @Override
+ public String[] getDefaultExcludes() {
+ return new String[]{};
+ }
+
+ @Override
+ public FileUpdater newFileUpdater(SourceEntry entry) {
+ return FileUpdaterHelper.newJavaFileUpdater(entry.getBasedir(), defaultGenerateBasedir);
+ }
+
+ @Override
+ protected String getOutGetter() {
+ return "jaxx.getter";
+ }
+
+ @Override
+ protected String getKeyModifierStart() {
+ return "=\\s*[\"\']";
+ }
+
+ @Override
+ protected String getKeyModifierEnd() {
+ return "[\"\']";
+ }
+
+ @Override
+ protected String getFileRules() {
+ return rulesJaxx;
+ }
+
+ @Override
+ protected String getCoreFileRules() {
+ return "jaxx.rules";
+ }
+
+ public void setRulesJaxx(String rulesJaxx) {
+ this.rulesJaxx = rulesJaxx;
+ }
+
+ @Override
+ public String extract(String i18nString) {
+ return i18nString.length() == 0 ? null : i18nString;
+ }
+
+}
Property changes on: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJaxxMojo.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:mergeinfo
+
Added: svn:eol-style
+ native
Deleted: 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-12-28 10:26:01 UTC (rev 1689)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserSwixat.java 2009-12-28 10:27:28 UTC (rev 1690)
@@ -1,100 +0,0 @@
-/*
- * *##% Plugin maven pour i18n
- * Copyright (C) 2007 - 2009 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%* */
-
-package org.nuiton.i18n.plugin.parser.impl;
-
-import org.nuiton.i18n.plugin.SourceEntry;
-import org.nuiton.io.FileUpdater;
-
-/**
- * Recuperation des chaines à traduire depuis les fichiers xml Swixat.
- *
- * @author julien
- * @goal parserSwixat
- * @phase generate-resources
- * @deprecated since 1.0.0 : swixat is dead...
- */
-@Deprecated
-public class ParserSwixat extends ParserXml {
-
- /**
- * Source entries (src+includes) .
- *
- * @parameter expression="${i18n.defaultIncludes}" default-value="**\/*.xml"
- */
- protected String defaultIncludes;
-
- /**
- * Source entries (src+excludes) .
- *
- * @parameter expression="${i18n.defaultIncludes}" default-value="**\/context.xml"
- */
- protected String defaultExcludes;
-
- /**
- * Regles xml.
- *
- * @parameter expression="${i18n.rulesSwixat}" default-value="swixat.rules"
- */
- protected String rulesSwixat;
-
- @Override
- public String[] getDefaultIncludes() {
- return new String[]{defaultIncludes};
- }
-
- @Override
- public String[] getDefaultExcludes() {
- return new String[]{defaultExcludes};
- }
-
- @Override
- public FileUpdater newFileUpdater(SourceEntry entry) {
- return null;
- }
-
- @Override
- protected String getKeyModifierStart() {
- return "=\\s*[\"\']";
- }
-
- @Override
- protected String getKeyModifierEnd() {
- return "[\"\']";
- }
-
- @Override
- protected String getOutGetter() {
- return "swixat.getter";
- }
-
- @Override
- protected String getFileRules() {
- return rulesSwixat;
- }
-
- @Override
- protected String getCoreFileRules() {
- return "swixat.rules";
- }
-
- @Override
- public String extract(String i18nString) {
- return i18nString;
- }
-}
Copied: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserSwixatMojo.java (from rev 1687, 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/ParserSwixatMojo.java (rev 0)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserSwixatMojo.java 2009-12-28 10:27:28 UTC (rev 1690)
@@ -0,0 +1,102 @@
+/*
+ * *##%
+ * I18n :: Maven Plugin
+ * Copyright (C) 2007 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%* */
+
+package org.nuiton.i18n.plugin.parser.impl;
+
+import org.nuiton.i18n.plugin.SourceEntry;
+import org.nuiton.io.FileUpdater;
+
+/**
+ * Recuperation des chaines à traduire depuis les fichiers xml Swixat.
+ *
+ * @author julien
+ * @goal parserSwixat
+ * @phase generate-resources
+ * @deprecated since 1.0.0 : swixat is dead...
+ */
+@Deprecated
+public class ParserSwixatMojo extends ParserXmlMojo {
+
+ /**
+ * Source entries (src+includes) .
+ *
+ * @parameter expression="${i18n.defaultIncludes}" default-value="**\/*.xml"
+ */
+ protected String defaultIncludes;
+
+ /**
+ * Source entries (src+excludes) .
+ *
+ * @parameter expression="${i18n.defaultIncludes}" default-value="**\/context.xml"
+ */
+ protected String defaultExcludes;
+
+ /**
+ * Regles xml.
+ *
+ * @parameter expression="${i18n.rulesSwixat}" default-value="swixat.rules"
+ */
+ protected String rulesSwixat;
+
+ @Override
+ public String[] getDefaultIncludes() {
+ return new String[]{defaultIncludes};
+ }
+
+ @Override
+ public String[] getDefaultExcludes() {
+ return new String[]{defaultExcludes};
+ }
+
+ @Override
+ public FileUpdater newFileUpdater(SourceEntry entry) {
+ return null;
+ }
+
+ @Override
+ protected String getKeyModifierStart() {
+ return "=\\s*[\"\']";
+ }
+
+ @Override
+ protected String getKeyModifierEnd() {
+ return "[\"\']";
+ }
+
+ @Override
+ protected String getOutGetter() {
+ return "swixat.getter";
+ }
+
+ @Override
+ protected String getFileRules() {
+ return rulesSwixat;
+ }
+
+ @Override
+ protected String getCoreFileRules() {
+ return "swixat.rules";
+ }
+
+ @Override
+ public String extract(String i18nString) {
+ return i18nString;
+ }
+}
Property changes on: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserSwixatMojo.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:mergeinfo
+
Added: svn:eol-style
+ native
Deleted: 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-12-28 10:26:01 UTC (rev 1689)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserValidation.java 2009-12-28 10:27:28 UTC (rev 1690)
@@ -1,194 +0,0 @@
-/*
- * *##% Plugin maven pour i18n
- * Copyright (C) 2007 - 2009 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%* */
-package org.nuiton.i18n.plugin.parser.impl;
-
-import java.io.IOException;
-import java.net.URLConnection;
-import org.nuiton.i18n.plugin.SourceEntry;
-import org.nuiton.io.FileUpdater;
-import org.nuiton.io.MirroredFileUpdater;
-
-import java.io.File;
-import java.net.SocketTimeoutException;
-import java.net.URL;
-import org.xml.sax.EntityResolver;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-
-/**
- * Récupération des chaine à traduire depuis les fichiers xml de validation.
- * <p/>
- * Le goal doit etre execute avant que les resources soient copiees dans target/classes
- * pour rendre operatne le file updater (sinon lesfichiers sont toujours a jour...)
- *
- * @author chemit
- * @goal parserValidation
- * @phase generate-resources
- */
-public class ParserValidation extends ParserXml {
-
- public static final String XWORK_PUBLIC_ID = "-//OpenSymphony Group//XWork Validator 1.0.2//EN";
- final URL xworksResource = getClass().getResource("/xwork-validator-1.0.2.dtd");
- /**
- * Source entries (src+includes+excludes) .
- *
- * @parameter expression="${i18n.defaultIncludes}" default-value="**\/**-validation.xml"
- */
- protected String defaultIncludes;
- /**
- * Where jaxx files should have been generated.
- *
- * @parameter expression="${i18n.cp}" default-value="${basedir}/target/classes"
- */
- protected File cp;
- /**
- * Regles xml.
- *
- * @parameter expression="${i18n.rulesValidation}" default-value="validation.rules"
- */
- protected String rulesValidation;
- /**
- * default src for an entry.
- *
- * @parameter expression="${i18n.defaultBasedir}" default-value="${basedir}/src/main/resources"
- * @required
- */
- protected File defaultBasedir;
- /**
- * Always use the local xowrks dtd to increase performance.
- *
- * @parameter expression="${i18n.useLocalResolver}" default-value="true"
- * @since 1.6.0
- */
- protected boolean useLocalResolver;
-
- @Override
- public String[] getDefaultIncludes() {
- return new String[]{defaultIncludes};
- }
-
- @Override
- public String[] getDefaultExcludes() {
- return new String[]{};
- }
-
- @Override
- public File getDefaultBasedir() {
- return defaultBasedir;
- }
-
- @Override
- public FileUpdater newFileUpdater(SourceEntry entry) {
- return new MirroredFileUpdater("", "", entry.getBasedir(), this.cp) {
-
- @Override
- public File getMirrorFile(File f) {
- String file = f.getAbsolutePath().substring(this.prefixSourceDirecotory);
- return new File(this.destinationDirectory + File.separator + file);
- }
- };
- }
-
- @Override
- protected String getOutGetter() {
- return "validation.getter";
- }
-
- @Override
- protected String getKeyModifierStart() {
- return "=\\s*[\"\']";
- }
-
- @Override
- protected String getKeyModifierEnd() {
- return "[\"\']";
- }
-
- @Override
- protected String getFileRules() {
- return rulesValidation;
- }
-
- @Override
- protected String getCoreFileRules() {
- return "validation.rules";
- }
-
-// public void setRulesJaxx(String rulesJaxx) {
-// this.rulesValidation = rulesJaxx;
-// }
-
- @Override
- public String extract(String i18nString) {
- String s = null;
- if (!i18nString.trim().isEmpty()) {
- s = i18nString.trim();
- int end = s.indexOf("##");
- if (end > 0) {
- // remove params from key
- s = s.substring(0, end);
- }
- }
- if (getLog().isDebugEnabled()) {
- getLog().debug(i18nString + " = " + s);
- }
- return s;
- }
-
- @Override
- public EntityResolver getEntityResolver() {
-
- return new EntityResolver() {
-
- public static final String XWORK_PUBLIC_ID = "-//OpenSymphony Group//XWork Validator 1.0.2//EN";
- boolean useLocal = useLocalResolver;
-
- @Override
- public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
- if (getLog().isDebugEnabled()) {
- getLog().debug("publicID:" + publicId + ", systemId:" + systemId);
- }
- if (XWORK_PUBLIC_ID.equals(publicId)) {
- if (!useLocal) {
- URL uri = new URL(systemId);
- if (verbose) {
- getLog().info("try to connect to " + uri);
- }
- URLConnection openConnection = uri.openConnection();
- openConnection.setUseCaches(true);
- openConnection.setConnectTimeout(1000);
- try {
- openConnection.connect();
- return new InputSource(openConnection.getInputStream());
- } catch (SocketTimeoutException e) {
- useLocal = true;
- } catch (IOException e) {
- useLocal = true;
- }
- }
-
- // use directly local resource
- InputSource inputSource = new InputSource(xworksResource.openStream());
- return inputSource;
- }
- // use the default behaviour
- return null;
- }
- };
- }
-}
Copied: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserValidationMojo.java (from rev 1687, 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/ParserValidationMojo.java (rev 0)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserValidationMojo.java 2009-12-28 10:27:28 UTC (rev 1690)
@@ -0,0 +1,191 @@
+/*
+ * *##%
+ * I18n :: Maven Plugin
+ * Copyright (C) 2007 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%* */
+package org.nuiton.i18n.plugin.parser.impl;
+
+import org.nuiton.i18n.plugin.SourceEntry;
+import org.nuiton.io.FileUpdater;
+import org.nuiton.io.MirroredFileUpdater;
+import org.xml.sax.EntityResolver;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.SocketTimeoutException;
+import java.net.URL;
+import java.net.URLConnection;
+
+/**
+ * Récupération des chaine à traduire depuis les fichiers xml de validation.
+ * <p/>
+ * Le goal doit etre execute avant que les resources soient copiees dans target/classes
+ * pour rendre operatne le file updater (sinon lesfichiers sont toujours a jour...)
+ *
+ * @author chemit
+ * @goal parserValidation
+ * @phase generate-resources
+ */
+public class ParserValidationMojo extends ParserXmlMojo {
+
+ final URL xworksResource = getClass().getResource("/xwork-validator-1.0.2.dtd");
+ /**
+ * Source entries (src+includes+excludes) .
+ *
+ * @parameter expression="${i18n.defaultIncludes}" default-value="**\/**-validation.xml"
+ */
+ protected String defaultIncludes;
+ /**
+ * Where jaxx files should have been generated.
+ *
+ * @parameter expression="${i18n.cp}" default-value="${basedir}/target/classes"
+ */
+ protected File cp;
+ /**
+ * Regles xml.
+ *
+ * @parameter expression="${i18n.rulesValidation}" default-value="validation.rules"
+ */
+ protected String rulesValidation;
+ /**
+ * default src for an entry.
+ *
+ * @parameter expression="${i18n.defaultBasedir}" default-value="${basedir}/src/main/resources"
+ * @required
+ */
+ protected File defaultBasedir;
+ /**
+ * Always use the local xowrks dtd to increase performance.
+ *
+ * @parameter expression="${i18n.useLocalResolver}" default-value="true"
+ * @since 1.6.0
+ */
+ protected boolean useLocalResolver;
+
+ @Override
+ public String[] getDefaultIncludes() {
+ return new String[]{defaultIncludes};
+ }
+
+ @Override
+ public String[] getDefaultExcludes() {
+ return new String[]{};
+ }
+
+ @Override
+ public File getDefaultBasedir() {
+ return defaultBasedir;
+ }
+
+ @Override
+ public FileUpdater newFileUpdater(SourceEntry entry) {
+ return new MirroredFileUpdater("", "", entry.getBasedir(), this.cp) {
+
+ @Override
+ public File getMirrorFile(File f) {
+ String file = f.getAbsolutePath().substring(this.prefixSourceDirecotory);
+ return new File(this.destinationDirectory + File.separator + file);
+ }
+ };
+ }
+
+ @Override
+ protected String getOutGetter() {
+ return "validation.getter";
+ }
+
+ @Override
+ protected String getKeyModifierStart() {
+ return "=\\s*[\"\']";
+ }
+
+ @Override
+ protected String getKeyModifierEnd() {
+ return "[\"\']";
+ }
+
+ @Override
+ protected String getFileRules() {
+ return rulesValidation;
+ }
+
+ @Override
+ protected String getCoreFileRules() {
+ return "validation.rules";
+ }
+
+ @Override
+ public String extract(String i18nString) {
+ String s = null;
+ if (!i18nString.trim().isEmpty()) {
+ s = i18nString.trim();
+ int end = s.indexOf("##");
+ if (end > 0) {
+ // remove params from key
+ s = s.substring(0, end);
+ }
+ }
+ if (getLog().isDebugEnabled()) {
+ getLog().debug(i18nString + " = " + s);
+ }
+ return s;
+ }
+
+ @Override
+ public EntityResolver getEntityResolver() {
+
+ return new EntityResolver() {
+
+ public static final String XWORK_PUBLIC_ID = "-//OpenSymphony Group//XWork Validator 1.0.2//EN";
+ boolean useLocal = useLocalResolver;
+
+ @Override
+ public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
+ if (getLog().isDebugEnabled()) {
+ getLog().debug("publicID:" + publicId + ", systemId:" + systemId);
+ }
+ if (XWORK_PUBLIC_ID.equals(publicId)) {
+ if (!useLocal) {
+ URL uri = new URL(systemId);
+ if (verbose) {
+ getLog().info("try to connect to " + uri);
+ }
+ URLConnection openConnection = uri.openConnection();
+ openConnection.setUseCaches(true);
+ openConnection.setConnectTimeout(1000);
+ try {
+ openConnection.connect();
+ return new InputSource(openConnection.getInputStream());
+ } catch (SocketTimeoutException e) {
+ useLocal = true;
+ } catch (IOException e) {
+ useLocal = true;
+ }
+ }
+
+ // use directly local resource
+ InputSource inputSource = new InputSource(xworksResource.openStream());
+ return inputSource;
+ }
+ // use the default behaviour
+ return null;
+ }
+ };
+ }
+}
Property changes on: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserValidationMojo.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:mergeinfo
+
Added: svn:eol-style
+ native
Deleted: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserXml.java
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserXml.java 2009-12-28 10:26:01 UTC (rev 1689)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserXml.java 2009-12-28 10:27:28 UTC (rev 1690)
@@ -1,255 +0,0 @@
-/*
- * *##% Plugin maven pour i18n
- * Copyright (C) 2007 - 2009 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%* */
-package org.nuiton.i18n.plugin.parser.impl;
-
-import javax.xml.parsers.ParserConfigurationException;
-import org.nuiton.i18n.plugin.parser.AbstractI18nParser;
-import org.nuiton.i18n.plugin.parser.ParserEvent;
-import org.nuiton.i18n.plugin.parser.ParserException;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.xml.sax.InputSource;
-
-import javax.xml.xpath.XPath;
-import javax.xml.xpath.XPathConstants;
-import javax.xml.xpath.XPathExpression;
-import javax.xml.xpath.XPathFactory;
-import java.io.BufferedInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import org.w3c.dom.Document;
-import org.xml.sax.EntityResolver;
-
-/**
- * Récupération des chaines à traduire depuis les fichiers xml.
- *
- * @author julien
- */
-public abstract class ParserXml extends AbstractI18nParser {
-
- /** Taille du buffer pour les lectures/écritures */
- protected static final int BUFFER_SIZE = 8 * 1024;
- /**
- * default src for an entry.
- *
- * @parameter expression="${i18n.defaultBasedir}" default-value="${basedir}/src/main/uimodel"
- * @required
- */
- protected File defaultBasedir;
- protected String rules;
- protected XPathFactory factory;
- protected XPath xpath;
- protected DocumentBuilder builder;
-
- /**
- * Fonction d'extraction de la chaine
- *
- * @param i18nString le clef i18n
- * @return la chaine
- */
- public abstract String extract(String i18nString);
-
- /** @return le fichier des rules */
- protected abstract String getFileRules();
-
- /** @return le fichier des rules de base à toujours charger */
- protected abstract String getCoreFileRules();
-
- @Override
- public void init() {
- super.init();
- this.factory = XPathFactory.newInstance();
- this.rules = getRules(getFileRules());
- this.xpath = factory.newXPath();
- DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
- documentBuilderFactory.setNamespaceAware(true); // never forget this!
-
- try {
- // never forget this!
- builder = documentBuilderFactory.newDocumentBuilder();
-
- EntityResolver resolver = getEntityResolver();
-
- if (resolver != null) {
- builder.setEntityResolver(resolver);
- }
-
- } catch (ParserConfigurationException ex) {
- throw new IllegalStateException("could not load DocumentBuilder for reason " + ex.getMessage(), ex);
- }
- }
-
- public EntityResolver getEntityResolver() {
- return null;
- }
-
- public InputSource getSystemId(String publicId) {
- return null;
- }
-
- @Override
- public void parseFile(File file) {
- NodeList list;
-// InputSource inputSource = new InputSource(file.getAbsolutePath()); // TODO: A deplacer pour les performances
-
- try {
- int size = result.size();
-
- // Recherche des clés à partir d'un xpath
-
- Document doc = builder.parse(file.getAbsolutePath());
-// Document doc = builder.parse(new FileInputStream(file.getAbsolutePath()),xworksResource.getFile());
- XPathExpression expression = xpath.compile(rules);
- list = (NodeList) expression.evaluate(doc, XPathConstants.NODESET);
-// list = (NodeList) expression.evaluate(inputSource, XPathConstants.NODESET);
-
- for (int index = 0; index < list.getLength(); index++) {
- Node node = list.item(index);
- parseLine(file, node.getTextContent());
- }
- if (safeMode) {
- // Détection de nouvelles clés, sauvegarde du fichier pour pouvoir le restaurer en cas de plantage
- if (size != result.size()) {
- saveGetterFile();
- }
- }
- } catch (Exception e) {
- throw new ParserException(e);
- }
- }
-
- @Override
- public void parseLine(File file, String key) {
- key = extract(key);
- if (key != null) {
- touchFile = true;
- String keyModified = key;
- for (ParserEvent event : events) {
- event.eventChangeKey(key, !oldLanguage.containsKey(key));
- keyModified = event.eventGetRealKey();
- }
-
- if (oldParser.containsKey(key)) {
- result.put(keyModified, oldParser.get(key));
- } else {
- result.put(keyModified, key);
- }
- }
- }
-
- @Override
- public File getDefaultBasedir() {
- return defaultBasedir;
- }
-
- /**
- * Récupère le xpath à partir d'un fichier
- *
- * @param fileRules le nom du fichier contant les règles
- * @return le xpath à partir d'un fichier
- */
- private String getRules(String fileRules) {
- StringBuilder buffer = new StringBuilder();
-
- try {
- String readInputStream;
-
- // load core rules
- readInputStream = loadRulesFile(getCoreFileRules());
- if (!silent && verbose) {
- getLog().info("core rules : " + getCoreFileRules());
- }
- buffer.append(readInputStream);
-
- if (!fileRules.equals(getCoreFileRules())) {
- // add custom rules
- readInputStream = loadRulesFile(fileRules);
- if (!silent && verbose) {
- getLog().info("custom rules : " + fileRules);
- }
- buffer.append(" | ").append(readInputStream);
- }
- } catch (IOException e) {
- throw new ParserException(e);
- }
-
- return buffer.toString();
- }
-
- private String loadRulesFile(String fileRules) throws IOException {
- File f = new File(fileRules);
-
- InputStream inputStream;
- if (f.exists()) {
- // load from a file
- try {
- inputStream = new FileInputStream(f);
- } catch (FileNotFoundException e) {
- throw new ParserException(e);
- }
- } else {
- // load from classpath
- ClassLoader classLoader = getClass().getClassLoader();
- inputStream = classLoader.getResourceAsStream(fileRules);
- }
- if (inputStream == null) {
- throw new ParserException("could not found file of rules : " + fileRules);
- }
-
- inputStream = new BufferedInputStream(inputStream);
-
- try {
- // Lecture
- String readInputStream;
- readInputStream = readInputStream(inputStream);
- return readInputStream;
- } catch (IOException e) {
- throw new ParserException(e);
- } finally {
- inputStream.close();
- }
- }
-
- /**
- * Permet la lecture d'un InputStream et Suppressions.
- *
- * @param in le flux entrant
- * @return le contenu du flux
- * @throws IOException si problème de lecture dans flux entrant
- */
- private String readInputStream(InputStream in) throws IOException {
- StringBuilder sb = new StringBuilder();
- byte[] buffer = new byte[BUFFER_SIZE];
- while (in.read(buffer, 0, BUFFER_SIZE) != -1) {
- String tmp = new String(buffer);
- sb.append(tmp);
- }
- in.close();
- // Suppression
- String txt = sb.toString().trim();
- txt = txt.replaceAll("#.*\n", ""); // suppression des commentaires
- txt = txt.replaceAll("\\s+", " | "); // contruction du xpath avec des ou
- txt = txt.replaceAll("(^ \\| )|( \\| $)", ""); // suppression des ou de début ee fin
- return txt;
- }
-}
Copied: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserXmlMojo.java (from rev 1687, trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserXml.java)
===================================================================
--- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserXmlMojo.java (rev 0)
+++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserXmlMojo.java 2009-12-28 10:27:28 UTC (rev 1690)
@@ -0,0 +1,255 @@
+/*
+ * *##%
+ * I18n :: Maven Plugin
+ * Copyright (C) 2007 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%* */
+package org.nuiton.i18n.plugin.parser.impl;
+
+import org.nuiton.i18n.plugin.parser.AbstractI18nParserMojo;
+import org.nuiton.i18n.plugin.parser.ParserEvent;
+import org.nuiton.i18n.plugin.parser.ParserException;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.EntityResolver;
+import org.xml.sax.InputSource;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathExpression;
+import javax.xml.xpath.XPathFactory;
+import java.io.*;
+
+/**
+ * Récupération des chaines à traduire depuis les fichiers xml.
+ *
+ * @author julien
+ */
+public abstract class ParserXmlMojo extends AbstractI18nParserMojo {
+
+ /**
+ * Taille du buffer pour les lectures/écritures
+ */
+ protected static final int BUFFER_SIZE = 8 * 1024;
+ /**
+ * default src for an entry.
+ *
+ * @parameter expression="${i18n.defaultBasedir}" default-value="${basedir}/src/main/uimodel"
+ * @required
+ */
+ protected File defaultBasedir;
+ protected String rules;
+ protected XPathFactory factory;
+ protected XPath xpath;
+ protected DocumentBuilder builder;
+
+ /**
+ * Fonction d'extraction de la chaine
+ *
+ * @param i18nString le clef i18n
+ * @return la chaine
+ */
+ public abstract String extract(String i18nString);
+
+ /**
+ * @return le fichier des rules
+ */
+ protected abstract String getFileRules();
+
+ /**
+ * @return le fichier des rules de base à toujours charger
+ */
+ protected abstract String getCoreFileRules();
+
+ @Override
+ public void init() throws Exception {
+ super.init();
+ this.factory = XPathFactory.newInstance();
+ this.rules = getRules(getFileRules());
+ this.xpath = factory.newXPath();
+ DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
+ documentBuilderFactory.setNamespaceAware(true); // never forget this!
+
+ try {
+ // never forget this!
+ builder = documentBuilderFactory.newDocumentBuilder();
+
+ EntityResolver resolver = getEntityResolver();
+
+ if (resolver != null) {
+ builder.setEntityResolver(resolver);
+ }
+
+ } catch (ParserConfigurationException ex) {
+ throw new IllegalStateException("could not load DocumentBuilder for reason " + ex.getMessage(), ex);
+ }
+ }
+
+ public EntityResolver getEntityResolver() {
+ return null;
+ }
+
+ public InputSource getSystemId(String publicId) {
+ return null;
+ }
+
+ @Override
+ public void parseFile(File file) {
+ NodeList list;
+
+ try {
+ int size = result.size();
+
+ // Recherche des clés à partir d'un xpath
+
+ Document doc = builder.parse(file.getAbsolutePath());
+ XPathExpression expression = xpath.compile(rules);
+ list = (NodeList) expression.evaluate(doc, XPathConstants.NODESET);
+
+ for (int index = 0; index < list.getLength(); index++) {
+ Node node = list.item(index);
+ parseLine(file, node.getTextContent());
+ }
+ if (safeMode) {
+ // Détection de nouvelles clés, sauvegarde du fichier pour pouvoir le restaurer en cas de plantage
+ if (size != result.size()) {
+ saveGetterFile();
+ }
+ }
+ } catch (Exception e) {
+ throw new ParserException(e);
+ }
+ }
+
+ @Override
+ public void parseLine(File file, String key) {
+ key = extract(key);
+ if (key != null) {
+ touchFile = true;
+ String keyModified = key;
+ for (ParserEvent event : events) {
+ event.eventChangeKey(key, !oldLanguage.containsKey(key));
+ keyModified = event.eventGetRealKey();
+ }
+
+ if (oldParser.containsKey(key)) {
+ result.put(keyModified, oldParser.get(key));
+ } else {
+ result.put(keyModified, key);
+ }
+ }
+ }
+
+ @Override
+ public File getDefaultBasedir() {
+ return defaultBasedir;
+ }
+
+ /**
+ * Récupère le xpath à partir d'un fichier
+ *
+ * @param fileRules le nom du fichier contant les règles
+ * @return le xpath à partir d'un fichier
+ */
+ private String getRules(String fileRules) {
+ StringBuilder buffer = new StringBuilder();
+
+ try {
+ String readInputStream;
+
+ // load core rules
+ readInputStream = loadRulesFile(getCoreFileRules());
+ if (!silent && verbose) {
+ getLog().info("core rules : " + getCoreFileRules());
+ }
+ buffer.append(readInputStream);
+
+ if (!fileRules.equals(getCoreFileRules())) {
+ // add custom rules
+ readInputStream = loadRulesFile(fileRules);
+ if (!silent && verbose) {
+ getLog().info("custom rules : " + fileRules);
+ }
+ buffer.append(" | ").append(readInputStream);
+ }
+ } catch (IOException e) {
+ throw new ParserException(e);
+ }
+
+ return buffer.toString();
+ }
+
+ private String loadRulesFile(String fileRules) throws IOException {
+ File f = new File(fileRules);
+
+ InputStream inputStream;
+ if (f.exists()) {
+ // load from a file
+ try {
+ inputStream = new FileInputStream(f);
+ } catch (FileNotFoundException e) {
+ throw new ParserException(e);
+ }
+ } else {
+ // load from classpath
+ ClassLoader classLoader = getClass().getClassLoader();
+ inputStream = classLoader.getResourceAsStream(fileRules);
+ }
+ if (inputStream == null) {
+ throw new ParserException("could not found file of rules : " + fileRules);
+ }
+
+ inputStream = new BufferedInputStream(inputStream);
+
+ try {
+ // Lecture
+ String readInputStream;
+ readInputStream = readInputStream(inputStream);
+ return readInputStream;
+ } catch (IOException e) {
+ throw new ParserException(e);
+ } finally {
+ inputStream.close();
+ }
+ }
+
+ /**
+ * Permet la lecture d'un InputStream et Suppressions.
+ *
+ * @param in le flux entrant
+ * @return le contenu du flux
+ * @throws IOException si problème de lecture dans flux entrant
+ */
+ private String readInputStream(InputStream in) throws IOException {
+ StringBuilder sb = new StringBuilder();
+ byte[] buffer = new byte[BUFFER_SIZE];
+ while (in.read(buffer, 0, BUFFER_SIZE) != -1) {
+ String tmp = new String(buffer);
+ sb.append(tmp);
+ }
+ in.close();
+ // Suppression
+ String txt = sb.toString().trim();
+ txt = txt.replaceAll("#.*\n", ""); // suppression des commentaires
+ txt = txt.replaceAll("\\s+", " | "); // contruction du xpath avec des ou
+ txt = txt.replaceAll("(^ \\| )|( \\| $)", ""); // suppression des ou de début ee fin
+ return txt;
+ }
+}
Property changes on: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserXmlMojo.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:mergeinfo
+
Added: svn:eol-style
+ native
Modified: trunk/maven-i18n-plugin/src/site/apt/index.apt
===================================================================
--- trunk/maven-i18n-plugin/src/site/apt/index.apt 2009-12-28 10:26:01 UTC (rev 1689)
+++ trunk/maven-i18n-plugin/src/site/apt/index.apt 2009-12-28 10:27:28 UTC (rev 1690)
@@ -29,6 +29,8 @@
* {{{gen-mojo.html} i18n:gen}} generate i18n bundle from getters.
+ * {{{collect-i18n-artifacts-mojo.html} i18n:collect-i18n-artifacts}} collects all i18n resources throught project dependencies and store the location of resources in a file.
+
* {{{bundle-mojo.html} i18n:bundle}} generate unique i18n bundle for final application.
* {{{help-mojo.html} i18n:help}} display help.
Modified: trunk/maven-i18n-plugin/src/site/site_fr.xml
===================================================================
--- trunk/maven-i18n-plugin/src/site/site_fr.xml 2009-12-28 10:26:01 UTC (rev 1689)
+++ trunk/maven-i18n-plugin/src/site/site_fr.xml 2009-12-28 10:27:28 UTC (rev 1690)
@@ -26,6 +26,7 @@
<item name="parserXWorks" href="parserValidation-mojo.html"/>
<item name="get" href="get-mojo.html"/>
<item name="gen" href="gen-mojo.html"/>
+ <item name="collect-i18n-artifacts" href="collect-i18n-artifacts-mojo.html"/>
<item name="bundle" href="bundle-mojo.html"/>
<item name="help" href="help-mojo.html"/>
</item>
1
0
r1689 - in trunk/nuiton-i18n-api/src: main/java/org/nuiton/i18n main/java/org/nuiton/i18n/bundle main/java/org/nuiton/util test/java/org/nuiton/i18n/bundle test/java/org/nuiton/util
by tchemit@users.nuiton.org 28 Dec '09
by tchemit@users.nuiton.org 28 Dec '09
28 Dec '09
Author: tchemit
Date: 2009-12-28 11:26:01 +0100 (Mon, 28 Dec 2009)
New Revision: 1689
Modified:
trunk/nuiton-i18n-api/src/main/java/org/nuiton/i18n/CountryEnum.java
trunk/nuiton-i18n-api/src/main/java/org/nuiton/i18n/I18nDefaultTooltipFilter.java
trunk/nuiton-i18n-api/src/main/java/org/nuiton/i18n/I18nFileReader.java
trunk/nuiton-i18n-api/src/main/java/org/nuiton/i18n/I18nFilter.java
trunk/nuiton-i18n-api/src/main/java/org/nuiton/i18n/I18nUtil.java
trunk/nuiton-i18n-api/src/main/java/org/nuiton/i18n/LanguageEnum.java
trunk/nuiton-i18n-api/src/main/java/org/nuiton/i18n/bundle/I18nBundle.java
trunk/nuiton-i18n-api/src/main/java/org/nuiton/i18n/bundle/I18nBundleEntry.java
trunk/nuiton-i18n-api/src/main/java/org/nuiton/i18n/bundle/I18nBundleFactory.java
trunk/nuiton-i18n-api/src/main/java/org/nuiton/i18n/bundle/I18nBundleScope.java
trunk/nuiton-i18n-api/src/main/java/org/nuiton/util/LocaleConverter.java
trunk/nuiton-i18n-api/src/test/java/org/nuiton/i18n/bundle/I18nBunsleScopeTest.java
trunk/nuiton-i18n-api/src/test/java/org/nuiton/util/LocaleConverterTest.java
Log:
update java license header
Modified: trunk/nuiton-i18n-api/src/main/java/org/nuiton/i18n/CountryEnum.java
===================================================================
--- trunk/nuiton-i18n-api/src/main/java/org/nuiton/i18n/CountryEnum.java 2009-12-28 10:24:27 UTC (rev 1688)
+++ trunk/nuiton-i18n-api/src/main/java/org/nuiton/i18n/CountryEnum.java 2009-12-28 10:26:01 UTC (rev 1689)
@@ -1,6 +1,7 @@
/*
- * *##% Lutin utilities library
- * Copyright (C) 2004 - 2008 CodeLutin
+ * *##%
+ * I18n :: Api
+ * Copyright (C) 2004 - 2009 CodeLutin
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
@@ -14,7 +15,8 @@
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%* */
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%* */
package org.nuiton.i18n;
/**
Modified: trunk/nuiton-i18n-api/src/main/java/org/nuiton/i18n/I18nDefaultTooltipFilter.java
===================================================================
--- trunk/nuiton-i18n-api/src/main/java/org/nuiton/i18n/I18nDefaultTooltipFilter.java 2009-12-28 10:24:27 UTC (rev 1688)
+++ trunk/nuiton-i18n-api/src/main/java/org/nuiton/i18n/I18nDefaultTooltipFilter.java 2009-12-28 10:26:01 UTC (rev 1689)
@@ -1,5 +1,6 @@
-/* *##% Lutin utilities library
- * Copyright (C) 2004 - 2008 CodeLutin
+/* *##%
+ * I18n :: Api
+ * Copyright (C) 2004 - 2009 CodeLutin
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
@@ -13,7 +14,8 @@
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%* */
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%* */
/* *
* i18nDefaultTooltipFilter.java
Modified: trunk/nuiton-i18n-api/src/main/java/org/nuiton/i18n/I18nFileReader.java
===================================================================
--- trunk/nuiton-i18n-api/src/main/java/org/nuiton/i18n/I18nFileReader.java 2009-12-28 10:24:27 UTC (rev 1688)
+++ trunk/nuiton-i18n-api/src/main/java/org/nuiton/i18n/I18nFileReader.java 2009-12-28 10:26:01 UTC (rev 1689)
@@ -1,5 +1,6 @@
-/* *##% Lutin utilities library
- * Copyright (C) 2004 - 2008 CodeLutin
+/* *##%
+ * I18n :: Api
+ * Copyright (C) 2004 - 2009 CodeLutin
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
@@ -13,7 +14,8 @@
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%* */
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%* */
/* *
* I18nFileReader.java
Modified: trunk/nuiton-i18n-api/src/main/java/org/nuiton/i18n/I18nFilter.java
===================================================================
--- trunk/nuiton-i18n-api/src/main/java/org/nuiton/i18n/I18nFilter.java 2009-12-28 10:24:27 UTC (rev 1688)
+++ trunk/nuiton-i18n-api/src/main/java/org/nuiton/i18n/I18nFilter.java 2009-12-28 10:26:01 UTC (rev 1689)
@@ -1,5 +1,6 @@
-/* *##% Lutin utilities library
- * Copyright (C) 2004 - 2008 CodeLutin
+/* *##%
+ * I18n :: Api
+ * Copyright (C) 2004 - 2009 CodeLutin
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
@@ -13,7 +14,8 @@
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%* */
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%* */
/* *
* i18nFilter.java
@@ -32,6 +34,6 @@
public interface I18nFilter { // I18nFilter
- public String applyFilter(String message);
+ String applyFilter(String message);
} // I18nFilter
Modified: trunk/nuiton-i18n-api/src/main/java/org/nuiton/i18n/I18nUtil.java
===================================================================
--- trunk/nuiton-i18n-api/src/main/java/org/nuiton/i18n/I18nUtil.java 2009-12-28 10:24:27 UTC (rev 1688)
+++ trunk/nuiton-i18n-api/src/main/java/org/nuiton/i18n/I18nUtil.java 2009-12-28 10:26:01 UTC (rev 1689)
@@ -1,3 +1,23 @@
+/*
+ * *##%
+ * I18n :: Api
+ * Copyright (C) 2004 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%*
+ */
package org.nuiton.i18n;
import java.io.File;
Modified: trunk/nuiton-i18n-api/src/main/java/org/nuiton/i18n/LanguageEnum.java
===================================================================
--- trunk/nuiton-i18n-api/src/main/java/org/nuiton/i18n/LanguageEnum.java 2009-12-28 10:24:27 UTC (rev 1688)
+++ trunk/nuiton-i18n-api/src/main/java/org/nuiton/i18n/LanguageEnum.java 2009-12-28 10:26:01 UTC (rev 1689)
@@ -1,6 +1,7 @@
/*
- * *##% Lutin utilities library
- * Copyright (C) 2004 - 2008 CodeLutin
+ * *##%
+ * I18n :: Api
+ * Copyright (C) 2004 - 2009 CodeLutin
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
@@ -14,7 +15,8 @@
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%* */
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%* */
package org.nuiton.i18n;
/**
Modified: trunk/nuiton-i18n-api/src/main/java/org/nuiton/i18n/bundle/I18nBundle.java
===================================================================
--- trunk/nuiton-i18n-api/src/main/java/org/nuiton/i18n/bundle/I18nBundle.java 2009-12-28 10:24:27 UTC (rev 1688)
+++ trunk/nuiton-i18n-api/src/main/java/org/nuiton/i18n/bundle/I18nBundle.java 2009-12-28 10:26:01 UTC (rev 1689)
@@ -1,6 +1,7 @@
/*
-* *##% Lutin utilities library
- * Copyright (C) 2004 - 2008 CodeLutin
+* *##%
+ * I18n :: Api
+ * Copyright (C) 2004 - 2009 CodeLutin
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
@@ -14,7 +15,8 @@
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%* */
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%* */
package org.nuiton.i18n.bundle;
import java.util.Iterator;
Modified: trunk/nuiton-i18n-api/src/main/java/org/nuiton/i18n/bundle/I18nBundleEntry.java
===================================================================
--- trunk/nuiton-i18n-api/src/main/java/org/nuiton/i18n/bundle/I18nBundleEntry.java 2009-12-28 10:24:27 UTC (rev 1688)
+++ trunk/nuiton-i18n-api/src/main/java/org/nuiton/i18n/bundle/I18nBundleEntry.java 2009-12-28 10:26:01 UTC (rev 1689)
@@ -1,6 +1,7 @@
/*
- * *##% Lutin utilities library
- * Copyright (C) 2004 - 2008 CodeLutin
+ * *##%
+ * I18n :: Api
+ * Copyright (C) 2004 - 2009 CodeLutin
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
@@ -14,7 +15,8 @@
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%* */
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%* */
package org.nuiton.i18n.bundle;
import java.io.IOException;
Modified: trunk/nuiton-i18n-api/src/main/java/org/nuiton/i18n/bundle/I18nBundleFactory.java
===================================================================
--- trunk/nuiton-i18n-api/src/main/java/org/nuiton/i18n/bundle/I18nBundleFactory.java 2009-12-28 10:24:27 UTC (rev 1688)
+++ trunk/nuiton-i18n-api/src/main/java/org/nuiton/i18n/bundle/I18nBundleFactory.java 2009-12-28 10:26:01 UTC (rev 1689)
@@ -1,3 +1,23 @@
+/*
+ * *##%
+ * I18n :: Api
+ * Copyright (C) 2004 - 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%*
+ */
package org.nuiton.i18n.bundle;
import java.io.File;
Modified: trunk/nuiton-i18n-api/src/main/java/org/nuiton/i18n/bundle/I18nBundleScope.java
===================================================================
--- trunk/nuiton-i18n-api/src/main/java/org/nuiton/i18n/bundle/I18nBundleScope.java 2009-12-28 10:24:27 UTC (rev 1688)
+++ trunk/nuiton-i18n-api/src/main/java/org/nuiton/i18n/bundle/I18nBundleScope.java 2009-12-28 10:26:01 UTC (rev 1689)
@@ -1,6 +1,7 @@
/*
-* *##% Lutin utilities library
- * Copyright (C) 2004 - 2008 CodeLutin
+* *##%
+ * I18n :: Api
+ * Copyright (C) 2004 - 2009 CodeLutin
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
@@ -14,7 +15,8 @@
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%* */
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%* */
package org.nuiton.i18n.bundle;
import java.util.Locale;
Modified: trunk/nuiton-i18n-api/src/main/java/org/nuiton/util/LocaleConverter.java
===================================================================
--- trunk/nuiton-i18n-api/src/main/java/org/nuiton/util/LocaleConverter.java 2009-12-28 10:24:27 UTC (rev 1688)
+++ trunk/nuiton-i18n-api/src/main/java/org/nuiton/util/LocaleConverter.java 2009-12-28 10:26:01 UTC (rev 1689)
@@ -1,5 +1,6 @@
/*
- * *##% Lutin utilities library
+ * *##%
+ * I18n :: Api
* Copyright (C) 2004 - 2009 CodeLutin
*
* This program is free software: you can redistribute it and/or modify
@@ -14,7 +15,8 @@
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%* */
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%* */
package org.nuiton.util;
Modified: trunk/nuiton-i18n-api/src/test/java/org/nuiton/i18n/bundle/I18nBunsleScopeTest.java
===================================================================
--- trunk/nuiton-i18n-api/src/test/java/org/nuiton/i18n/bundle/I18nBunsleScopeTest.java 2009-12-28 10:24:27 UTC (rev 1688)
+++ trunk/nuiton-i18n-api/src/test/java/org/nuiton/i18n/bundle/I18nBunsleScopeTest.java 2009-12-28 10:26:01 UTC (rev 1689)
@@ -1,6 +1,7 @@
/**
- * *##% Lutin utilities library
- * Copyright (C) 2004 - 2008 CodeLutin
+ * *##%
+ * I18n :: Api
+ * Copyright (C) 2004 - 2009 CodeLutin
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
@@ -14,7 +15,8 @@
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%*
*/
package org.nuiton.i18n.bundle;
Modified: trunk/nuiton-i18n-api/src/test/java/org/nuiton/util/LocaleConverterTest.java
===================================================================
--- trunk/nuiton-i18n-api/src/test/java/org/nuiton/util/LocaleConverterTest.java 2009-12-28 10:24:27 UTC (rev 1688)
+++ trunk/nuiton-i18n-api/src/test/java/org/nuiton/util/LocaleConverterTest.java 2009-12-28 10:26:01 UTC (rev 1689)
@@ -1,6 +1,7 @@
/**
- * *##% Lutin utilities library
- * Copyright (C) 2004 - 2008 CodeLutin
+ * *##%
+ * I18n :: Api
+ * Copyright (C) 2004 - 2009 CodeLutin
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
@@ -14,7 +15,8 @@
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * ##%*
*/
package org.nuiton.util;
1
0
Author: tchemit
Date: 2009-12-28 11:24:27 +0100 (Mon, 28 Dec 2009)
New Revision: 1688
Modified:
trunk/pom.xml
Log:
using snpashot of mavenpom
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2009-12-18 13:34:07 UTC (rev 1687)
+++ trunk/pom.xml 2009-12-28 10:24:27 UTC (rev 1688)
@@ -10,7 +10,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>mavenpom</artifactId>
- <version>1.1.3</version>
+ <version>1.1.4-SNAPSHOT</version>
</parent>
<artifactId>i18n</artifactId>
1
0
Author: tchemit
Date: 2009-12-18 14:34:07 +0100 (Fri, 18 Dec 2009)
New Revision: 1687
Modified:
trunk/pom.xml
Log:
use mavenpom 1.1.3
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2009-12-09 10:39:02 UTC (rev 1686)
+++ trunk/pom.xml 2009-12-18 13:34:07 UTC (rev 1687)
@@ -10,7 +10,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>mavenpom</artifactId>
- <version>1.1.1</version>
+ <version>1.1.3</version>
</parent>
<artifactId>i18n</artifactId>
1
0
09 Dec '09
Author: tchemit
Date: 2009-12-09 11:39:02 +0100 (Wed, 09 Dec 2009)
New Revision: 1686
Modified:
trunk/maven-i18n-plugin/pom.xml
trunk/nuiton-i18n-api/pom.xml
trunk/pom.xml
Log:
Change module names, use a convention of " :: " for a module
Modified: trunk/maven-i18n-plugin/pom.xml
===================================================================
--- trunk/maven-i18n-plugin/pom.xml 2009-11-02 09:52:46 UTC (rev 1685)
+++ trunk/maven-i18n-plugin/pom.xml 2009-12-09 10:39:02 UTC (rev 1686)
@@ -83,7 +83,7 @@
<!-- ************************************************************* -->
<!-- *** Project Information ************************************* -->
<!-- ************************************************************* -->
- <name>I18n Maven Plugin</name>
+ <name>I18n :: Maven Plugin</name>
<description>
Plugin pour maven 2 de génération des bundles pour l'internationnalisation (i18n) des applications java
basé sur nuiton-i18n-api.
Modified: trunk/nuiton-i18n-api/pom.xml
===================================================================
--- trunk/nuiton-i18n-api/pom.xml 2009-11-02 09:52:46 UTC (rev 1685)
+++ trunk/nuiton-i18n-api/pom.xml 2009-12-09 10:39:02 UTC (rev 1686)
@@ -40,7 +40,7 @@
<!-- *** Project Information ************************************* -->
<!-- ************************************************************* -->
- <name>I18n Api</name>
+ <name>I18n :: Api</name>
<description>Api of i18n system</description>
<inceptionYear>2004</inceptionYear>
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2009-11-02 09:52:46 UTC (rev 1685)
+++ trunk/pom.xml 2009-12-09 10:39:02 UTC (rev 1686)
@@ -10,7 +10,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>mavenpom</artifactId>
- <version>1.1.0</version>
+ <version>1.1.1</version>
</parent>
<artifactId>i18n</artifactId>
@@ -188,7 +188,7 @@
<!-- ************************************************************* -->
<!-- *** Project Information ************************************* -->
<!-- ************************************************************* -->
- <name>I18n project</name>
+ <name>I18n</name>
<description>Nuiton i18n tools</description>
<inceptionYear>2008</inceptionYear>
<url>http://maven-site.nuiton.org/i18n</url>
1
0
r1685 - in trunk: maven-i18n-plugin/src/site nuiton-i18n-api/src/site nuiton-i18n-editor/src/site src/site src/site/apt
by tchemit@users.nuiton.org 02 Nov '09
by tchemit@users.nuiton.org 02 Nov '09
02 Nov '09
Author: tchemit
Date: 2009-11-02 10:52:46 +0100 (Mon, 02 Nov 2009)
New Revision: 1685
Added:
trunk/maven-i18n-plugin/src/site/site_fr.xml
trunk/nuiton-i18n-api/src/site/site_fr.xml
trunk/nuiton-i18n-editor/src/site/site_fr.xml
trunk/src/site/apt/
trunk/src/site/apt/index.apt
trunk/src/site/site_fr.xml
Removed:
trunk/maven-i18n-plugin/src/site/site.xml
trunk/nuiton-i18n-api/src/site/site.xml
trunk/nuiton-i18n-editor/src/site/site.xml
trunk/src/site/site.xml
Log:
use specialized site descriptor + generate a index.html
Deleted: trunk/maven-i18n-plugin/src/site/site.xml
===================================================================
--- trunk/maven-i18n-plugin/src/site/site.xml 2009-11-02 09:32:30 UTC (rev 1684)
+++ trunk/maven-i18n-plugin/src/site/site.xml 2009-11-02 09:52:46 UTC (rev 1685)
@@ -1,46 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project name="${project.name}">
-
- <bannerLeft>
- <name>${project.name}</name>
- <href>index.html</href>
- </bannerLeft>
-
- <body>
-
- <breadcrumbs>
- <item name="${project.name}" href="${project.url}" />
- </breadcrumbs>
-
- <menu ref="parent"/>
-
- <menu name="Utilisateur">
- <item name="Introduction" href="index.html"/>
- <item name="Usages" href="usages.html"/>
- <item name="Goals" href="plugin-info.html">
- <item name="parserJava" href="parserJava-mojo.html"/>
- <item name="parserJaxx" href="parserJaxx-mojo.html"/>
- <item name="parserSwixat" href="parserSwixat-mojo.html"/>
- <item name="parserJavaActionConfig" href="parserJavaActionConfig-mojo.html"/>
- <item name="parserJavaTabConfig" href="parserJavaTabConfig-mojo.html"/>
- <item name="parserXWorks" href="parserValidation-mojo.html"/>
- <item name="get" href="get-mojo.html"/>
- <item name="gen" href="gen-mojo.html"/>
- <item name="bundle" href="bundle-mojo.html"/>
- <item name="help" href="help-mojo.html"/>
- </item>
- </menu>
-
- <menu name="Téléchargement">
- <item href="${repository.home.url}/org/nuiton/i18n/${project.artifactId}/${project.version}/${project.build.finalName}.jar"
- name="Librairie (jar)"/>
- <item href="${repository.home.url}/org/nuiton/i18n/${project.artifactId}/${project.version}/${project.build.finalName}-javadoc.jar"
- name="Javadoc (jar)"/>
- <item href="${repository.home.url}/org/nuiton/i18n/${project.artifactId}/${project.version}/${project.build.finalName}-sources.jar"
- name="Sources (jar)"/>
- </menu>
-
- <menu ref="reports"/>
-
- </body>
-</project>
Copied: trunk/maven-i18n-plugin/src/site/site_fr.xml (from rev 1684, trunk/maven-i18n-plugin/src/site/site.xml)
===================================================================
--- trunk/maven-i18n-plugin/src/site/site_fr.xml (rev 0)
+++ trunk/maven-i18n-plugin/src/site/site_fr.xml 2009-11-02 09:52:46 UTC (rev 1685)
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project name="${project.name}">
+
+ <bannerLeft>
+ <name>${project.name}</name>
+ <href>index.html</href>
+ </bannerLeft>
+
+ <body>
+
+ <breadcrumbs>
+ <item name="${project.name}" href="${project.url}" />
+ </breadcrumbs>
+
+ <menu ref="parent"/>
+
+ <menu name="Utilisateur">
+ <item name="Introduction" href="index.html"/>
+ <item name="Usages" href="usages.html"/>
+ <item name="Goals" href="plugin-info.html">
+ <item name="parserJava" href="parserJava-mojo.html"/>
+ <item name="parserJaxx" href="parserJaxx-mojo.html"/>
+ <item name="parserSwixat" href="parserSwixat-mojo.html"/>
+ <item name="parserJavaActionConfig" href="parserJavaActionConfig-mojo.html"/>
+ <item name="parserJavaTabConfig" href="parserJavaTabConfig-mojo.html"/>
+ <item name="parserXWorks" href="parserValidation-mojo.html"/>
+ <item name="get" href="get-mojo.html"/>
+ <item name="gen" href="gen-mojo.html"/>
+ <item name="bundle" href="bundle-mojo.html"/>
+ <item name="help" href="help-mojo.html"/>
+ </item>
+ </menu>
+
+ <menu name="Téléchargement">
+ <item href="${repository.home.url}/org/nuiton/i18n/${project.artifactId}/${project.version}/${project.build.finalName}.jar"
+ name="Librairie (jar)"/>
+ <item href="${repository.home.url}/org/nuiton/i18n/${project.artifactId}/${project.version}/${project.build.finalName}-javadoc.jar"
+ name="Javadoc (jar)"/>
+ <item href="${repository.home.url}/org/nuiton/i18n/${project.artifactId}/${project.version}/${project.build.finalName}-sources.jar"
+ name="Sources (jar)"/>
+ </menu>
+
+ <menu ref="reports"/>
+
+ </body>
+</project>
Deleted: trunk/nuiton-i18n-api/src/site/site.xml
===================================================================
--- trunk/nuiton-i18n-api/src/site/site.xml 2009-11-02 09:32:30 UTC (rev 1684)
+++ trunk/nuiton-i18n-api/src/site/site.xml 2009-11-02 09:52:46 UTC (rev 1685)
@@ -1,33 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project name="${project.name}">
-
- <bannerLeft>
- <name>${project.name}</name>
- <href>index.html</href>
- </bannerLeft>
-
- <body>
-
- <breadcrumbs>
- <item name="${project.name}" href="${project.url}" />
- </breadcrumbs>
-
- <menu ref="parent"/>
-
- <menu name="Utilisateur">
- <item name="Accueil" href="index.html"/>
- </menu>
-
- <menu name="Téléchargement">
- <item href="${repository.home.url}/org/nuiton/i18n/${project.artifactId}/${project.version}/${project.build.finalName}.jar"
- name="Librairie (jar)"/>
- <item href="${repository.home.url}/org/nuiton/i18n/${project.artifactId}/${project.version}/${project.build.finalName}-javadoc.jar"
- name="Javadoc (jar)"/>
- <item href="${repository.home.url}/org/nuiton/i18n/${project.artifactId}/${project.version}/${project.build.finalName}-sources.jar"
- name="Sources (jar)"/>
- </menu>
-
- <menu ref="reports"/>
-
- </body>
-</project>
Copied: trunk/nuiton-i18n-api/src/site/site_fr.xml (from rev 1684, trunk/nuiton-i18n-api/src/site/site.xml)
===================================================================
--- trunk/nuiton-i18n-api/src/site/site_fr.xml (rev 0)
+++ trunk/nuiton-i18n-api/src/site/site_fr.xml 2009-11-02 09:52:46 UTC (rev 1685)
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project name="${project.name}">
+
+ <bannerLeft>
+ <name>${project.name}</name>
+ <href>index.html</href>
+ </bannerLeft>
+
+ <body>
+
+ <breadcrumbs>
+ <item name="${project.name}" href="${project.url}" />
+ </breadcrumbs>
+
+ <menu ref="parent"/>
+
+ <menu name="Utilisateur">
+ <item name="Accueil" href="index.html"/>
+ </menu>
+
+ <menu name="Téléchargement">
+ <item href="${repository.home.url}/org/nuiton/i18n/${project.artifactId}/${project.version}/${project.build.finalName}.jar"
+ name="Librairie (jar)"/>
+ <item href="${repository.home.url}/org/nuiton/i18n/${project.artifactId}/${project.version}/${project.build.finalName}-javadoc.jar"
+ name="Javadoc (jar)"/>
+ <item href="${repository.home.url}/org/nuiton/i18n/${project.artifactId}/${project.version}/${project.build.finalName}-sources.jar"
+ name="Sources (jar)"/>
+ </menu>
+
+ <menu ref="reports"/>
+
+ </body>
+</project>
Property changes on: trunk/nuiton-i18n-api/src/site/site_fr.xml
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Deleted: trunk/nuiton-i18n-editor/src/site/site.xml
===================================================================
--- trunk/nuiton-i18n-editor/src/site/site.xml 2009-11-02 09:32:30 UTC (rev 1684)
+++ trunk/nuiton-i18n-editor/src/site/site.xml 2009-11-02 09:52:46 UTC (rev 1685)
@@ -1,51 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project name="${project.name}">
-
- <skin>
- <groupId>org.nuiton</groupId>
- <artifactId>maven-nuiton-skin</artifactId>
- <version>1.0.0</version>
- </skin>
-
- <bannerLeft>
- <name>${project.name}</name>
- <href>index.html</href>
- </bannerLeft>
-
- <bannerRight>
- <src>http://www.codelutin.com/images/lutinorange-codelutin.png</src>
- <href>${project.organization.url}</href>
- </bannerRight>
-
- <poweredBy>
- <logo href="http://maven-site.nuiton.org/jaxx" name="JAXX" img="images/jaxx-logo.png"/>
- <logo href="http://jrst.labs.libre-entreprise.org/jrst" name="JRst"
- img="images/jrst-logo.png"/>
-
- <logo href="http://docutils.sourceforge.net/rst.html" name="ReStructuredText"
- img="images/restructuredtext-logo.png"/>
- </poweredBy>
-
- <body>
-
- <breadcrumbs>
- <item name="${project.name}" href="${project.url}" />
- </breadcrumbs>
-
- <menu name="Utilisateur">
- <item name="Accueil" href="index.html"/>
- <item href="launch-${project.artifactId}.jnlp"
- src="images/webstart.gif"
- name="Démarrer la dernière version"/>
- <item href="${project.build.finalName}-bin.zip"
- name="Télécharger la dernière version"/>
- </menu>
-
- <menu name="Développeur">
- <item name="A faire" href="Todo.html"/>
- </menu>
-
- <menu ref="reports"/>
-
- </body>
-</project>
Copied: trunk/nuiton-i18n-editor/src/site/site_fr.xml (from rev 1684, trunk/nuiton-i18n-editor/src/site/site.xml)
===================================================================
--- trunk/nuiton-i18n-editor/src/site/site_fr.xml (rev 0)
+++ trunk/nuiton-i18n-editor/src/site/site_fr.xml 2009-11-02 09:52:46 UTC (rev 1685)
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project name="${project.name}">
+
+ <skin>
+ <groupId>org.nuiton</groupId>
+ <artifactId>maven-nuiton-skin</artifactId>
+ <version>1.0.0</version>
+ </skin>
+
+ <bannerLeft>
+ <name>${project.name}</name>
+ <href>index.html</href>
+ </bannerLeft>
+
+ <bannerRight>
+ <src>http://www.codelutin.com/images/lutinorange-codelutin.png</src>
+ <href>${project.organization.url}</href>
+ </bannerRight>
+
+ <poweredBy>
+ <logo href="http://maven-site.nuiton.org/jaxx" name="JAXX" img="images/jaxx-logo.png"/>
+ <logo href="http://jrst.labs.libre-entreprise.org/jrst" name="JRst"
+ img="images/jrst-logo.png"/>
+
+ <logo href="http://docutils.sourceforge.net/rst.html" name="ReStructuredText"
+ img="images/restructuredtext-logo.png"/>
+ </poweredBy>
+
+ <body>
+
+ <breadcrumbs>
+ <item name="${project.name}" href="${project.url}" />
+ </breadcrumbs>
+
+ <menu name="Utilisateur">
+ <item name="Accueil" href="index.html"/>
+ <item href="launch-${project.artifactId}.jnlp"
+ src="images/webstart.gif"
+ name="Démarrer la dernière version"/>
+ <item href="${project.build.finalName}-bin.zip"
+ name="Télécharger la dernière version"/>
+ </menu>
+
+ <menu name="Développeur">
+ <item name="A faire" href="Todo.html"/>
+ </menu>
+
+ <menu ref="reports"/>
+
+ </body>
+</project>
Added: trunk/src/site/apt/index.apt
===================================================================
--- trunk/src/site/apt/index.apt (rev 0)
+++ trunk/src/site/apt/index.apt 2009-11-02 09:52:46 UTC (rev 1685)
@@ -0,0 +1,16 @@
+----
+Nuiton I18n
+----
+----
+2009-11-02
+----
+
+Présentation
+
+ Projet I18n de traduction composé de deux modules :
+
+ - {{{nuiton-i18n-api/index.html}I18n Api}}
+
+ - {{{maven-i18n-plugin/index.html}I18n Maven Plugin}}
+
+
Deleted: trunk/src/site/site.xml
===================================================================
--- trunk/src/site/site.xml 2009-11-02 09:32:30 UTC (rev 1684)
+++ trunk/src/site/site.xml 2009-11-02 09:52:46 UTC (rev 1685)
@@ -1,23 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project name="${project.name}">
-
- <bannerLeft>
- <name>${project.name}</name>
- <href>index.html</href>
- </bannerLeft>
-
- <poweredBy>
- <logo href="http://maven.apache.org" name="Maven" img="${project.url}/images/logos/maven-feather.png"/>
- </poweredBy>
-
- <body>
-
- <breadcrumbs>
- <item name="${project.name}" href="${project.url}" />
- </breadcrumbs>
-
- <menu ref="modules"/>
-
- <menu ref="reports"/>
- </body>
-</project>
Copied: trunk/src/site/site_fr.xml (from rev 1684, trunk/src/site/site.xml)
===================================================================
--- trunk/src/site/site_fr.xml (rev 0)
+++ trunk/src/site/site_fr.xml 2009-11-02 09:52:46 UTC (rev 1685)
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project name="${project.name}">
+
+ <bannerLeft>
+ <name>${project.name}</name>
+ <href>index.html</href>
+ </bannerLeft>
+
+ <poweredBy>
+ <logo href="http://maven.apache.org" name="Maven" img="${project.url}/images/logos/maven-feather.png"/>
+ </poweredBy>
+
+ <body>
+
+ <breadcrumbs>
+ <item name="${project.name}" href="${project.url}"/>
+ </breadcrumbs>
+
+ <menu name="Utilisateur">
+ <item name="Accueil" href="index.html"/>
+ </menu>
+
+ <menu ref="modules"/>
+
+ <menu ref="reports"/>
+ </body>
+</project>
1
0
02 Nov '09
Author: tchemit
Date: 2009-11-02 10:32:30 +0100 (Mon, 02 Nov 2009)
New Revision: 1684
Modified:
trunk/maven-i18n-plugin/pom.xml
trunk/nuiton-i18n-api/pom.xml
trunk/pom.xml
Log:
add nice project names
Modified: trunk/maven-i18n-plugin/pom.xml
===================================================================
--- trunk/maven-i18n-plugin/pom.xml 2009-11-02 03:47:09 UTC (rev 1683)
+++ trunk/maven-i18n-plugin/pom.xml 2009-11-02 09:32:30 UTC (rev 1684)
@@ -83,7 +83,7 @@
<!-- ************************************************************* -->
<!-- *** Project Information ************************************* -->
<!-- ************************************************************* -->
- <name>nuiton-i18n - maven plugin</name>
+ <name>I18n Maven Plugin</name>
<description>
Plugin pour maven 2 de génération des bundles pour l'internationnalisation (i18n) des applications java
basé sur nuiton-i18n-api.
Modified: trunk/nuiton-i18n-api/pom.xml
===================================================================
--- trunk/nuiton-i18n-api/pom.xml 2009-11-02 03:47:09 UTC (rev 1683)
+++ trunk/nuiton-i18n-api/pom.xml 2009-11-02 09:32:30 UTC (rev 1684)
@@ -40,7 +40,7 @@
<!-- *** Project Information ************************************* -->
<!-- ************************************************************* -->
- <name>nuiton-i18n - api</name>
+ <name>I18n Api</name>
<description>Api of i18n system</description>
<inceptionYear>2004</inceptionYear>
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2009-11-02 03:47:09 UTC (rev 1683)
+++ trunk/pom.xml 2009-11-02 09:32:30 UTC (rev 1684)
@@ -188,7 +188,7 @@
<!-- ************************************************************* -->
<!-- *** Project Information ************************************* -->
<!-- ************************************************************* -->
- <name>nuiton-i18n - pom</name>
+ <name>I18n project</name>
<description>Nuiton i18n tools</description>
<inceptionYear>2008</inceptionYear>
<url>http://maven-site.nuiton.org/i18n</url>
1
0
Author: tchemit
Date: 2009-11-02 04:47:09 +0100 (Mon, 02 Nov 2009)
New Revision: 1683
Modified:
trunk/pom.xml
Log:
use mavenpom 1.1.0
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2009-11-02 03:38:44 UTC (rev 1682)
+++ trunk/pom.xml 2009-11-02 03:47:09 UTC (rev 1683)
@@ -1,5 +1,6 @@
<?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/xsd/maven-4.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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
@@ -9,7 +10,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>mavenpom</artifactId>
- <version>1.1.0-SNAPSHOT</version>
+ <version>1.1.0</version>
</parent>
<artifactId>i18n</artifactId>
@@ -120,10 +121,10 @@
<groupId>org.apache.velocity</groupId>
<artifactId>velocity</artifactId>
</exclusion>
-
+
</exclusions>
</dependency>
-
+
<dependency>
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-dependency-tree</artifactId>
@@ -140,7 +141,7 @@
<artifactId>commons-collections</artifactId>
<version>3.1</version>
</dependency>
-
+
<!-- tests dependencies -->
<dependency>
@@ -203,7 +204,7 @@
<projectId>i18n</projectId>
<processor.version>1.0.1</processor.version>
-
+
</properties>
<build>
@@ -222,6 +223,6 @@
<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