Author: tchemit Date: 2012-07-09 15:12:35 +0200 (Mon, 09 Jul 2012) New Revision: 1961 Url: http://nuiton.org/repositories/revision/i18n/1961 Log: fixes #2176: Rename mojo module to i18n-maven-plugin Added: trunk/i18n-maven-plugin/ trunk/i18n-maven-plugin/pom.xml trunk/i18n-maven-plugin/src/it/ano-1494/iso-8859-1/goals.txt trunk/i18n-maven-plugin/src/it/ano-1494/migrate/goals.txt trunk/i18n-maven-plugin/src/it/ano-1494/utf-8/goals.txt trunk/i18n-maven-plugin/src/it/ano-672/goals.txt trunk/i18n-maven-plugin/src/it/evo-1507/goals.txt trunk/i18n-maven-plugin/src/it/parsers/newProject/goals.txt trunk/i18n-maven-plugin/src/it/parsers/newProject/src/main/resources/org/nuiton/i18n/test/MyBean-validation.xml trunk/i18n-maven-plugin/src/it/parsers/withNewKeys/goals.txt trunk/i18n-maven-plugin/src/it/parsers/withNewKeys/src/main/resources/org/nuiton/i18n/test/MyBean-validation.xml trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nMojo.java trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/GenerateMojo.java trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/GetterMojo.java trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/AbstractI18nBundleMojo.java trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/AbstractMakeI18nBundleMojo.java trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/AvailableConverterMojo.java trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/BundleMojo.java trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/CollectI18nArtifactsMojo.java trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/parser/AbstractI18nParserMojo.java trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/AbstractParserXmlMojo.java trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserGWTJavaMojo.java trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJavaMojo.java trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJspMojo.java trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserTapestryMojo.java trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserValidationMojo.java trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserXmlUserMojo.java trunk/i18n-maven-plugin/src/main/resources/xwork-validator-1.0.3.dtd trunk/i18n-maven-plugin/src/site/site_en.xml trunk/i18n-maven-plugin/src/site/site_fr.xml trunk/i18n-maven-plugin/src/test/java/org/nuiton/i18n/plugin/parser/SourceEntryTest.java trunk/i18n-maven-plugin/src/test/resources/ Removed: trunk/i18n-maven-plugin/pom.xml trunk/i18n-maven-plugin/src/it/ano-1494/iso-8859-1/invoker.properties trunk/i18n-maven-plugin/src/it/ano-1494/migrate/invoker.properties trunk/i18n-maven-plugin/src/it/ano-1494/utf-8/invoker.properties trunk/i18n-maven-plugin/src/it/ano-672/invoker.properties trunk/i18n-maven-plugin/src/it/evo-1507/invoker.properties trunk/i18n-maven-plugin/src/it/parsers/newProject/invoker.properties trunk/i18n-maven-plugin/src/it/parsers/newProject/src/main/resources/org/nuiton/i18n/test/MyBean-validation.xml trunk/i18n-maven-plugin/src/it/parsers/withNewKeys/invoker.properties trunk/i18n-maven-plugin/src/it/parsers/withNewKeys/src/main/resources/org/nuiton/i18n/test/MyBean-validation.xml trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nMojo.java trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/GenerateMojo.java trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/GetterMojo.java trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/AbstractI18nBundleMojo.java trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/AbstractMakeI18nBundleMojo.java trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/AvailableConverterMojo.java trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/BundleMojo.java trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/CollectI18nArtifactsMojo.java trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/parser/AbstractI18nParserMojo.java trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/AbstractParserXmlMojo.java trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserGWTJavaMojo.java trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJavaMojo.java trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJspMojo.java trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserTapestryMojo.java trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserValidationMojo.java trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserXmlUserMojo.java trunk/i18n-maven-plugin/src/site/site_en.xml trunk/i18n-maven-plugin/src/site/site_fr.xml trunk/maven-i18n-plugin/ Modified: trunk/i18n-maven-plugin/src/it/ano-1494/iso-8859-1/pom.xml trunk/i18n-maven-plugin/src/it/ano-1494/migrate/pom.xml trunk/i18n-maven-plugin/src/it/ano-1494/utf-8/pom.xml trunk/i18n-maven-plugin/src/it/ano-672/pom.xml trunk/i18n-maven-plugin/src/it/evo-1507/pom.xml trunk/i18n-maven-plugin/src/it/parsers/newProject/pom.xml trunk/i18n-maven-plugin/src/it/parsers/withNewKeys/pom.xml trunk/i18n-maven-plugin/src/site/apt/usages.apt trunk/i18n-maven-plugin/src/site/en/apt/usages.apt trunk/src/site/apt/gwt.apt trunk/src/site/apt/index.apt trunk/src/site/apt/library.apt.vm trunk/src/site/en/apt/gwt.apt trunk/src/site/en/apt/index.apt trunk/src/site/en/apt/library.apt.vm Deleted: trunk/i18n-maven-plugin/pom.xml =================================================================== --- trunk/maven-i18n-plugin/pom.xml 2012-05-30 14:03:24 UTC (rev 1957) +++ trunk/i18n-maven-plugin/pom.xml 2012-07-09 13:12:35 UTC (rev 1961) @@ -1,238 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - #%L - I18n :: Maven Plugin - - $Id$ - $HeadURL$ - %% - Copyright (C) 2007 - 2010 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>. - #L% - --> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - - <modelVersion>4.0.0</modelVersion> - - <!-- ************************************************************* --> - <!-- *** POM Relationships *************************************** --> - <!-- ************************************************************* --> - <parent> - <groupId>org.nuiton</groupId> - <artifactId>i18n</artifactId> - <version>2.4.2-SNAPSHOT</version> - </parent> - - <groupId>org.nuiton.i18n</groupId> - <artifactId>maven-i18n-plugin</artifactId> - - <dependencies> - - <dependency> - <groupId>${project.groupId}</groupId> - <artifactId>nuiton-i18n</artifactId> - <version>${project.version}</version> - </dependency> - - <dependency> - <groupId>org.nuiton.processor</groupId> - <artifactId>nuiton-processor</artifactId> - </dependency> - - <dependency> - <groupId>org.nuiton</groupId> - <artifactId>helper-maven-plugin</artifactId> - </dependency> - - <dependency> - <groupId>commons-logging</groupId> - <artifactId>commons-logging</artifactId> - </dependency> - - <dependency> - <groupId>commons-lang</groupId> - <artifactId>commons-lang</artifactId> - </dependency> - - <dependency> - <groupId>commons-io</groupId> - <artifactId>commons-io</artifactId> - </dependency> - - <dependency> - <groupId>org.apache.maven.shared</groupId> - <artifactId>maven-dependency-tree</artifactId> - </dependency> - - <!-- provided dependencies --> - - <dependency> - <groupId>org.apache.maven</groupId> - <artifactId>maven-project</artifactId> - </dependency> - - <dependency> - <groupId>org.apache.maven</groupId> - <artifactId>maven-artifact</artifactId> - </dependency> - - <dependency> - <groupId>org.apache.maven</groupId> - <artifactId>maven-plugin-api</artifactId> - </dependency> - - <!-- FIXME si on ne le rajoute pas, on se retrouve avec la version 1.1 qui ne convient pas --> - <dependency> - <groupId>org.codehaus.plexus</groupId> - <artifactId>plexus-utils</artifactId> - </dependency> - - <dependency> - <groupId>log4j</groupId> - <artifactId>log4j</artifactId> - <scope>runtime</scope> - </dependency> - - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - </dependency> - - </dependencies> - - <!-- ************************************************************* --> - <!-- *** Project Information ************************************* --> - <!-- ************************************************************* --> - <name>I18n :: Maven Plugin</name> - <description> - Maven plugin to deal with i18n stuff in a project, mainly base on the - nuiton-i18n api (but not only). - </description> - <inceptionYear>2007</inceptionYear> - - <!-- ************************************************************* --> - <!-- *** Build Settings ****************************************** --> - <!-- ************************************************************* --> - - <packaging>maven-plugin</packaging> - - <build> - <plugins> - - <!-- expose new plexus components --> - <plugin> - <groupId>org.codehaus.plexus</groupId> - <artifactId>plexus-component-metadata</artifactId> - <executions> - <execution> - <goals> - <goal>generate-metadata</goal> - </goals> - </execution> - </executions> - </plugin> - - <plugin> - <artifactId>maven-plugin-plugin</artifactId> - <executions> - <execution> - <goals> - <goal>helpmojo</goal> - </goals> - </execution> - </executions> - </plugin> - - </plugins> - </build> - <profiles> - - <!-- perform only on a release stage when using the maven-release-plugin --> - <profile> - <id>reporting</id> - <activation> - <property> - <name>performRelease</name> - <value>true</value> - </property> - </activation> - - <reporting> - - <plugins> - - <plugin> - <artifactId>maven-plugin-plugin</artifactId> - <version>${pluginPluginVersion}</version> - </plugin> - - <plugin> - <artifactId>maven-invoker-plugin</artifactId> - <version>${invokerPluginVersion}</version> - </plugin> - - <plugin> - <groupId>org.codehaus.plexus</groupId> - <artifactId>plexus-maven-plugin</artifactId> - <version>${plexusPluginVersion}</version> - </plugin> - - </plugins> - </reporting> - - </profile> - - <profile> - <id>run-its</id> - <activation> - <property> - <name>performRelease</name> - <value>true</value> - </property> - </activation> - <build> - <defaultGoal>verify</defaultGoal> - <plugins> - <plugin> - <artifactId>maven-invoker-plugin</artifactId> - <configuration> - <pomIncludes> - <pomInclude>**/pom.xml</pomInclude> - </pomIncludes> - <postBuildHookScript>verify</postBuildHookScript> - <localRepositoryPath>${basedir}/target/local-repo - </localRepositoryPath> - <settingsFile>src/it/settings.xml</settingsFile> - <cloneProjectsTo>${project.build.directory}/its</cloneProjectsTo> - <debug>${maven.verbose}</debug> - </configuration> - <executions> - <execution> - <id>integration-test</id> - <goals> - <goal>install</goal> - <goal>run</goal> - </goals> - <phase>integration-test</phase> - </execution> - </executions> - </plugin> - </plugins> - </build> - </profile> - </profiles> - -</project> Copied: trunk/i18n-maven-plugin/pom.xml (from rev 1960, trunk/maven-i18n-plugin/pom.xml) =================================================================== --- trunk/i18n-maven-plugin/pom.xml (rev 0) +++ trunk/i18n-maven-plugin/pom.xml 2012-07-09 13:12:35 UTC (rev 1961) @@ -0,0 +1,298 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + #%L + I18n :: Maven Plugin + + $Id$ + $HeadURL$ + %% + Copyright (C) 2007 - 2010 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>. + #L% + --> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + + <modelVersion>4.0.0</modelVersion> + + <!-- ************************************************************* --> + <!-- *** POM Relationships *************************************** --> + <!-- ************************************************************* --> + <parent> + <groupId>org.nuiton</groupId> + <artifactId>i18n</artifactId> + <version>2.4.2-SNAPSHOT</version> + </parent> + + <groupId>org.nuiton.i18n</groupId> + <artifactId>i18n-maven-plugin</artifactId> + + <dependencies> + + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>nuiton-i18n</artifactId> + <version>${project.version}</version> + </dependency> + + <dependency> + <groupId>org.nuiton.processor</groupId> + <artifactId>nuiton-processor</artifactId> + </dependency> + + <dependency> + <groupId>org.nuiton</groupId> + <artifactId>helper-maven-plugin</artifactId> + </dependency> + + <dependency> + <groupId>commons-logging</groupId> + <artifactId>commons-logging</artifactId> + </dependency> + + <dependency> + <groupId>commons-lang</groupId> + <artifactId>commons-lang</artifactId> + </dependency> + + <dependency> + <groupId>commons-io</groupId> + <artifactId>commons-io</artifactId> + </dependency> + + <dependency> + <groupId>org.apache.maven.shared</groupId> + <artifactId>maven-dependency-tree</artifactId> + </dependency> + + <!-- provided dependencies --> + + <dependency> + <groupId>org.apache.maven</groupId> + <artifactId>maven-project</artifactId> + </dependency> + + <dependency> + <groupId>org.apache.maven</groupId> + <artifactId>maven-artifact</artifactId> + </dependency> + + <dependency> + <groupId>org.apache.maven</groupId> + <artifactId>maven-plugin-api</artifactId> + </dependency> + + <!-- dependencies to mojo annotations --> + <dependency> + <groupId>org.apache.maven.plugin-tools</groupId> + <artifactId>maven-plugin-annotations</artifactId> + </dependency> + + <!-- FIXME si on ne le rajoute pas, on se retrouve avec la version 1.1 qui ne convient pas --> + <dependency> + <groupId>org.codehaus.plexus</groupId> + <artifactId>plexus-utils</artifactId> + </dependency> + + <dependency> + <groupId>log4j</groupId> + <artifactId>log4j</artifactId> + <scope>runtime</scope> + </dependency> + + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + </dependency> + + </dependencies> + + <!-- ************************************************************* --> + <!-- *** Project Information ************************************* --> + <!-- ************************************************************* --> + <name>I18n :: Maven Plugin</name> + <description> + Maven plugin to deal with i18n stuff in a project, mainly base on the + nuiton-i18n api (but not only). + </description> + <inceptionYear>2007</inceptionYear> + + <!-- ************************************************************* --> + <!-- *** Build Settings ****************************************** --> + <!-- ************************************************************* --> + + <packaging>maven-plugin</packaging> + + <build> + <plugins> + + <!-- expose new plexus components --> + <plugin> + <groupId>org.codehaus.plexus</groupId> + <artifactId>plexus-component-metadata</artifactId> + <executions> + <execution> + <goals> + <goal>generate-metadata</goal> + </goals> + </execution> + </executions> + </plugin> + + <plugin> + <artifactId>maven-plugin-plugin</artifactId> + <configuration> + <skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound> + </configuration> + <executions> + <execution> + <goals> + <goal>helpmojo</goal> + <goal>descriptor</goal> + </goals> + </execution> + </executions> + </plugin> + + </plugins> + </build> + <profiles> + + <!-- perform only on a release stage when using the maven-release-plugin --> + <profile> + <id>reporting</id> + <activation> + <property> + <name>performRelease</name> + <value>true</value> + </property> + </activation> + + <reporting> + + <plugins> + + <plugin> + <artifactId>maven-project-info-reports-plugin</artifactId> + <version>${projectInfoReportsPluginVersion}</version> + <reportSets> + <reportSet> + <reports> + <report>project-team</report> + <report>mailing-list</report> + <report>cim</report> + <report>issue-tracking</report> + <report>license</report> + <report>scm</report> + <report>dependencies</report> + <report>dependency-convergence</report> + <report>plugin-management</report> + <report>plugins</report> + <report>dependency-management</report> + <report>summary</report> + </reports> + </reportSet> + </reportSets> + </plugin> + + <plugin> + <artifactId>maven-plugin-plugin</artifactId> + <version>${pluginPluginVersion}</version> + </plugin> + + <plugin> + <artifactId>maven-invoker-plugin</artifactId> + <version>${invokerPluginVersion}</version> + </plugin> + + <plugin> + <groupId>org.codehaus.plexus</groupId> + <artifactId>plexus-maven-plugin</artifactId> + <version>${plexusPluginVersion}</version> + </plugin> + + <plugin> + <artifactId>maven-javadoc-plugin</artifactId> + <version>${javadocPluginVersion}</version> + <configuration> + <quiet>true</quiet> + <tagletArtifacts> + <tagletArtifact> + <groupId>org.apache.maven.plugin-tools</groupId> + <artifactId>maven-plugin-tools-javadoc</artifactId> + <version>${pluginPluginVersion}</version> + </tagletArtifact> + <tagletArtifact> + <groupId>org.codehaus.plexus</groupId> + <artifactId>plexus-component-javadoc</artifactId> + <version>1.5.5</version> + </tagletArtifact> + </tagletArtifacts> + </configuration> + <reportSets> + <reportSet> + <reports> + <report>javadoc</report> + <report>test-javadoc</report> + </reports> + </reportSet> + </reportSets> + </plugin> + + </plugins> + </reporting> + + </profile> + + <profile> + <id>run-its</id> + <activation> + <property> + <name>maven.test.skip</name> + <value>!true</value> + </property> + </activation> + <build> + <defaultGoal>verify</defaultGoal> + <plugins> + <plugin> + <artifactId>maven-invoker-plugin</artifactId> + <configuration> + <pomIncludes> + <pomInclude>**/pom.xml</pomInclude> + </pomIncludes> + <postBuildHookScript>verify</postBuildHookScript> + <localRepositoryPath>${basedir}/target/local-repo + </localRepositoryPath> + <settingsFile>src/it/settings.xml</settingsFile> + <cloneProjectsTo>${project.build.directory}/its</cloneProjectsTo> + </configuration> + <executions> + <execution> + <id>integration-test</id> + <goals> + <goal>install</goal> + <goal>run</goal> + </goals> + <phase>integration-test</phase> + </execution> + </executions> + </plugin> + </plugins> + </build> + </profile> + </profiles> + +</project> Copied: trunk/i18n-maven-plugin/src/it/ano-1494/iso-8859-1/goals.txt (from rev 1960, trunk/maven-i18n-plugin/src/it/ano-1494/iso-8859-1/goals.txt) =================================================================== --- trunk/i18n-maven-plugin/src/it/ano-1494/iso-8859-1/goals.txt (rev 0) +++ trunk/i18n-maven-plugin/src/it/ano-1494/iso-8859-1/goals.txt 2012-07-09 13:12:35 UTC (rev 1961) @@ -0,0 +1 @@ +clean compile \ No newline at end of file Deleted: trunk/i18n-maven-plugin/src/it/ano-1494/iso-8859-1/invoker.properties =================================================================== --- trunk/maven-i18n-plugin/src/it/ano-1494/iso-8859-1/invoker.properties 2012-05-30 14:03:24 UTC (rev 1957) +++ trunk/i18n-maven-plugin/src/it/ano-1494/iso-8859-1/invoker.properties 2012-07-09 13:12:35 UTC (rev 1961) @@ -1,45 +0,0 @@ -### -# #%L -# I18n :: Maven Plugin -# -# $Id$ -# $HeadURL$ -# %% -# Copyright (C) 2007 - 2010 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>. -# #L% -### -# A comma or space separated list of goals/phases to execute, may -# specify an empty list to execute the default goal of the IT project -invoker.goals=clean compile -Dlog4j.configuration=file:src/test/resources/log4j.properties - -# Optionally, a list of goals to run during further invocations of Maven -#invoker.goals.2=${project.groupId}:${project.artifactId}:${project.version}:run - -# A comma or space separated list of profiles to activate -#invoker.profiles=run-all run-once - -# The value for the environment variable MAVEN_OPTS -#invoker.mavenOpts=-Dfile.encoding=UTF-16 -Xms32m -Xmx256m - -# Possible values are "fail-fast" (default), "fail-at-end" and "fail-never" -invoker.failureBehavior=fail-at-end - -# The expected result of the build, possible values are "success" (default) and "failure" -#invoker.buildResult=success - -# A boolean value controlling the -N flag, defaults to "false" -#invoker.nonRecursive=false Modified: trunk/i18n-maven-plugin/src/it/ano-1494/iso-8859-1/pom.xml =================================================================== --- trunk/maven-i18n-plugin/src/it/ano-1494/iso-8859-1/pom.xml 2012-05-30 14:03:24 UTC (rev 1957) +++ trunk/i18n-maven-plugin/src/it/ano-1494/iso-8859-1/pom.xml 2012-07-09 13:12:35 UTC (rev 1961) @@ -66,7 +66,7 @@ <plugin> <groupId>org.nuiton.i18n</groupId> - <artifactId>maven-i18n-plugin</artifactId> + <artifactId>i18n-maven-plugin</artifactId> <version>@pom.version@</version> <configuration> <verbose>true</verbose> Copied: trunk/i18n-maven-plugin/src/it/ano-1494/migrate/goals.txt (from rev 1960, trunk/maven-i18n-plugin/src/it/ano-1494/migrate/goals.txt) =================================================================== --- trunk/i18n-maven-plugin/src/it/ano-1494/migrate/goals.txt (rev 0) +++ trunk/i18n-maven-plugin/src/it/ano-1494/migrate/goals.txt 2012-07-09 13:12:35 UTC (rev 1961) @@ -0,0 +1 @@ +clean compile -Dlog4j.configuration=file:src/main/resources/log4j.properties \ No newline at end of file Deleted: trunk/i18n-maven-plugin/src/it/ano-1494/migrate/invoker.properties =================================================================== --- trunk/maven-i18n-plugin/src/it/ano-1494/migrate/invoker.properties 2012-05-30 14:03:24 UTC (rev 1957) +++ trunk/i18n-maven-plugin/src/it/ano-1494/migrate/invoker.properties 2012-07-09 13:12:35 UTC (rev 1961) @@ -1,45 +0,0 @@ -### -# #%L -# I18n :: Maven Plugin -# -# $Id$ -# $HeadURL$ -# %% -# Copyright (C) 2007 - 2010 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>. -# #L% -### -# A comma or space separated list of goals/phases to execute, may -# specify an empty list to execute the default goal of the IT project -invoker.goals=clean compile -Dlog4j.configuration=file:src/test/resources/log4j.properties - -# Optionally, a list of goals to run during further invocations of Maven -#invoker.goals.2=${project.groupId}:${project.artifactId}:${project.version}:run - -# A comma or space separated list of profiles to activate -#invoker.profiles=run-all run-once - -# The value for the environment variable MAVEN_OPTS -#invoker.mavenOpts=-Dfile.encoding=UTF-16 -Xms32m -Xmx256m - -# Possible values are "fail-fast" (default), "fail-at-end" and "fail-never" -invoker.failureBehavior=fail-at-end - -# The expected result of the build, possible values are "success" (default) and "failure" -#invoker.buildResult=success - -# A boolean value controlling the -N flag, defaults to "false" -#invoker.nonRecursive=false Modified: trunk/i18n-maven-plugin/src/it/ano-1494/migrate/pom.xml =================================================================== --- trunk/maven-i18n-plugin/src/it/ano-1494/migrate/pom.xml 2012-05-30 14:03:24 UTC (rev 1957) +++ trunk/i18n-maven-plugin/src/it/ano-1494/migrate/pom.xml 2012-07-09 13:12:35 UTC (rev 1961) @@ -66,7 +66,7 @@ <plugin> <groupId>org.nuiton.i18n</groupId> - <artifactId>maven-i18n-plugin</artifactId> + <artifactId>i18n-maven-plugin</artifactId> <version>@pom.version@</version> <configuration> <verbose>true</verbose> Copied: trunk/i18n-maven-plugin/src/it/ano-1494/utf-8/goals.txt (from rev 1960, trunk/maven-i18n-plugin/src/it/ano-1494/utf-8/goals.txt) =================================================================== --- trunk/i18n-maven-plugin/src/it/ano-1494/utf-8/goals.txt (rev 0) +++ trunk/i18n-maven-plugin/src/it/ano-1494/utf-8/goals.txt 2012-07-09 13:12:35 UTC (rev 1961) @@ -0,0 +1 @@ +clean test \ No newline at end of file Deleted: trunk/i18n-maven-plugin/src/it/ano-1494/utf-8/invoker.properties =================================================================== --- trunk/maven-i18n-plugin/src/it/ano-1494/utf-8/invoker.properties 2012-05-30 14:03:24 UTC (rev 1957) +++ trunk/i18n-maven-plugin/src/it/ano-1494/utf-8/invoker.properties 2012-07-09 13:12:35 UTC (rev 1961) @@ -1,45 +0,0 @@ -### -# #%L -# I18n :: Maven Plugin -# -# $Id$ -# $HeadURL$ -# %% -# Copyright (C) 2007 - 2010 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>. -# #L% -### -# A comma or space separated list of goals/phases to execute, may -# specify an empty list to execute the default goal of the IT project -invoker.goals=clean test -Dlog4j.configuration=file:src/test/resources/log4j.properties - -# Optionally, a list of goals to run during further invocations of Maven -#invoker.goals.2=${project.groupId}:${project.artifactId}:${project.version}:run - -# A comma or space separated list of profiles to activate -#invoker.profiles=run-all run-once - -# The value for the environment variable MAVEN_OPTS -#invoker.mavenOpts=-Dfile.encoding=UTF-16 -Xms32m -Xmx256m - -# Possible values are "fail-fast" (default), "fail-at-end" and "fail-never" -invoker.failureBehavior=fail-at-end - -# The expected result of the build, possible values are "success" (default) and "failure" -#invoker.buildResult=success - -# A boolean value controlling the -N flag, defaults to "false" -#invoker.nonRecursive=false Modified: trunk/i18n-maven-plugin/src/it/ano-1494/utf-8/pom.xml =================================================================== --- trunk/maven-i18n-plugin/src/it/ano-1494/utf-8/pom.xml 2012-05-30 14:03:24 UTC (rev 1957) +++ trunk/i18n-maven-plugin/src/it/ano-1494/utf-8/pom.xml 2012-07-09 13:12:35 UTC (rev 1961) @@ -77,7 +77,7 @@ <plugin> <groupId>org.nuiton.i18n</groupId> - <artifactId>maven-i18n-plugin</artifactId> + <artifactId>i18n-maven-plugin</artifactId> <version>@pom.version@</version> <configuration> <verbose>true</verbose> Copied: trunk/i18n-maven-plugin/src/it/ano-672/goals.txt (from rev 1960, trunk/maven-i18n-plugin/src/it/ano-672/goals.txt) =================================================================== --- trunk/i18n-maven-plugin/src/it/ano-672/goals.txt (rev 0) +++ trunk/i18n-maven-plugin/src/it/ano-672/goals.txt 2012-07-09 13:12:35 UTC (rev 1961) @@ -0,0 +1 @@ +clean test \ No newline at end of file Deleted: trunk/i18n-maven-plugin/src/it/ano-672/invoker.properties =================================================================== --- trunk/maven-i18n-plugin/src/it/ano-672/invoker.properties 2012-05-30 14:03:24 UTC (rev 1957) +++ trunk/i18n-maven-plugin/src/it/ano-672/invoker.properties 2012-07-09 13:12:35 UTC (rev 1961) @@ -1,45 +0,0 @@ -### -# #%L -# I18n :: Maven Plugin -# -# $Id$ -# $HeadURL$ -# %% -# Copyright (C) 2007 - 2010 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>. -# #L% -### -# A comma or space separated list of goals/phases to execute, may -# specify an empty list to execute the default goal of the IT project -invoker.goals=clean test - -# Optionally, a list of goals to run during further invocations of Maven -#invoker.goals.2=${project.groupId}:${project.artifactId}:${project.version}:run - -# A comma or space separated list of profiles to activate -#invoker.profiles=run-all run-once - -# The value for the environment variable MAVEN_OPTS -#invoker.mavenOpts=-Dfile.encoding=UTF-16 -Xms32m -Xmx256m - -# Possible values are "fail-fast" (default), "fail-at-end" and "fail-never" -invoker.failureBehavior=fail-at-end - -# The expected result of the build, possible values are "success" (default) and "failure" -#invoker.buildResult=success - -# A boolean value controlling the -N flag, defaults to "false" -#invoker.nonRecursive=false Modified: trunk/i18n-maven-plugin/src/it/ano-672/pom.xml =================================================================== --- trunk/maven-i18n-plugin/src/it/ano-672/pom.xml 2012-05-30 14:03:24 UTC (rev 1957) +++ trunk/i18n-maven-plugin/src/it/ano-672/pom.xml 2012-07-09 13:12:35 UTC (rev 1961) @@ -87,7 +87,7 @@ <plugin> <groupId>org.nuiton.i18n</groupId> - <artifactId>maven-i18n-plugin</artifactId> + <artifactId>i18n-maven-plugin</artifactId> <version>@pom.version@</version> <configuration> <verbose>true</verbose> Copied: trunk/i18n-maven-plugin/src/it/evo-1507/goals.txt (from rev 1960, trunk/maven-i18n-plugin/src/it/evo-1507/goals.txt) =================================================================== --- trunk/i18n-maven-plugin/src/it/evo-1507/goals.txt (rev 0) +++ trunk/i18n-maven-plugin/src/it/evo-1507/goals.txt 2012-07-09 13:12:35 UTC (rev 1961) @@ -0,0 +1 @@ +clean test \ No newline at end of file Deleted: trunk/i18n-maven-plugin/src/it/evo-1507/invoker.properties =================================================================== --- trunk/maven-i18n-plugin/src/it/evo-1507/invoker.properties 2012-05-30 14:03:24 UTC (rev 1957) +++ trunk/i18n-maven-plugin/src/it/evo-1507/invoker.properties 2012-07-09 13:12:35 UTC (rev 1961) @@ -1,45 +0,0 @@ -### -# #%L -# I18n :: Maven Plugin -# -# $Id$ -# $HeadURL$ -# %% -# Copyright (C) 2007 - 2010 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>. -# #L% -### -# A comma or space separated list of goals/phases to execute, may -# specify an empty list to execute the default goal of the IT project -invoker.goals=clean test - -# Optionally, a list of goals to run during further invocations of Maven -#invoker.goals.2=${project.groupId}:${project.artifactId}:${project.version}:run - -# A comma or space separated list of profiles to activate -#invoker.profiles=run-all run-once - -# The value for the environment variable MAVEN_OPTS -#invoker.mavenOpts=-Dfile.encoding=UTF-16 -Xms32m -Xmx256m - -# Possible values are "fail-fast" (default), "fail-at-end" and "fail-never" -invoker.failureBehavior=fail-at-end - -# The expected result of the build, possible values are "success" (default) and "failure" -#invoker.buildResult=success - -# A boolean value controlling the -N flag, defaults to "false" -#invoker.nonRecursive=false Modified: trunk/i18n-maven-plugin/src/it/evo-1507/pom.xml =================================================================== --- trunk/maven-i18n-plugin/src/it/evo-1507/pom.xml 2012-05-30 14:03:24 UTC (rev 1957) +++ trunk/i18n-maven-plugin/src/it/evo-1507/pom.xml 2012-07-09 13:12:35 UTC (rev 1961) @@ -72,7 +72,7 @@ <plugin> <groupId>org.nuiton.i18n</groupId> - <artifactId>maven-i18n-plugin</artifactId> + <artifactId>i18n-maven-plugin</artifactId> <version>@pom.version@</version> <configuration> <verbose>true</verbose> Copied: trunk/i18n-maven-plugin/src/it/parsers/newProject/goals.txt (from rev 1960, trunk/maven-i18n-plugin/src/it/parsers/newProject/goals.txt) =================================================================== --- trunk/i18n-maven-plugin/src/it/parsers/newProject/goals.txt (rev 0) +++ trunk/i18n-maven-plugin/src/it/parsers/newProject/goals.txt 2012-07-09 13:12:35 UTC (rev 1961) @@ -0,0 +1 @@ +clean compile \ No newline at end of file Deleted: trunk/i18n-maven-plugin/src/it/parsers/newProject/invoker.properties =================================================================== --- trunk/maven-i18n-plugin/src/it/parsers/newProject/invoker.properties 2012-05-30 14:03:24 UTC (rev 1957) +++ trunk/i18n-maven-plugin/src/it/parsers/newProject/invoker.properties 2012-07-09 13:12:35 UTC (rev 1961) @@ -1,45 +0,0 @@ -### -# #%L -# I18n :: Maven Plugin -# -# $Id$ -# $HeadURL$ -# %% -# Copyright (C) 2007 - 2010 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>. -# #L% -### -# A comma or space separated list of goals/phases to execute, may -# specify an empty list to execute the default goal of the IT project -invoker.goals=clean compile - -# Optionally, a list of goals to run during further invocations of Maven -#invoker.goals.2=${project.groupId}:${project.artifactId}:${project.version}:run - -# A comma or space separated list of profiles to activate -#invoker.profiles=run-all run-once - -# The value for the environment variable MAVEN_OPTS -#invoker.mavenOpts=-Dfile.encoding=UTF-16 -Xms32m -Xmx256m - -# Possible values are "fail-fast" (default), "fail-at-end" and "fail-never" -invoker.failureBehavior=fail-at-end - -# The expected result of the build, possible values are "success" (default) and "failure" -#invoker.buildResult=success - -# A boolean value controlling the -N flag, defaults to "false" -#invoker.nonRecursive=false Modified: trunk/i18n-maven-plugin/src/it/parsers/newProject/pom.xml =================================================================== --- trunk/maven-i18n-plugin/src/it/parsers/newProject/pom.xml 2012-05-30 14:03:24 UTC (rev 1957) +++ trunk/i18n-maven-plugin/src/it/parsers/newProject/pom.xml 2012-07-09 13:12:35 UTC (rev 1961) @@ -66,7 +66,7 @@ <plugin> <groupId>org.nuiton.i18n</groupId> - <artifactId>maven-i18n-plugin</artifactId> + <artifactId>i18n-maven-plugin</artifactId> <version>@pom.version@</version> <configuration> <verbose>true</verbose> Deleted: trunk/i18n-maven-plugin/src/it/parsers/newProject/src/main/resources/org/nuiton/i18n/test/MyBean-validation.xml =================================================================== --- trunk/maven-i18n-plugin/src/it/parsers/newProject/src/main/resources/org/nuiton/i18n/test/MyBean-validation.xml 2012-05-30 14:03:24 UTC (rev 1957) +++ trunk/i18n-maven-plugin/src/it/parsers/newProject/src/main/resources/org/nuiton/i18n/test/MyBean-validation.xml 2012-07-09 13:12:35 UTC (rev 1961) @@ -1,48 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - #%L - I18n :: Maven Plugin - - $Id$ - $HeadURL$ - %% - Copyright (C) 2007 - 2010 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>. - #L% - --> - -<!DOCTYPE validators PUBLIC - "-//OpenSymphony Group//XWork Validator 1.0.2//EN" - "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd"> -<validators> - - <field name="field1"> - - <field-validator type="required"> - <message>validationGetter.key1</message> - </field-validator> - - </field> - - <field name="field2"> - - <field-validator type="required"> - <message>validationGetter.key2##${parm1}</message> - </field-validator> - - </field> - -</validators> Copied: trunk/i18n-maven-plugin/src/it/parsers/newProject/src/main/resources/org/nuiton/i18n/test/MyBean-validation.xml (from rev 1960, trunk/maven-i18n-plugin/src/it/parsers/newProject/src/main/resources/org/nuiton/i18n/test/MyBean-validation.xml) =================================================================== --- trunk/i18n-maven-plugin/src/it/parsers/newProject/src/main/resources/org/nuiton/i18n/test/MyBean-validation.xml (rev 0) +++ trunk/i18n-maven-plugin/src/it/parsers/newProject/src/main/resources/org/nuiton/i18n/test/MyBean-validation.xml 2012-07-09 13:12:35 UTC (rev 1961) @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + #%L + I18n :: Maven Plugin + + $Id$ + $HeadURL$ + %% + Copyright (C) 2007 - 2010 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>. + #L% + --> + +<!DOCTYPE validators PUBLIC + "-//Apache Struts//XWork Validator 1.0.3//EN" + "http://struts.apache.org/dtds/xwork-validator-1.0.3.dtd"> +<validators> + + <field name="field1"> + + <field-validator type="required"> + <message>validationGetter.key1</message> + </field-validator> + + </field> + + <field name="field2"> + + <field-validator type="required"> + <message>validationGetter.key2##${parm1}</message> + </field-validator> + + </field> + +</validators> Copied: trunk/i18n-maven-plugin/src/it/parsers/withNewKeys/goals.txt (from rev 1960, trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/goals.txt) =================================================================== --- trunk/i18n-maven-plugin/src/it/parsers/withNewKeys/goals.txt (rev 0) +++ trunk/i18n-maven-plugin/src/it/parsers/withNewKeys/goals.txt 2012-07-09 13:12:35 UTC (rev 1961) @@ -0,0 +1 @@ +clean compile \ No newline at end of file Deleted: trunk/i18n-maven-plugin/src/it/parsers/withNewKeys/invoker.properties =================================================================== --- trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/invoker.properties 2012-05-30 14:03:24 UTC (rev 1957) +++ trunk/i18n-maven-plugin/src/it/parsers/withNewKeys/invoker.properties 2012-07-09 13:12:35 UTC (rev 1961) @@ -1,45 +0,0 @@ -### -# #%L -# I18n :: Maven Plugin -# -# $Id$ -# $HeadURL$ -# %% -# Copyright (C) 2007 - 2010 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>. -# #L% -### -# A comma or space separated list of goals/phases to execute, may -# specify an empty list to execute the default goal of the IT project -invoker.goals=clean compile - -# Optionally, a list of goals to run during further invocations of Maven -#invoker.goals.2=${project.groupId}:${project.artifactId}:${project.version}:run - -# A comma or space separated list of profiles to activate -#invoker.profiles=run-all run-once - -# The value for the environment variable MAVEN_OPTS -#invoker.mavenOpts=-Dfile.encoding=UTF-16 -Xms32m -Xmx256m - -# Possible values are "fail-fast" (default), "fail-at-end" and "fail-never" -invoker.failureBehavior=fail-at-end - -# The expected result of the build, possible values are "success" (default) and "failure" -#invoker.buildResult=success - -# A boolean value controlling the -N flag, defaults to "false" -#invoker.nonRecursive=false Modified: trunk/i18n-maven-plugin/src/it/parsers/withNewKeys/pom.xml =================================================================== --- trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/pom.xml 2012-05-30 14:03:24 UTC (rev 1957) +++ trunk/i18n-maven-plugin/src/it/parsers/withNewKeys/pom.xml 2012-07-09 13:12:35 UTC (rev 1961) @@ -76,7 +76,7 @@ <plugin> <groupId>org.nuiton.i18n</groupId> - <artifactId>maven-i18n-plugin</artifactId> + <artifactId>i18n-maven-plugin</artifactId> <version>@pom.version@</version> <configuration> <keepGetters>true</keepGetters> Deleted: trunk/i18n-maven-plugin/src/it/parsers/withNewKeys/src/main/resources/org/nuiton/i18n/test/MyBean-validation.xml =================================================================== --- trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/src/main/resources/org/nuiton/i18n/test/MyBean-validation.xml 2012-05-30 14:03:24 UTC (rev 1957) +++ trunk/i18n-maven-plugin/src/it/parsers/withNewKeys/src/main/resources/org/nuiton/i18n/test/MyBean-validation.xml 2012-07-09 13:12:35 UTC (rev 1961) @@ -1,52 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - #%L - I18n :: Maven Plugin - - $Id$ - $HeadURL$ - %% - Copyright (C) 2007 - 2010 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>. - #L% - --> - -<!DOCTYPE validators PUBLIC - "-//OpenSymphony Group//XWork Validator 1.0.2//EN" - "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd"> -<validators> - - <validator type="required"> - <message>validationGetter.key3</message> - </validator> - - <field name="field1"> - - <field-validator type="required"> - <message>validationGetter.key1</message> - </field-validator> - - </field> - - <field name="field2"> - - <field-validator type="required"> - <message>validationGetter.key2##${parm1}</message> - </field-validator> - - </field> - -</validators> Copied: trunk/i18n-maven-plugin/src/it/parsers/withNewKeys/src/main/resources/org/nuiton/i18n/test/MyBean-validation.xml (from rev 1960, trunk/maven-i18n-plugin/src/it/parsers/withNewKeys/src/main/resources/org/nuiton/i18n/test/MyBean-validation.xml) =================================================================== --- trunk/i18n-maven-plugin/src/it/parsers/withNewKeys/src/main/resources/org/nuiton/i18n/test/MyBean-validation.xml (rev 0) +++ trunk/i18n-maven-plugin/src/it/parsers/withNewKeys/src/main/resources/org/nuiton/i18n/test/MyBean-validation.xml 2012-07-09 13:12:35 UTC (rev 1961) @@ -0,0 +1,52 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + #%L + I18n :: Maven Plugin + + $Id$ + $HeadURL$ + %% + Copyright (C) 2007 - 2010 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>. + #L% + --> + +<!DOCTYPE validators PUBLIC + "-//Apache Struts//XWork Validator 1.0.3//EN" + "http://struts.apache.org/dtds/xwork-validator-1.0.3.dtd"> +<validators> + + <validator type="required"> + <message>validationGetter.key3</message> + </validator> + + <field name="field1"> + + <field-validator type="required"> + <message>validationGetter.key1</message> + </field-validator> + + </field> + + <field name="field2"> + + <field-validator type="required"> + <message>validationGetter.key2##${parm1}</message> + </field-validator> + + </field> + +</validators> Deleted: trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nMojo.java =================================================================== --- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nMojo.java 2012-05-30 14:03:24 UTC (rev 1957) +++ trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nMojo.java 2012-07-09 13:12:35 UTC (rev 1961) @@ -1,336 +0,0 @@ -/* - * #%L - * I18n :: Maven Plugin - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2007 - 2010 CodeLutin, Tony Chemit - * %% - * 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>. - * #L% - */ - -package org.nuiton.i18n.plugin; - -import org.apache.maven.project.MavenProject; -import org.nuiton.i18n.I18nUtil; -import org.nuiton.plugin.AbstractPlugin; -import org.nuiton.plugin.PluginHelper; -import org.nuiton.plugin.PluginWithEncoding; - -import java.io.File; -import java.io.IOException; -import java.util.Locale; -import java.util.Map; -import java.util.Properties; -import java.util.SortedSet; -import java.util.TreeSet; - -/** - * Lower level i18n mojo abstraction. - * <p/> - * We defines here all commons parameters and shared behaviour. - * - * @author tchemit <chemit@codelutin.com> - * @author jruchaud <ruchaud@codelutin.com> - */ -public abstract class AbstractI18nMojo extends AbstractPlugin implements PluginWithEncoding { - - /** Le nombre de getters détectés pendant le cycle de vie du build. */ - private static int NB_GETTER_FILES; - - /** - * Dependance du projet. - * - * @parameter default-value="${project}" - * @required - * @since 1.0.2 - */ - protected MavenProject project; - - /** - * Name to use as prefix of generated files. - * <p/> - * <b>Note :</b> By default, use the artifact id. - * - * @parameter expression="${i18n.artifactId}" default-value="${project.artifactId}" - * @readonly - */ - protected String artifactId; - - /** - * Locales to treate, separated by comma. - * <p/> - * Example : - * <pre>fr_FR,en_GB</pre> - * - * @parameter expression="${i18n.bundles}" default-value="fr_FR,en_GB" - * @required - */ - protected String bundles; - - /** - * Directory where to find project i18n files. - * - * @parameter expression="${i18n.src}" default-value="${basedir}/src/main/resources/i18n" - * @required - */ - protected File src; - - /** - * Directory where to generate i18n files. - * - * @parameter expression="${i18n.out}" default-value="${basedir}/target/generated-sources/i18n" - * @required - */ - protected File out; - - /** - * Encoding used to load and store properties. - * - * @parameter expression="${i18n.encoding}" default-value="${project.build.sourceEncoding}" - * @required - */ - protected String encoding; - - /** - * To update generated files to user i18n files. - * <p/> - * <b>Note :</b> By default, this is active, in order to have a project uptodate - * with last i18n bundles detected. - * - * @parameter expression="${i18n.genSrc}" default-value="true" - */ - protected boolean genSrc; - - /** - * Verbose flag. - * <p/> - * <b>Note :</b> if not setted, we used the {@code maven.verbose} property. - * - * @parameter expression="${i18n.verbose}" default-value="${maven.verbose}" - */ - protected boolean verbose; - - /** - * Silent flag to see only errors in console. - * - * @parameter expression="${i18n.silent}" default-value="false" - * @since 1.0.0-rc-5 - */ - protected boolean silent; - - /** - * Strict mode to only keep in user i18n detected i18n keys and remove obsolete keys. - * <p/> - * <b>Note :</b> By default not active. Use this with care since it can - * delete keys. Moreover if this flag is activated, then all files will be parsed. - * - * @parameter expression="${i18n.strictMode}" default-value="false" - */ - protected boolean strictMode; - - /** locales to process */ - protected Locale[] locales; - - - @Override - protected boolean checkPackaging() { - - // nothing to do on a pom module - return !acceptPackaging(Packaging.pom); - } - - @Override - public void init() throws Exception { - - if (verbose) { - // in verbose mode, no silent - silent = false; - 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')"); - } - } - - public String getArtifactId() { - return artifactId; - } - - /** - * @return {@code true} si des getters ont etes enregistres pendant le - * cycle de vie, {@code false} 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++; - } - - /** - * @param root le repertoire ou sont stockes les fichiers i18n - * @param artifactId le nom de l'artifact - * @param locale le nom de la locale (peut-être nulle) - * @param create {@code true} pour creer le fichier si non present - * @return le fichier i18n - * @throws IOException si probleme lors de la creation du fichier - */ - public File getI18nFile(File root, - String artifactId, - Locale locale, - boolean create) throws IOException { - String path = root.getAbsolutePath() + File.separatorChar + artifactId; - if (locale != null) { - path += "_" + locale.toString(); - } - path += ".properties"; - File file = new File(path); - if (create && !file.exists()) { - createNewFile(file); - } - return file; - } - - /** - * @param root le repertoire ou sont stockes les fichiers getter - * @param getter le nom du getter - * @param create {@code true} pour creer le fichier si non present - * @return le fichier i18n - * @throws 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()) { - createNewFile(file); - } - return file; - } - - protected void checkBundle(Locale locale, - Properties propertiesOut, - boolean showEmpty, - Map<Locale, SortedSet<String>> unsafeHolder) { - - // on verifie qu'il n'y a pas de traduction vide - SortedSet<String> emptyEntries = PluginHelper.getEmptyKeys(propertiesOut); - if (!emptyEntries.isEmpty()) { - if (unsafeHolder != null) { - - // push empties i18n keys in the holder - SortedSet<String> empties = unsafeHolder.get(locale); - if (empties == null) { - empties = new TreeSet<String>(); - unsafeHolder.put(locale, empties); - } - empties.addAll(emptyEntries); - } - 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 - "); - buffer.append(index++); - buffer.append("/"); - buffer.append(size); - buffer.append(" : "); - buffer.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)."); - } - } - } - - - @Override - public File getBackupFile(File file) { - return new File(file.getAbsolutePath() + "~"); - } - - @Override - protected void backupFile(File f) throws IOException { - File dst = getBackupFile(f); - copyFile(f, dst); - } - - @Override - public MavenProject getProject() { - return project; - } - - @Override - public void setProject(MavenProject project) { - this.project = project; - } - - @Override - public boolean isVerbose() { - return verbose; - } - - @Override - public void setVerbose(boolean verbose) { - this.verbose = verbose; - } - - public boolean isSilent() { - return silent; - } - - public boolean isStrictMode() { - return strictMode; - } - - @Override - public String getEncoding() { - return encoding; - } - - @Override - public void setEncoding(String encoding) { - this.encoding = encoding; - } -} Copied: trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nMojo.java (from rev 1960, trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nMojo.java) =================================================================== --- trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nMojo.java (rev 0) +++ trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nMojo.java 2012-07-09 13:12:35 UTC (rev 1961) @@ -0,0 +1,318 @@ +/* + * #%L + * I18n :: Maven Plugin + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2007 - 2010 CodeLutin, Tony Chemit + * %% + * 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>. + * #L% + */ + +package org.nuiton.i18n.plugin; + +import org.apache.maven.plugins.annotations.Component; +import org.apache.maven.plugins.annotations.Parameter; +import org.apache.maven.project.MavenProject; +import org.nuiton.i18n.I18nUtil; +import org.nuiton.plugin.AbstractPlugin; +import org.nuiton.plugin.PluginHelper; +import org.nuiton.plugin.PluginWithEncoding; + +import java.io.File; +import java.io.IOException; +import java.util.Locale; +import java.util.Map; +import java.util.Properties; +import java.util.SortedSet; +import java.util.TreeSet; + +/** + * Lower level i18n mojo abstraction. + * <p/> + * We defines here all commons parameters and shared behaviour. + * + * @author tchemit <chemit@codelutin.com> + * @author jruchaud <ruchaud@codelutin.com> + */ +public abstract class AbstractI18nMojo extends AbstractPlugin implements PluginWithEncoding { + + /** Le nombre de getters détectés pendant le cycle de vie du build. */ + private static int NB_GETTER_FILES; + + /** + * Dependance du projet. + * + * @since 1.0.2 + */ + @Component + protected MavenProject project; + + /** + * Name to use as prefix of generated files. + * <p/> + * <b>Note :</b> By default, use the artifact id. + */ + @Parameter(property = "i18n.artifactId", defaultValue = "${project.artifactId}", readonly = true) + protected String artifactId; + + /** + * Locales to treate, separated by comma. + * <p/> + * Example : + * <pre>fr_FR,en_GB</pre> + */ + @Parameter(property = "i18n.bundles", defaultValue = "fr_FR,en_GB", required = true) + protected String bundles; + + /** Directory where to find project i18n files. */ + @Parameter(property = "i18n.src", defaultValue = "${basedir}/src/main/resources/i18n", required = true) + protected File src; + + /** Directory where to generate i18n files. */ + @Parameter(property = "i18n.out", defaultValue = "${basedir}/target/generated-sources/i18n", required = true) + protected File out; + + /** Encoding used to load and store properties. */ + @Parameter(property = "i18n.encoding", defaultValue = "${project.build.sourceEncoding}", required = true) + protected String encoding; + + /** + * To update generated files to user i18n files. + * <p/> + * <b>Note :</b> By default, this is active, in order to have a project uptodate + * with last i18n bundles detected. + */ + @Parameter(property = "i18n.genSrc", defaultValue = "true") + protected boolean genSrc; + + /** + * Verbose flag. + * <p/> + * <b>Note :</b> if not setted, we used the {@code maven.verbose} property. + */ + @Parameter(property = "i18n.verbose", defaultValue = "${maven.verbose}") + protected boolean verbose; + + /** + * Silent flag to see only errors in console. + * + * @since 1.0.0-rc-5 + */ + @Parameter(property = "i18n.silent", defaultValue = "false") + protected boolean silent; + + /** + * Strict mode to only keep in user i18n detected i18n keys and remove obsolete keys. + * <p/> + * <b>Note :</b> By default not active. Use this with care since it can + * delete keys. Moreover if this flag is activated, then all files will be parsed. + */ + @Parameter(property = "i18n.strictMode", defaultValue = "false") + protected boolean strictMode; + + /** locales to process */ + protected Locale[] locales; + + + @Override + protected boolean checkPackaging() { + + // nothing to do on a pom module + return !acceptPackaging(Packaging.pom); + } + + @Override + public void init() throws Exception { + + if (verbose) { + // in verbose mode, no silent + silent = false; + 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')"); + } + } + + public String getArtifactId() { + return artifactId; + } + + /** + * @return {@code true} si des getters ont etes enregistres pendant le + * cycle de vie, {@code false} 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++; + } + + /** + * @param root le repertoire ou sont stockes les fichiers i18n + * @param artifactId le nom de l'artifact + * @param locale le nom de la locale (peut-être nulle) + * @param create {@code true} pour creer le fichier si non present + * @return le fichier i18n + * @throws IOException si probleme lors de la creation du fichier + */ + public File getI18nFile(File root, + String artifactId, + Locale locale, + boolean create) throws IOException { + String path = root.getAbsolutePath() + File.separatorChar + artifactId; + if (locale != null) { + path += "_" + locale.toString(); + } + path += ".properties"; + File file = new File(path); + if (create && !file.exists()) { + createNewFile(file); + } + return file; + } + + /** + * @param root le repertoire ou sont stockes les fichiers getter + * @param getter le nom du getter + * @param create {@code true} pour creer le fichier si non present + * @return le fichier i18n + * @throws 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()) { + createNewFile(file); + } + return file; + } + + protected void checkBundle(Locale locale, + Properties propertiesOut, + boolean showEmpty, + Map<Locale, SortedSet<String>> unsafeHolder) { + + // on verifie qu'il n'y a pas de traduction vide + SortedSet<String> emptyEntries = PluginHelper.getEmptyKeys(propertiesOut); + if (!emptyEntries.isEmpty()) { + if (unsafeHolder != null) { + + // push empties i18n keys in the holder + SortedSet<String> empties = unsafeHolder.get(locale); + if (empties == null) { + empties = new TreeSet<String>(); + unsafeHolder.put(locale, empties); + } + empties.addAll(emptyEntries); + } + 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 - "); + buffer.append(index++); + buffer.append("/"); + buffer.append(size); + buffer.append(" : "); + buffer.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)."); + } + } + } + + + @Override + public File getBackupFile(File file) { + return new File(file.getAbsolutePath() + "~"); + } + + @Override + protected void backupFile(File f) throws IOException { + File dst = getBackupFile(f); + copyFile(f, dst); + } + + @Override + public MavenProject getProject() { + return project; + } + + @Override + public void setProject(MavenProject project) { + this.project = project; + } + + @Override + public boolean isVerbose() { + return verbose; + } + + @Override + public void setVerbose(boolean verbose) { + this.verbose = verbose; + } + + public boolean isSilent() { + return silent; + } + + public boolean isStrictMode() { + return strictMode; + } + + @Override + public String getEncoding() { + return encoding; + } + + @Override + public void setEncoding(String encoding) { + this.encoding = encoding; + } +} Deleted: trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/GenerateMojo.java =================================================================== --- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/GenerateMojo.java 2012-05-30 14:03:24 UTC (rev 1957) +++ trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/GenerateMojo.java 2012-07-09 13:12:35 UTC (rev 1961) @@ -1,175 +0,0 @@ -/* - * #%L - * I18n :: Maven Plugin - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2007 - 2010 CodeLutin, Tony Chemit - * %% - * 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>. - * #L% - */ - -package org.nuiton.i18n.plugin; - -import org.nuiton.io.SortedProperties; - -import java.io.File; -import java.util.Arrays; -import java.util.Locale; - -/** - * Merge new generated i18n bundles with older existing ones. - * - * @author jruchaud <ruchaud@codelutin.com> - * @author chemit <chemit@codelutin.com> - * @goal gen - * @phase generate-resources - * @execute goal=get - */ -public class GenerateMojo extends AbstractI18nMojo { - - /** - * A flag to check that bundles are complete (no missing i18n translations). - * - * @parameter expression="${i18n.checkBundle}" default-value="true" - * @required - * @since 1.0.0 - */ - protected boolean checkBundle; - - /** - * A flag to show missing i18n translation. - * <p/> - * <b>Note :</b> Need the {@link #checkBundle} to be activated). - * - * @parameter expression="${i18n.showEmpty}" default-value="false" - * @required - * @since 1.0.0 - */ - protected boolean showEmpty; - - /** - * To keep a backup of old i18n bundles (suffiex by a {@code ~}). - * <p/> - * <b>Note: </b> By default, this property is not active. - * - * @parameter expression="${i18n.keepBackup}" default-value="false" - */ - protected boolean keepBackup; - - /** - * To keep generated getter files. - * <p/> - * <b>Note: </b> By default, this property is not active. - * - * @parameter expression="${i18n.keepGetters}" default-value="false" - */ - protected boolean keepGetters; - - @Override - protected boolean checkSkip() { - if (!needGeneration()) { - 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()); - getLog().info("config - locales : " + Arrays.toString(locales)); - } - for (Locale locale : locales) { - if (!silent) { - getLog().info("prepare bundle for locale " + locale); - } - // Merge - File bundleSrc = getI18nFile(src, artifactId, locale, false); - File bundleOut = getI18nFile(out, artifactId, locale, false); - File bundleGetterOut = getI18nFile( - out, artifactId + GetterMojo.FROM_GETTERS, 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(bundleGetterOut); - - // 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, ""); - } - } - - propertiesOut.store(bundleOut); - - // Sauvegarde avant copie - if (genSrc && keepBackup) { - backupFile(bundleSrc); - } - if (!silent) { - getLog().info("merge bundle " + locale + " to out"); - } - - if (checkBundle) { - checkBundle(locale, propertiesOut, showEmpty, null); - } - - if (genSrc) { - // Copie des fichiers dans les sources -// copyFile(bundleOut, bundleSrc); - - propertiesOut.store(bundleSrc); - - if (!silent) { - getLog().info("copy bundle " + locale + " to src"); - } - } - - if (!keepGetters) { - if (isVerbose()) { - getLog().info("Will delete getter " + bundleGetterOut); - } - deleteFile(bundleGetterOut); - } - } - } -} Copied: trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/GenerateMojo.java (from rev 1958, trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/GenerateMojo.java) =================================================================== --- trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/GenerateMojo.java (rev 0) +++ trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/GenerateMojo.java 2012-07-09 13:12:35 UTC (rev 1961) @@ -0,0 +1,174 @@ +/* + * #%L + * I18n :: Maven Plugin + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2007 - 2010 CodeLutin, Tony Chemit + * %% + * 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>. + * #L% + */ + +package org.nuiton.i18n.plugin; + +import org.apache.maven.plugins.annotations.Execute; +import org.apache.maven.plugins.annotations.LifecyclePhase; +import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.plugins.annotations.Parameter; +import org.nuiton.io.SortedProperties; + +import java.io.File; +import java.util.Arrays; +import java.util.Locale; + +/** + * Merge new generated i18n bundles with older existing ones. + * + * @author jruchaud <ruchaud@codelutin.com> + * @author chemit <chemit@codelutin.com> + */ +@Mojo(name = "gen", defaultPhase = LifecyclePhase.GENERATE_RESOURCES) +@Execute(goal = "get") +public class GenerateMojo extends AbstractI18nMojo { + + /** + * A flag to check that bundles are complete (no missing i18n translations). + * + * @since 1.0.0 + */ + @Parameter(property = "i18n.checkBundle", defaultValue = "true", required = true) + protected boolean checkBundle; + + /** + * A flag to show missing i18n translation. + * <p/> + * <b>Note :</b> Need the {@link #checkBundle} to be activated). + * + * @since 1.0.0 + */ + @Parameter(property = "i18n.showEmpty", defaultValue = "false", required = true) + protected boolean showEmpty; + + /** + * To keep a backup of old i18n bundles (suffiex by a {@code ~}). + * <p/> + * <b>Note: </b> By default, this property is not active. + */ + @Parameter(property = "i18n.keepBackup", defaultValue = "false") + protected boolean keepBackup; + + /** + * To keep generated getter files. + * <p/> + * <b>Note: </b> By default, this property is not active. + */ + @Parameter(property = "i18n.keepGetters", defaultValue = "false") + protected boolean keepGetters; + + @Override + protected boolean checkSkip() { + if (!needGeneration()) { + 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()); + getLog().info("config - locales : " + Arrays.toString(locales)); + } + for (Locale locale : locales) { + if (!silent) { + getLog().info("prepare bundle for locale " + locale); + } + // Merge + File bundleSrc = getI18nFile(src, artifactId, locale, false); + File bundleOut = getI18nFile(out, artifactId, locale, false); + File bundleGetterOut = getI18nFile( + out, artifactId + GetterMojo.FROM_GETTERS, 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(bundleGetterOut); + + // 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, ""); + } + } + + propertiesOut.store(bundleOut); + + // Sauvegarde avant copie + if (genSrc && keepBackup) { + backupFile(bundleSrc); + } + if (!silent) { + getLog().info("merge bundle " + locale + " to out"); + } + + if (checkBundle) { + checkBundle(locale, propertiesOut, showEmpty, null); + } + + if (genSrc) { + // Copie des fichiers dans les sources +// copyFile(bundleOut, bundleSrc); + + propertiesOut.store(bundleSrc); + + if (!silent) { + getLog().info("copy bundle " + locale + " to src"); + } + } + + if (!keepGetters) { + if (isVerbose()) { + getLog().info("Will delete getter " + bundleGetterOut); + } + deleteFile(bundleGetterOut); + } + } + } +} Deleted: trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/GetterMojo.java =================================================================== --- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/GetterMojo.java 2012-05-30 14:03:24 UTC (rev 1957) +++ trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/GetterMojo.java 2012-07-09 13:12:35 UTC (rev 1961) @@ -1,131 +0,0 @@ -/* - * #%L - * I18n :: Maven Plugin - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2007 - 2010 CodeLutin, Tony Chemit - * %% - * 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>. - * #L% - */ - -package org.nuiton.i18n.plugin; - -import org.codehaus.plexus.util.DirectoryScanner; -import org.nuiton.io.SortedProperties; -import org.nuiton.plugin.PluginHelper; - -import java.io.File; -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 { - - /** - * To keep generated getter files. - * <p/> - * <b>Note: </b> By default, this property is not active. - * - * @parameter expression="${i18n.keepGetters}" default-value="false" - */ - protected boolean keepGetters; - - protected static final String FROM_GETTERS = "-fromGetters"; - - @Override - protected boolean checkSkip() { - - if (!needGeneration()) { - 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 - basedir : " + out.getAbsolutePath()); - getLog().info("config - locales : " + Arrays.toString(locales)); - } - - File bundleGetters = new File(out.getAbsoluteFile(), - artifactId + ".properties"); - - createDirectoryIfNecessary(bundleGetters.getParentFile()); - - SortedProperties propertiesOut = new SortedProperties(encoding); - - 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); - - // chargement du getter - SortedProperties propertiesIn = - new SortedProperties(encoding).load(bundleGetter); - - // ajout des entrées dans le bundle - propertiesOut.putAll(propertiesIn); - - if (!keepGetters) { - if (isVerbose()) { - getLog().info("Will delete getter " + bundleGetter); - } - deleteFile(bundleGetter); - } - if (!silent) { - String time = PluginHelper.convertTime(System.nanoTime() - t0); - getLog().info("import getter " + bundleGetter.getName() + - " in " + time); - } - } - - // sauvegarde du fichier des getters - propertiesOut.store(bundleGetters); - - // Création des bundles - for (Locale locale : locales) { - if (getLog().isDebugEnabled()) { - getLog().debug("generate bundle for locale " + locale); - } - File bundleOut = getI18nFile(out, artifactId + FROM_GETTERS, locale, false); - copyFile(bundleGetters, bundleOut); - if (!silent && verbose) { - getLog().info("generate bundle " + locale); - } - } - if (!keepGetters) { - deleteFile(bundleGetters); - } - } - -} Copied: trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/GetterMojo.java (from rev 1958, trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/GetterMojo.java) =================================================================== --- trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/GetterMojo.java (rev 0) +++ trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/GetterMojo.java 2012-07-09 13:12:35 UTC (rev 1961) @@ -0,0 +1,132 @@ +/* + * #%L + * I18n :: Maven Plugin + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2007 - 2010 CodeLutin, Tony Chemit + * %% + * 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>. + * #L% + */ + +package org.nuiton.i18n.plugin; + +import org.apache.maven.plugins.annotations.LifecyclePhase; +import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.plugins.annotations.Parameter; +import org.codehaus.plexus.util.DirectoryScanner; +import org.nuiton.io.SortedProperties; +import org.nuiton.plugin.PluginHelper; + +import java.io.File; +import java.util.Arrays; +import java.util.Locale; + +/** + * Recupere les différents fichiers des parsers en un fichier de proprietes. + * + * @author julien + */ +@Mojo(name = "get", defaultPhase = LifecyclePhase.GENERATE_RESOURCES) +public class GetterMojo extends AbstractI18nMojo { + + /** + * To keep generated getter files. + * <p/> + * <b>Note: </b> By default, this property is not active. + */ + @Parameter(property = "i18n.keepGetters", defaultValue = "false") + protected boolean keepGetters; + + protected static final String FROM_GETTERS = "-fromGetters"; + + @Override + protected boolean checkSkip() { + + if (!needGeneration()) { + 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 - basedir : " + out.getAbsolutePath()); + getLog().info("config - locales : " + Arrays.toString(locales)); + } + + File bundleGetters = new File(out.getAbsoluteFile(), + artifactId + ".properties"); + + createDirectoryIfNecessary(bundleGetters.getParentFile()); + + SortedProperties propertiesOut = new SortedProperties(encoding); + + 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); + + // chargement du getter + SortedProperties propertiesIn = + new SortedProperties(encoding).load(bundleGetter); + + // ajout des entrées dans le bundle + propertiesOut.putAll(propertiesIn); + + if (!keepGetters) { + if (isVerbose()) { + getLog().info("Will delete getter " + bundleGetter); + } + deleteFile(bundleGetter); + } + if (!silent) { + String time = PluginHelper.convertTime(System.nanoTime() - t0); + getLog().info("import getter " + bundleGetter.getName() + + " in " + time); + } + } + + // sauvegarde du fichier des getters + propertiesOut.store(bundleGetters); + + // Création des bundles + for (Locale locale : locales) { + if (getLog().isDebugEnabled()) { + getLog().debug("generate bundle for locale " + locale); + } + File bundleOut = getI18nFile(out, artifactId + FROM_GETTERS, locale, false); + copyFile(bundleGetters, bundleOut); + if (!silent && verbose) { + getLog().info("generate bundle " + locale); + } + } + if (!keepGetters) { + deleteFile(bundleGetters); + } + } + +} Deleted: trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/AbstractI18nBundleMojo.java =================================================================== --- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/AbstractI18nBundleMojo.java 2012-05-30 14:03:24 UTC (rev 1957) +++ trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/AbstractI18nBundleMojo.java 2012-07-09 13:12:35 UTC (rev 1961) @@ -1,93 +0,0 @@ -/* - * #%L - * I18n :: Maven Plugin - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2007 - 2010 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>. - * #L% - */ - -package org.nuiton.i18n.plugin.bundle; - -import org.nuiton.i18n.plugin.AbstractI18nMojo; - -import java.io.File; -import java.io.IOException; -import java.net.URL; -import java.util.Locale; - -/** - * Created: 26 déc. 2009 - * - * @author tchemit <chemit@codelutin.com> - * @since 1.0 - */ -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; - } - -} Copied: trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/AbstractI18nBundleMojo.java (from rev 1958, trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/AbstractI18nBundleMojo.java) =================================================================== --- trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/AbstractI18nBundleMojo.java (rev 0) +++ trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/AbstractI18nBundleMojo.java 2012-07-09 13:12:35 UTC (rev 1961) @@ -0,0 +1,91 @@ +/* + * #%L + * I18n :: Maven Plugin + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2007 - 2010 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>. + * #L% + */ + +package org.nuiton.i18n.plugin.bundle; + +import org.apache.maven.plugins.annotations.Parameter; +import org.nuiton.i18n.plugin.AbstractI18nMojo; + +import java.io.File; +import java.io.IOException; +import java.net.URL; +import java.util.Locale; + +/** + * Created: 26 déc. 2009 + * + * @author tchemit <chemit@codelutin.com> + * @since 1.0 + */ +public abstract class AbstractI18nBundleMojo extends AbstractI18nMojo { + + /** + * Directory where to generate bundles. + * + * @since 1.0.2 + */ + @Parameter(property = "i18n.collectOutputDir", defaultValue = "${basedir}/target/i18n", required = true) + protected File collectOutputDir; + + /** + * BAse name of file which contains bundles locations. + * + * @since 1.0.2 + */ + @Parameter(property = "i18n.collectOutputName", defaultValue = "collect-${project.artifactId}-i18n", required = true) + 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; + } + +} Deleted: trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/AbstractMakeI18nBundleMojo.java =================================================================== --- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/AbstractMakeI18nBundleMojo.java 2012-05-30 14:03:24 UTC (rev 1957) +++ trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/AbstractMakeI18nBundleMojo.java 2012-07-09 13:12:35 UTC (rev 1961) @@ -1,286 +0,0 @@ -/* - * #%L - * I18n :: Maven Plugin - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2007 - 2010 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>. - * #L% - */ -package org.nuiton.i18n.plugin.bundle; - -import org.apache.commons.io.FileUtils; -import org.apache.commons.lang.StringUtils; -import org.apache.maven.plugin.MojoFailureException; - -import java.io.File; -import java.io.IOException; -import java.util.HashMap; -import java.util.Locale; -import java.util.Map; -import java.util.SortedSet; - -/** - * Common mojo to all final bundle maker. - * - * @author tchemit <chemit@codelutin.com> - * @since 2.0 - */ -public abstract class AbstractMakeI18nBundleMojo extends AbstractI18nBundleMojo { - - /** - * Encoding used to load any i18n property files. - * <p/> - * If not defined, will use the {@link #encoding} parameter. - * - * @parameter expression="${i18n.bundleInputEncoding}" - * @since 2.4 - */ - protected String bundleInputEncoding; - - /** - * Encoding used to write any i18n property files. - * <p/> - * If not defined, will use the {@link #encoding} parameter. - * - * @parameter expression="${i18n.bundleOutputEncoding}" - * @since 2.4 - */ - protected String bundleOutputEncoding; - - /** - * Root directory where to generate aggregated bundles (this directory will - * be added as resources of the project). - * - * @parameter expression="${i18n.bundleOutputDir}" default-value="${basedir}/target/generated-sources/resources" - * @required - * @since 1.0.0 - */ - protected File bundleOutputDir; - - /** - * Package name of the generate aggregated bundles. - * <p/> - * <strong>Note:</strong> By default we use the <code>META-INF</code> package - * since it is the favorite package of <code>I18n</code> runtime initializer. - * <p/> - * The package name is dotted as it will be stored as folder like in Java - * language. - * <p/> - * Example : - * <pre> - * package name : foo.bar - * directory : foo/bar - * </pre> - * - * @parameter expression="${i18n.bundleOutputPackage}" default-value="META-INF" - * @required - * @since 2.3.2 - */ - protected String bundleOutputPackage; - - /** - * Name of the bundle to generate. - * - * @parameter expression="${i18n.bundleOutputName}" default-value="${project.artifactId}-i18n" - * @required - * @since 1.0.2 - */ - protected String bundleOutputName; - - /** - * A flag to generate a bundle with the first locale defined as a default - * bundle (with no locale specialization). - * - * @parameter expression="${i18n.generateDefaultLocale}" default-value="false" - * @since 2.1 - */ - protected boolean generateDefaultLocale; - - /** - * A flag to check that bundles are complete (no missing i18n translations). - * <p/> - * <b>Note :</b> This behaviour will be activated is {@link #failsIfWarning} is on. - * - * @parameter expression="${i18n.checkBundle}" default-value="true" - * @since 1.0.0 - */ - protected boolean checkBundle; - - /** - * A flag to show missing i18n translation. - * <p/> - * <b>Note :</b> Need the {@link #checkBundle} to be activated). - * - * @parameter expression="${i18n.showEmpty}" default-value="false" - * @since 1.0.0 - */ - protected boolean showEmpty; - - /** - * A flag to make the build fails if there is some warnings while generating - * bundle, says when it misses some translations. - * <p/> - * <b>Note :</b> This parameter should be used in a release profile to - * ensure bundles are complete. - * - * @parameter expression="${i18n.failsIfWarning}" default-value="false" - * @since 2.0 - */ - protected boolean failsIfWarning; - - /** to keep all none translated i18n keys by locale. */ - protected Map<Locale, SortedSet<String>> unsafeMapping; - - /** - * The definitive directory where to generate the bundles (includes the - * package of bunlde). - * - * @since 2.3.2 - */ - protected File outputFolder; - - @Override - public void init() throws Exception { - super.init(); - - if (failsIfWarning) { - - // check bundle if wants to fail on unsafe bundles - checkBundle = true; - - unsafeMapping = new HashMap<Locale, SortedSet<String>>(); - } else { - unsafeMapping = null; - } - - // get the definitive folder where to generate bundles (including - // bundle package) - - outputFolder = getBundleOutputFolder(); - - if (isVerbose()) { - getLog().info("Will generates bundles in " + outputFolder); - } - createDirectoryIfNecessary(outputFolder); - - if (StringUtils.isEmpty(bundleInputEncoding)) { - - // use the default encoding - bundleInputEncoding = getEncoding(); - if (getLog().isDebugEnabled()) { - getLog().debug("Use as input encoding the default one : " + - bundleInputEncoding); - } - } - - if (StringUtils.isEmpty(bundleOutputEncoding)) { - - // use the default encoding - bundleOutputEncoding = getEncoding(); - - if (getLog().isDebugEnabled()) { - getLog().debug("Use as output encoding the default one : " + - bundleOutputEncoding); - } - } - } - - protected void failsIfWarning() throws MojoFailureException { - if (!failsIfWarning) { - - // no check - return; - } - - if (unsafeMapping != null && !unsafeMapping.isEmpty()) { - - // there is at least one not complete bundle, faisl the build - throw new MojoFailureException( - "Bundles for locale(s) " + unsafeMapping.keySet() + - " are not complete. Use the -Di18n.showEmpty to see " + - "missing translations."); - } - } - - /** - * Gets the bundle file for the given parameters. - * - * @param root the root directory where bundles are stored - * @param artifactId the artifactId (says the prefix of bundle) - * @param locale the locale used in bundle ({@code null} means no locale specialized) - * @param create a flag to create the file if none existing - * @return the bundle file - * @throws IOException if any IO problem while creating it (if needed). - * @since 2.1 - */ - protected abstract File getBundleFile(File root, - String artifactId, - Locale locale, - boolean create) throws IOException; - - /** - * Generates the default bundle, says the bundle with no locale specialized. - * <p/> - * This bundle is a copy of the bundle of the first locale (which in fact - * is considered as the main locale). - * - * @throws IOException if any IO problem while the copy. - * @since 2.1 - */ - protected void generateDefaultBundle() throws IOException { - - File bundleFirstLocale = getBundleFile(outputFolder, - bundleOutputName, - locales[0], - false - ); - - File bundleWithoutLocale = getBundleFile(outputFolder, - bundleOutputName, - null, - false - ); - - if (!isSilent()) { - getLog().info("Generate default bundle at " + bundleWithoutLocale); - } - - FileUtils.copyFile(bundleFirstLocale, bundleWithoutLocale); - } - - protected File getBundleOutputFolder() { - File result = bundleOutputDir; - if (StringUtils.isNotEmpty(bundleOutputPackage)) { - String[] paths = bundleOutputPackage.split("\\."); - for (String path : paths) { - result = new File(result, path); - } - } - return result; - } - - public String getBundleOutputEncoding() { - return bundleOutputEncoding; - } - - public String getBundleInputEncoding() { - return bundleInputEncoding; - } - -} Copied: trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/AbstractMakeI18nBundleMojo.java (from rev 1958, trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/AbstractMakeI18nBundleMojo.java) =================================================================== --- trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/AbstractMakeI18nBundleMojo.java (rev 0) +++ trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/AbstractMakeI18nBundleMojo.java 2012-07-09 13:12:35 UTC (rev 1961) @@ -0,0 +1,284 @@ +/* + * #%L + * I18n :: Maven Plugin + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2007 - 2010 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>. + * #L% + */ +package org.nuiton.i18n.plugin.bundle; + +import org.apache.commons.io.FileUtils; +import org.apache.commons.lang.StringUtils; +import org.apache.maven.plugin.MojoFailureException; +import org.apache.maven.plugins.annotations.Parameter; + +import java.io.File; +import java.io.IOException; +import java.util.HashMap; +import java.util.Locale; +import java.util.Map; +import java.util.SortedSet; + +/** + * Common mojo to all final bundle maker. + * + * @author tchemit <chemit@codelutin.com> + * @since 2.0 + */ +public abstract class AbstractMakeI18nBundleMojo extends AbstractI18nBundleMojo { + + /** + * Encoding used to load any i18n property files. + * <p/> + * If not defined, will use the {@link #encoding} parameter. + * + * @since 2.4 + */ + @Parameter(property = "i18n.bundleInputEncoding") + protected String bundleInputEncoding; + + /** + * Encoding used to write any i18n property files. + * <p/> + * If not defined, will use the {@link #encoding} parameter. + * + * @since 2.4 + */ + @Parameter(property = "i18n.bundleOutputEncoding") + protected String bundleOutputEncoding; + + /** + * Root directory where to generate aggregated bundles (this directory will + * be added as resources of the project). + * + * @since 1.0.0 + */ + @Parameter(property = "i18n.bundleOutputDir", defaultValue = "${basedir}/target/generated-sources/resources", required = true) + protected File bundleOutputDir; + + /** + * Package name of the generate aggregated bundles. + * <p/> + * <strong>Note:</strong> By default we use the <code>META-INF</code> package + * since it is the favorite package of <code>I18n</code> runtime initializer. + * <p/> + * The package name is dotted as it will be stored as folder like in Java + * language. + * <p/> + * Example : + * <pre> + * package name : foo.bar + * directory : foo/bar + * </pre> + * + * @since 2.3.2 + */ + @Parameter(property = "i18n.bundleOutputPackage", defaultValue = "META-INF", required = true) + protected String bundleOutputPackage; + + /** + * Name of the bundle to generate. + * + * @since 1.0.2 + */ + @Parameter(property = "i18n.bundleOutputName", defaultValue = "${project.artifactId}-i18n", required = true) + protected String bundleOutputName; + + /** + * A flag to generate a bundle with the first locale defined as a default + * bundle (with no locale specialization). + * + * @since 2.1 + */ + @Parameter(property = "i18n.generateDefaultLocale", defaultValue = "false") + protected boolean generateDefaultLocale; + + /** + * A flag to check that bundles are complete (no missing i18n translations). + * <p/> + * <b>Note :</b> This behaviour will be activated is {@link #failsIfWarning} is on. + * + * @since 1.0.0 + */ + @Parameter(property = "i18n.checkBundle", defaultValue = "true") + protected boolean checkBundle; + + /** + * A flag to show missing i18n translation. + * <p/> + * <b>Note :</b> Need the {@link #checkBundle} to be activated). + * + * @since 1.0.0 + */ + @Parameter(property = "i18n.showEmpty", defaultValue = "false") + protected boolean showEmpty; + + /** + * A flag to make the build fails if there is some warnings while generating + * bundle, says when it misses some translations. + * <p/> + * <b>Note :</b> This parameter should be used in a release profile to + * ensure bundles are complete. + * + * @since 2.0 + */ + @Parameter(property = "i18n.failsIfWarning", defaultValue = "false") + protected boolean failsIfWarning; + + /** to keep all none translated i18n keys by locale. */ + protected Map<Locale, SortedSet<String>> unsafeMapping; + + /** + * The definitive directory where to generate the bundles (includes the + * package of bunlde). + * + * @since 2.3.2 + */ + protected File outputFolder; + + @Override + public void init() throws Exception { + super.init(); + + if (failsIfWarning) { + + // check bundle if wants to fail on unsafe bundles + checkBundle = true; + + unsafeMapping = new HashMap<Locale, SortedSet<String>>(); + } else { + unsafeMapping = null; + } + + // get the definitive folder where to generate bundles (including + // bundle package) + + outputFolder = getBundleOutputFolder(); + + if (isVerbose()) { + getLog().info("Will generates bundles in " + outputFolder); + } + createDirectoryIfNecessary(outputFolder); + + if (StringUtils.isEmpty(bundleInputEncoding)) { + + // use the default encoding + bundleInputEncoding = getEncoding(); + if (getLog().isDebugEnabled()) { + getLog().debug("Use as input encoding the default one : " + + bundleInputEncoding); + } + } + + if (StringUtils.isEmpty(bundleOutputEncoding)) { + + // use the default encoding + bundleOutputEncoding = getEncoding(); + + if (getLog().isDebugEnabled()) { + getLog().debug("Use as output encoding the default one : " + + bundleOutputEncoding); + } + } + } + + protected void failsIfWarning() throws MojoFailureException { + if (!failsIfWarning) { + + // no check + return; + } + + if (unsafeMapping != null && !unsafeMapping.isEmpty()) { + + // there is at least one not complete bundle, faisl the build + throw new MojoFailureException( + "Bundles for locale(s) " + unsafeMapping.keySet() + + " are not complete. Use the -Di18n.showEmpty to see " + + "missing translations."); + } + } + + /** + * Gets the bundle file for the given parameters. + * + * @param root the root directory where bundles are stored + * @param artifactId the artifactId (says the prefix of bundle) + * @param locale the locale used in bundle ({@code null} means no locale specialized) + * @param create a flag to create the file if none existing + * @return the bundle file + * @throws IOException if any IO problem while creating it (if needed). + * @since 2.1 + */ + protected abstract File getBundleFile(File root, + String artifactId, + Locale locale, + boolean create) throws IOException; + + /** + * Generates the default bundle, says the bundle with no locale specialized. + * <p/> + * This bundle is a copy of the bundle of the first locale (which in fact + * is considered as the main locale). + * + * @throws IOException if any IO problem while the copy. + * @since 2.1 + */ + protected void generateDefaultBundle() throws IOException { + + File bundleFirstLocale = getBundleFile(outputFolder, + bundleOutputName, + locales[0], + false + ); + + File bundleWithoutLocale = getBundleFile(outputFolder, + bundleOutputName, + null, + false + ); + + if (!isSilent()) { + getLog().info("Generate default bundle at " + bundleWithoutLocale); + } + + FileUtils.copyFile(bundleFirstLocale, bundleWithoutLocale); + } + + protected File getBundleOutputFolder() { + File result = bundleOutputDir; + if (StringUtils.isNotEmpty(bundleOutputPackage)) { + String[] paths = bundleOutputPackage.split("\\."); + for (String path : paths) { + result = new File(result, path); + } + } + return result; + } + + public String getBundleOutputEncoding() { + return bundleOutputEncoding; + } + + public String getBundleInputEncoding() { + return bundleInputEncoding; + } + +} Deleted: trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/AvailableConverterMojo.java =================================================================== --- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/AvailableConverterMojo.java 2012-05-30 14:03:24 UTC (rev 1957) +++ trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/AvailableConverterMojo.java 2012-07-09 13:12:35 UTC (rev 1961) @@ -1,79 +0,0 @@ -/* - * #%L - * I18n :: Maven Plugin - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2007 - 2011 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>. - * #L% - */ -package org.nuiton.i18n.plugin.bundle; - -import org.nuiton.plugin.AbstractAvailableDataMojo; - -import java.util.Arrays; -import java.util.Collection; -import java.util.Map; - -/** - * Mojo used to display available {@link BundleFormatConverter}. - * <p/> - * Created: 09/05/11 - * - * @author fdesbois <desbois@codelutin.com> - * $Id$ - * @goal available-converters - * @requiresProject true - * @requiresDirectInvocation true - * @requiresDependencyResolution test - * @since 2.4 - */ -public class AvailableConverterMojo extends AbstractAvailableDataMojo { - - /** - * Map of all availables {@link BundleFormatConverter}. - * - * @component role="org.nuiton.i18n.plugin.bundle.BundleFormatConverter" - */ - protected Map<String, BundleFormatConverter> bundleFormatConverters; - - @Override - protected Collection<AvailableData> getAllAvailableDatas() { - - AvailableData data = new AvailableData() { - - @Override - public String name() { - return "bundleFormatConverter"; - } - - @Override - public Map<String, ?> getData() { - return bundleFormatConverters; - } - - @Override - public String toString(Object value) { - return value.getClass().getName(); - } - }; - - return Arrays.asList(data); - } - -} Copied: trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/AvailableConverterMojo.java (from rev 1958, trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/AvailableConverterMojo.java) =================================================================== --- trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/AvailableConverterMojo.java (rev 0) +++ trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/AvailableConverterMojo.java 2012-07-09 13:12:35 UTC (rev 1961) @@ -0,0 +1,83 @@ +/* + * #%L + * I18n :: Maven Plugin + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2007 - 2011 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>. + * #L% + */ +package org.nuiton.i18n.plugin.bundle; + +import org.apache.maven.plugins.annotations.Component; +import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.plugins.annotations.ResolutionScope; +import org.nuiton.plugin.AbstractAvailableDataMojo; + +import java.util.Arrays; +import java.util.Collection; +import java.util.Map; + +/** + * Mojo used to display available {@link BundleFormatConverter}. + * <p/> + * Created: 09/05/11 + * + * @author fdesbois <desbois@codelutin.com> + * $Id$ + * @since 2.4 + */ +@Mojo(name = "available-converters", + requiresProject = true, + requiresDirectInvocation = true, + requiresDependencyResolution = ResolutionScope.TEST) +public class AvailableConverterMojo extends AbstractAvailableDataMojo { + + /** + * Map of all availables {@link BundleFormatConverter}. + * + * @since 2.4 + */ + @Component(role = BundleFormatConverter.class) + protected Map<String, BundleFormatConverter> bundleFormatConverters; + + @Override + protected Collection<AvailableData> getAllAvailableDatas() { + + AvailableData data = new AvailableData() { + + @Override + public String name() { + return "bundleFormatConverter"; + } + + @Override + public Map<String, ?> getData() { + return bundleFormatConverters; + } + + @Override + public String toString(Object value) { + return value.getClass().getName(); + } + }; + + return Arrays.asList(data); + } + +} Deleted: trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/BundleMojo.java =================================================================== --- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/BundleMojo.java 2012-05-30 14:03:24 UTC (rev 1957) +++ trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/BundleMojo.java 2012-07-09 13:12:35 UTC (rev 1961) @@ -1,301 +0,0 @@ -/* - * #%L - * I18n :: Maven Plugin - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2007 - 2010 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>. - * #L% - */ - -package org.nuiton.i18n.plugin.bundle; - -import org.apache.commons.lang.StringUtils; -import org.apache.maven.plugin.MojoExecutionException; -import org.nuiton.i18n.bundle.I18nBundleEntry; -import org.nuiton.i18n.bundle.I18nBundleUtil; -import org.nuiton.i18n.init.DefaultI18nInitializer; -import org.nuiton.io.SortedProperties; -import org.nuiton.plugin.PluginHelper; - -import java.io.File; -import java.io.IOException; -import java.net.URL; -import java.nio.charset.Charset; -import java.util.ArrayList; -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 java.util.Properties; - -/** - * Generate an aggregate i18n bundle for all dependencies of the project. - * <p/> - * The main idea is to have a final unique i18n bundle for a application to - * launch, this really improve i18n loading time to have a unique named bundle, - * no need to seek in all dependencies... - * <p/> - * Moreover, this permits also to deal with order of i18n keys, more precisly, - * we want to use the higher level i18n key for an application. If the i18n - * key is present on a library, we want to be able to override it in - * application (or user wants it:)). - * <p/> - * This goal permits this using the dependencies graph order of artifacts. - * - * @author tchemit <chemit@codelutin.com> - * @goal bundle - * @phase generate-resources - * @execute goal=collect-i18n-artifacts - * @requiresProject true - * @requiresDependencyResolution runtime - * @since 0.12 - */ -public class BundleMojo extends AbstractMakeI18nBundleMojo { - - /** - * A flag to generate the i18n definition file. - * <p/> - * This file contains all generated bundles and the paths of all i18n - * artifacts used to make it. - * - * @parameter expression="${i18n.generateDefinitionFile}" default-value="true" - * @since 2.0 - */ - protected boolean generateDefinitionFile; - - /** - * Converter used to change format of bundles. - * - * @parameter expression="${i18n.bundleFormatConverter}" - * @since 2.4 - */ - protected String bundleFormatConverter; - - /** - * Map of all availables {@link BundleFormatConverter}. - * - * @component role="org.nuiton.i18n.plugin.bundle.BundleFormatConverter" - * @since 2.4 - */ - protected Map<String, BundleFormatConverter> bundleFormatConverters; - - /** Format converter to apply if */ - protected BundleFormatConverter converter; - - @Override - public void init() throws Exception { - super.init(); - - // add root bundle directory as resources of the project - - addResourceDir(bundleOutputDir, "**/*.properties"); - - if (StringUtils.isNotEmpty(bundleFormatConverter)) { - - // get converter from universe - converter = bundleFormatConverters.get(bundleFormatConverter); - - if (converter == null) { - - // unknown converter - throw new MojoExecutionException( - "There is no bundleFormatConverter named \"" + - bundleFormatConverter + "\", known ones are " + - bundleFormatConverters.keySet()); - } - } - } - - @Override - protected void doAction() throws Exception { - long t00 = System.nanoTime(); - - String version = getProject().getVersion(); - version = PluginHelper.removeSnapshotSuffix(version); - - String inputEncoding = getBundleInputEncoding(); - String outputEncoding = getBundleOutputEncoding(); - - if (!silent) { - getLog().info("config - resources dir : " + bundleOutputDir); - getLog().info("config - package name : " + bundleOutputPackage); - getLog().info("config - bundle name : " + bundleOutputName); - getLog().info("config - input encoding : " + inputEncoding); - getLog().info("config - output encoding : " + outputEncoding); - if (bundleFormatConverter != null) { - getLog().info("config - format converter : " + bundleFormatConverter); - } - getLog().info("config - locales : " + Arrays.toString(locales)); - getLog().info("config - version : " + version); - } - - Map<Locale, String> bundleDico = - new LinkedHashMap<Locale, String>(locales.length); - - for (Locale locale : locales) { - - long t0 = System.nanoTime(); - - File bundleOut = getI18nFile(outputFolder, - bundleOutputName, - locale, - false - ); - - SortedProperties propertiesOut = - new SortedProperties(outputEncoding, false); - StringBuilder buffer = new StringBuilder(); - - URL[] urls = getCollectI18nResources(locale); - if (urls.length == 0) { - getLog().warn("no bundle for locale " + locale); - continue; - } - - if (!silent) { - getLog().info("generate bundle for locale " + locale + - " from " + urls.length + " i18n resource(s)"); - } - - List<String> bundlesUrls = new ArrayList<String>(); - - Charset loadEncoding = Charset.forName(inputEncoding); - for (URL url : urls) { - long t000 = System.nanoTime(); - I18nBundleEntry bundleEntry = - new I18nBundleEntry(url, locale, null); - bundleEntry.load(propertiesOut, loadEncoding); - String strPath = bundleEntry.getPath().toString(); - int index = strPath.indexOf("i18n/"); - - String str = strPath.substring(index); - bundlesUrls.add(str); - buffer.append(',').append(str); - if (verbose) { - getLog().info( - "loaded " + bundleEntry.getPath() + " in " + - PluginHelper.convertTime(t000, System.nanoTime())); - } - } - - if (!bundlesUrls.isEmpty()) { - bundleDico.put(locale, buffer.substring(1)); - if (!silent) { - if (getLog().isDebugEnabled()) { - getLog().debug(bundlesUrls.size() + - " i18n resource(s) detected"); - } - for (String u : bundlesUrls) { - getLog().info(u); - } - } - } - - // Apply conversion if necessary, depends on input bundleFormatConverter - if (converter != null) { - applyConversion(propertiesOut); - } - - 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, unsafeMapping); - } - } - - failsIfWarning(); - - if (generateDefaultLocale) { - generateDefaultBundle(); - } - - if (generateDefinitionFile) { - - generateDefinitionFile(version, bundleDico); - } - if (!silent && verbose) { - getLog().info("done in " + - PluginHelper.convertTime(t00, System.nanoTime())); - } - } - - @Override - protected File getBundleFile(File root, - String artifactId, - Locale locale, - boolean create) throws IOException { - return getI18nFile(root, artifactId, locale, create); - } - - protected void generateDefinitionFile(String version, - Map<Locale, String> bundleDico) throws IOException { - - // ecriture du ficher des definitions i18n (permet de faire une - // recherche exacte sur un fichier puis d'en deduire les bundles a - // charger - String f = String.format(DefaultI18nInitializer.UNIQUE_BUNDLE_DEF, - bundleOutputName); - File defOut = new File(outputFolder, f); - if (!silent) { - getLog().info("prepare i18n definition file in " + - defOut.getAbsolutePath()); - } - SortedProperties p = new SortedProperties(encoding, false); - p.setProperty(DefaultI18nInitializer.BUNDLE_DEF_LOCALES, bundles); - p.setProperty(DefaultI18nInitializer.BUNDLE_DEF_VERSION, version); - p.setProperty(DefaultI18nInitializer.BUNDLE_DEF_ENCODING, encoding); - for (Entry<Locale, String> e : bundleDico.entrySet()) { - p.setProperty(DefaultI18nInitializer.BUNDLES_FOR_LOCALE + - e.getKey().toString(), e.getValue()); - } - p.store(defOut); - } - - @Override - protected URL[] getCollectI18nResources(Locale locale) throws IOException { - File file = getCollectOutputFile(locale, false); - if (!file.exists()) { - return I18nBundleUtil.EMPTY_URL_ARRAY; - } - URL[] urls = PluginHelper.getLinesAsURL(file); - return urls; - } - - /** - * Apply conversion over {@code properties} with internal converter. - * - * @param properties Properties to walk through - * @since 2.4 - */ - protected void applyConversion(Properties properties) { - - for (Entry<Object, Object> entry : properties.entrySet()) { - String convertedValue = converter.convert((String) entry.getValue()); - properties.setProperty((String) entry.getKey(), convertedValue); - } - } - -} Copied: trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/BundleMojo.java (from rev 1958, trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/BundleMojo.java) =================================================================== --- trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/BundleMojo.java (rev 0) +++ trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/BundleMojo.java 2012-07-09 13:12:35 UTC (rev 1961) @@ -0,0 +1,307 @@ +/* + * #%L + * I18n :: Maven Plugin + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2007 - 2010 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>. + * #L% + */ + +package org.nuiton.i18n.plugin.bundle; + +import org.apache.commons.lang.StringUtils; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugins.annotations.Component; +import org.apache.maven.plugins.annotations.Execute; +import org.apache.maven.plugins.annotations.LifecyclePhase; +import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.plugins.annotations.Parameter; +import org.apache.maven.plugins.annotations.ResolutionScope; +import org.nuiton.i18n.bundle.I18nBundleEntry; +import org.nuiton.i18n.bundle.I18nBundleUtil; +import org.nuiton.i18n.init.DefaultI18nInitializer; +import org.nuiton.io.SortedProperties; +import org.nuiton.plugin.PluginHelper; + +import java.io.File; +import java.io.IOException; +import java.net.URL; +import java.nio.charset.Charset; +import java.util.ArrayList; +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 java.util.Properties; + +/** + * Generate an aggregate i18n bundle for all dependencies of the project. + * <p/> + * The main idea is to have a final unique i18n bundle for a application to + * launch, this really improve i18n loading time to have a unique named bundle, + * no need to seek in all dependencies... + * <p/> + * Moreover, this permits also to deal with order of i18n keys, more precisly, + * we want to use the higher level i18n key for an application. If the i18n + * key is present on a library, we want to be able to override it in + * application (or user wants it:)). + * <p/> + * This goal permits this using the dependencies graph order of artifacts. + * + * @author tchemit <chemit@codelutin.com> + * @since 0.12 + */ +@Mojo(name = "bundle", + defaultPhase = LifecyclePhase.GENERATE_RESOURCES, + requiresProject = true, + requiresDependencyResolution = ResolutionScope.RUNTIME) +@Execute(goal = "collect-i18n-artifacts") +public class BundleMojo extends AbstractMakeI18nBundleMojo { + + /** + * A flag to generate the i18n definition file. + * <p/> + * This file contains all generated bundles and the paths of all i18n + * artifacts used to make it. + * + * @since 2.0 + */ + @Parameter(property = "i18n.generateDefinitionFile", defaultValue = "true") + protected boolean generateDefinitionFile; + + /** + * Converter used to change format of bundles. + * + * @since 2.4 + */ + @Parameter(property = "i18n.bundleFormatConverter") + protected String bundleFormatConverter; + + /** + * Map of all availables {@link BundleFormatConverter}. + * + * @since 2.4 + */ + @Component(role = BundleFormatConverter.class) + protected Map<String, BundleFormatConverter> bundleFormatConverters; + + /** Format converter to apply if */ + protected BundleFormatConverter converter; + + @Override + public void init() throws Exception { + super.init(); + + // add root bundle directory as resources of the project + + addResourceDir(bundleOutputDir, "**/*.properties"); + + if (StringUtils.isNotEmpty(bundleFormatConverter)) { + + // get converter from universe + converter = bundleFormatConverters.get(bundleFormatConverter); + + if (converter == null) { + + // unknown converter + throw new MojoExecutionException( + "There is no bundleFormatConverter named \"" + + bundleFormatConverter + "\", known ones are " + + bundleFormatConverters.keySet()); + } + } + } + + @Override + protected void doAction() throws Exception { + long t00 = System.nanoTime(); + + String version = getProject().getVersion(); + version = PluginHelper.removeSnapshotSuffix(version); + + String inputEncoding = getBundleInputEncoding(); + String outputEncoding = getBundleOutputEncoding(); + + if (!silent) { + getLog().info("config - resources dir : " + bundleOutputDir); + getLog().info("config - package name : " + bundleOutputPackage); + getLog().info("config - bundle name : " + bundleOutputName); + getLog().info("config - input encoding : " + inputEncoding); + getLog().info("config - output encoding : " + outputEncoding); + if (bundleFormatConverter != null) { + getLog().info("config - format converter : " + bundleFormatConverter); + } + getLog().info("config - locales : " + Arrays.toString(locales)); + getLog().info("config - version : " + version); + } + + Map<Locale, String> bundleDico = + new LinkedHashMap<Locale, String>(locales.length); + + for (Locale locale : locales) { + + long t0 = System.nanoTime(); + + File bundleOut = getI18nFile(outputFolder, + bundleOutputName, + locale, + false + ); + + SortedProperties propertiesOut = + new SortedProperties(outputEncoding, false); + StringBuilder buffer = new StringBuilder(); + + URL[] urls = getCollectI18nResources(locale); + if (urls.length == 0) { + getLog().warn("no bundle for locale " + locale); + continue; + } + + if (!silent) { + getLog().info("generate bundle for locale " + locale + + " from " + urls.length + " i18n resource(s)"); + } + + List<String> bundlesUrls = new ArrayList<String>(); + + Charset loadEncoding = Charset.forName(inputEncoding); + for (URL url : urls) { + long t000 = System.nanoTime(); + I18nBundleEntry bundleEntry = + new I18nBundleEntry(url, locale, null); + bundleEntry.load(propertiesOut, loadEncoding); + String strPath = bundleEntry.getPath().toString(); + int index = strPath.indexOf("i18n/"); + + String str = strPath.substring(index); + bundlesUrls.add(str); + buffer.append(',').append(str); + if (verbose) { + getLog().info( + "loaded " + bundleEntry.getPath() + " in " + + PluginHelper.convertTime(t000, System.nanoTime())); + } + } + + if (!bundlesUrls.isEmpty()) { + bundleDico.put(locale, buffer.substring(1)); + if (!silent) { + if (getLog().isDebugEnabled()) { + getLog().debug(bundlesUrls.size() + + " i18n resource(s) detected"); + } + for (String u : bundlesUrls) { + getLog().info(u); + } + } + } + + // Apply conversion if necessary, depends on input bundleFormatConverter + if (converter != null) { + applyConversion(propertiesOut); + } + + 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, unsafeMapping); + } + } + + failsIfWarning(); + + if (generateDefaultLocale) { + generateDefaultBundle(); + } + + if (generateDefinitionFile) { + + generateDefinitionFile(version, bundleDico); + } + if (!silent && verbose) { + getLog().info("done in " + + PluginHelper.convertTime(t00, System.nanoTime())); + } + } + + @Override + protected File getBundleFile(File root, + String artifactId, + Locale locale, + boolean create) throws IOException { + return getI18nFile(root, artifactId, locale, create); + } + + protected void generateDefinitionFile(String version, + Map<Locale, String> bundleDico) throws IOException { + + // ecriture du ficher des definitions i18n (permet de faire une + // recherche exacte sur un fichier puis d'en deduire les bundles a + // charger + String f = String.format(DefaultI18nInitializer.UNIQUE_BUNDLE_DEF, + bundleOutputName); + File defOut = new File(outputFolder, f); + if (!silent) { + getLog().info("prepare i18n definition file in " + + defOut.getAbsolutePath()); + } + SortedProperties p = new SortedProperties(encoding, false); + p.setProperty(DefaultI18nInitializer.BUNDLE_DEF_LOCALES, bundles); + p.setProperty(DefaultI18nInitializer.BUNDLE_DEF_VERSION, version); + p.setProperty(DefaultI18nInitializer.BUNDLE_DEF_ENCODING, encoding); + for (Entry<Locale, String> e : bundleDico.entrySet()) { + p.setProperty(DefaultI18nInitializer.BUNDLES_FOR_LOCALE + + e.getKey().toString(), e.getValue()); + } + p.store(defOut); + } + + @Override + protected URL[] getCollectI18nResources(Locale locale) throws IOException { + File file = getCollectOutputFile(locale, false); + if (!file.exists()) { + return I18nBundleUtil.EMPTY_URL_ARRAY; + } + URL[] urls = PluginHelper.getLinesAsURL(file); + return urls; + } + + /** + * Apply conversion over {@code properties} with internal converter. + * + * @param properties Properties to walk through + * @since 2.4 + */ + protected void applyConversion(Properties properties) { + + for (Entry<Object, Object> entry : properties.entrySet()) { + String convertedValue = converter.convert((String) entry.getValue()); + properties.setProperty((String) entry.getKey(), convertedValue); + } + } + +} Deleted: trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/CollectI18nArtifactsMojo.java =================================================================== --- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/CollectI18nArtifactsMojo.java 2012-05-30 14:03:24 UTC (rev 1957) +++ trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/CollectI18nArtifactsMojo.java 2012-07-09 13:12:35 UTC (rev 1961) @@ -1,262 +0,0 @@ -/* - * #%L - * I18n :: Maven Plugin - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2007 - 2010 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>. - * #L% - */ - -package org.nuiton.i18n.plugin.bundle; - -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.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 java.io.File; -import java.io.IOException; -import java.net.URL; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Locale; -import java.util.Map; - -/** - * Detects any i18n artifacts in the dependencies of the project and store - * their references in a file. - * <p/> - * The generated file will be used by {@code bundle} mojo to generate the final - * aggregated bundle. - * - * @author tchemit <chemit@codelutin.com> - * @goal collect-i18n-artifacts - * @phase generate-resources - * @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(); - - createDirectoryIfNecessary(collectOutputDir); - } - - @Override - protected void doAction() throws Exception { - - // 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); - } - } - - @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); - } - } - writeFile(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 IOException while detecting bundles from - * artifacts - * @throws DependencyTreeBuilderException if any error while building the - * depencendy tree - */ - protected I18nArtifact[] detectI18nArtifacts() - throws IOException, DependencyTreeBuilderException { - - Map<Artifact, I18nArtifact> dico = - new HashMap<Artifact, I18nArtifact>(); - - I18nArtifact i18nArtifact; - for (Object o : project.getArtifacts()) { - i18nArtifact = new I18nArtifact((Artifact) o); - detectBundles(i18nArtifact, null, dico); - } - - ArtifactFilter artifactFilter - = new ScopeArtifactFilter(Artifact.SCOPE_RUNTIME); - - DependencyNode rootNode = dependencyTreeBuilder.buildDependencyTree( - project, localRepository, factory, - artifactMetadataSource, artifactFilter, collector); - - List<Artifact> artifacts = new ArrayList<Artifact>(dico.keySet()); - - // workaround before using maven-helper-plugin 1.3 see http://nuiton.org/issues/show/1082 - if (!artifacts.isEmpty()) { - 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()); - detectBundles(i18nArtifact, artifacts, dico); - - I18nArtifact[] result = new I18nArtifact[artifacts.size()]; - int i = 0; - for (Artifact artifact : artifacts) { - result[i++] = dico.get(artifact); - } - return result; - } - - protected void detectBundles(I18nArtifact i18nArtifact, - List<Artifact> artifacts, - Map<Artifact, I18nArtifact> dico) throws IOException { - if (i18nArtifact.detectBundles()) { - if (!silent) { - getLog().info("detected i18n artifact " + i18nArtifact); - } - if (artifacts != null) { - artifacts.add(i18nArtifact.getArtifact()); - } - dico.put(i18nArtifact.getArtifact(), i18nArtifact); - } else { - if (getLog().isDebugEnabled()) { - getLog().debug("reject artifact " + i18nArtifact); - } - } - } -} Copied: trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/CollectI18nArtifactsMojo.java (from rev 1958, trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/CollectI18nArtifactsMojo.java) =================================================================== --- trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/CollectI18nArtifactsMojo.java (rev 0) +++ trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/CollectI18nArtifactsMojo.java 2012-07-09 13:12:35 UTC (rev 1961) @@ -0,0 +1,265 @@ +/* + * #%L + * I18n :: Maven Plugin + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2007 - 2010 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>. + * #L% + */ + +package org.nuiton.i18n.plugin.bundle; + +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.plugins.annotations.Component; +import org.apache.maven.plugins.annotations.LifecyclePhase; +import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.plugins.annotations.Parameter; +import org.apache.maven.plugins.annotations.ResolutionScope; +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 java.io.File; +import java.io.IOException; +import java.net.URL; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; + +/** + * Detects any i18n artifacts in the dependencies of the project and store + * their references in a file. + * <p/> + * The generated file will be used by {@code bundle} mojo to generate the final + * aggregated bundle. + * + * @author tchemit <chemit@codelutin.com> + * @since 1.0.2 + */ +@Mojo(name = "collect-i18n-artifacts", + defaultPhase = LifecyclePhase.GENERATE_RESOURCES, + requiresProject = true, + requiresDependencyResolution = ResolutionScope.RUNTIME) +public class CollectI18nArtifactsMojo extends AbstractI18nBundleMojo { + + /** + * Local Repository. + * + * @since 1.0.2 + */ + @Parameter(property = "localRepository", required = true, readonly = true) + protected ArtifactRepository localRepository; + + /** + * Dependency tree builder component. + * + * @since 1.0.2 + */ + @Component + protected DependencyTreeBuilder dependencyTreeBuilder; + + /** + * Artifact Factory component. + * + * @since 1.0.2 + */ + @Component + protected ArtifactFactory factory; + + /** + * Artifact metadata source component. + * + * @since 1.0.2 + */ + @Component + protected ArtifactMetadataSource artifactMetadataSource; + + /** + * Artifact collector component. + * + * @since 1.0.2 + */ + @Component + protected ArtifactCollector collector; + + I18nArtifact[] i18nArtifacts; + + @Override + public void init() throws Exception { + super.init(); + + createDirectoryIfNecessary(collectOutputDir); + } + + @Override + protected void doAction() throws Exception { + + // 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); + } + } + + @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); + } + } + writeFile(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 IOException while detecting bundles from + * artifacts + * @throws DependencyTreeBuilderException if any error while building the + * depencendy tree + */ + protected I18nArtifact[] detectI18nArtifacts() + throws IOException, DependencyTreeBuilderException { + + Map<Artifact, I18nArtifact> dico = + new HashMap<Artifact, I18nArtifact>(); + + I18nArtifact i18nArtifact; + for (Object o : project.getArtifacts()) { + i18nArtifact = new I18nArtifact((Artifact) o); + detectBundles(i18nArtifact, null, dico); + } + + ArtifactFilter artifactFilter + = new ScopeArtifactFilter(Artifact.SCOPE_RUNTIME); + + DependencyNode rootNode = dependencyTreeBuilder.buildDependencyTree( + project, localRepository, factory, + artifactMetadataSource, artifactFilter, collector); + + List<Artifact> artifacts = new ArrayList<Artifact>(dico.keySet()); + + // workaround before using maven-helper-plugin 1.3 see http://nuiton.org/issues/show/1082 + if (!artifacts.isEmpty()) { + 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()); + detectBundles(i18nArtifact, artifacts, dico); + + I18nArtifact[] result = new I18nArtifact[artifacts.size()]; + int i = 0; + for (Artifact artifact : artifacts) { + result[i++] = dico.get(artifact); + } + return result; + } + + protected void detectBundles(I18nArtifact i18nArtifact, + List<Artifact> artifacts, + Map<Artifact, I18nArtifact> dico) throws IOException { + if (i18nArtifact.detectBundles()) { + if (!silent) { + getLog().info("detected i18n artifact " + i18nArtifact); + } + if (artifacts != null) { + artifacts.add(i18nArtifact.getArtifact()); + } + dico.put(i18nArtifact.getArtifact(), i18nArtifact); + } else { + if (getLog().isDebugEnabled()) { + getLog().debug("reject artifact " + i18nArtifact); + } + } + } +} Deleted: trunk/i18n-maven-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 2012-05-30 14:03:24 UTC (rev 1957) +++ trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/parser/AbstractI18nParserMojo.java 2012-07-09 13:12:35 UTC (rev 1961) @@ -1,350 +0,0 @@ -/* - * #%L - * I18n :: Maven Plugin - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2007 - 2010 CodeLutin, Tony Chemit - * %% - * 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>. - * #L% - */ - -package org.nuiton.i18n.plugin.parser; - -import org.nuiton.i18n.plugin.AbstractI18nMojo; -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.List; - -/** - * Abstract implementation for parsing goal. - * - * @author tchemit <chemit@codelutin.com> - */ -public abstract class AbstractI18nParserMojo extends AbstractI18nMojo implements I18nParserConfiguration { - - /** @return the outGetter to use for the instance (java.getter,...) */ - protected abstract String getOutGetter(); - - /** @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(); - - /** - * @return a new file parser to be used in the parser consumer parserExecutor - * @since 1.2 - */ - public abstract FileParser newFileParser(); - - /** - * @param entry the incoming source entry to attach to the file updater - * @return a new file updater to detects files to treate - */ - public abstract FileUpdater newFileUpdater(SourceEntry entry); - - /** - * Build directory (used to know if files in sources are up-to-date). - * - * @parameter expression="${i18n.cp}" default-value="${basedir}/target/classes" - */ - protected File cp; - - /** - * To treate default entry offered by the mojo. - * - * @parameter expression="${i18n.treateDefaultEntry}" default-value="true" - */ - protected boolean treateDefaultEntry; - - /** - * Source entries (src+includes+excludes) to process. - * - * @parameter expression="${i18n.entries}" - */ - protected I18nSourceEntry[] entries; - - /** - * Flag to display touched files while parsing. - * <p/> - * Note: the value will be always {@code true} if {@link #verbose} is - * set at {@code true}. - * - * @parameter expression="${i18n.showTouchedFiles}" default-value="${maven.verbose}" - * @since 0.9 - */ - protected boolean showTouchedFiles; - - /** - * 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; - - /** - * To force reparse of all sources. - * - * @parameter expression="${i18n.force}" default-value="false" - * @since 1.2 - */ - protected boolean force; - - private SortedProperties result; - - protected SortedProperties oldParser; - - protected SortedProperties oldLanguage; - - protected long t0; - - ParserExecutor parserExecutor; - - @Override - public boolean isStrictMode() { - return strictMode; - } - - public boolean isForce() { - return force; - } - - @Override - public void init() throws Exception { - super.init(); - t0 = System.nanoTime(); - result = new SortedProperties(encoding); - oldParser = new SortedProperties(encoding); - oldLanguage = new SortedProperties(encoding); - createDirectoryIfNecessary(out); -// // 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."); - } - - if (verbose && entries != null && entries.length > 0) { - if (getLog().isInfoEnabled()) { - - getLog().info("detected entries : " + entries.length); - for (SourceEntry e : entries) { - getLog().info(e.toString() + ", specific goal ? " + - e.getSpecificGoal()); - } - } - } - - parserExecutor = new ParserExecutor(this); - } - - protected boolean onEnterEntry(I18nSourceEntry entry) { - boolean skip = entry.init(this); - return skip; - } - - @Override - protected void doAction() throws Exception { - - if (!silent && strictMode) { - getLog().info("config - strictMode is on (all files will be" + - " parsed)."); - } - if (!silent && force) { - getLog().info("config - force is on (all files will be" + - " parsed)."); - } - - // Reprise sur un ancien parsing - File oldParserFile = getGetterFile(out, getOutGetter(), true); - File saveFile = getBackupFile(oldParserFile); - - oldParser.load(oldParserFile); - if (backupGetter) { - backupFile(oldParserFile); - } - - // 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 - if (treateDefaultEntry) { - addDefaultEntry(); - } - - for (I18nSourceEntry entry : entries) { - - boolean skip = onEnterEntry(entry); - - if (skip) { - if (!silent && verbose) { - getLog().info("skip - " + entry.getSkipMessage()); - } - continue; - } - - // launch parser for found files - String[] files = entry.getFiles(); - - if (!silent) { - getLog().info("start entry " + entry.toString()); - getLog().info(files.length + " file(s) to process (among " + - entry.getFoudFiles() + " files)"); - } - - for (int i = 0, max = files.length; i < max; i++) { - String file1 = files[i]; - String fileName = entry.getBasedir().getAbsolutePath() + - File.separator + file1; - File file = new File(fileName); - parserExecutor.addFile(newFileParser(), file); - } - } - - if (getLog().isDebugEnabled()) { - getLog().debug("ask to terminate " + parserExecutor); - } - - // all files are send to parserExecutor, we ask termination of parserExecutor. - // this termination treat all sending file before really stop - parserExecutor.terminatesAndWaits(); - - List<File> treadedFiles = parserExecutor.getTreatedFiles(); - List<File> touchedFiles = parserExecutor.getTouchedFiles(); - - // Suppression du fichier sauvegarder - if (!backupGetter) { - deleteFile(saveFile); - } - - if (treadedFiles.isEmpty()) { - if (!silent) { - getLog().info("Nothing was parsed - all files are up to date."); - } - } else { - if (showTouchedFiles) { - for (File f : touchedFiles) { - getLog().info("touch " + f); - } - } - if (!silent) { - int i = touchedFiles.size(); - int max = treadedFiles.size(); - getLog().info(getLogEntry( - "Parsing is done. [treated file(s) : " + i + '/' + - max + "]", max, 0, t0)); - } - // save getter - saveGetterFile(); - // add getter - addGetter(); - } - - parserExecutor.clear(); - } - - @Override - public boolean isShowTouchedFiles() { - return showTouchedFiles; - } - - @Override - public SortedProperties getResult() { - return result; - } - - /** - * 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() { - 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; - } - - /** - * 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); - } - - /** - * Construit une chaine de log formatée. - * - * @param msg le prefix du message - * @param nbFiles le nombre de fichiers actuellement traités - * @param time le time de traitement de ce fichier - * @param all le temps de traitement de tous les fichiers - * @return la chaine de log formatée - */ - public static String getLogEntry(String msg, - int nbFiles, - long time, - long all) { - long now = System.nanoTime(); - long delta = now - time; - String s = msg; - if (time > 0 && all == 0) { - s += " (" + PluginHelper.convertTime(delta) + ")"; - } - if (all > 0) { - s += "(total time:" + PluginHelper.convertTime(now - all) + ")"; - } - if (nbFiles > 0) { - s += " ( ~ " + - PluginHelper.convertTime((now - all) / nbFiles) + " / file)"; - } - return s; - } -} Copied: trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/parser/AbstractI18nParserMojo.java (from rev 1960, trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/AbstractI18nParserMojo.java) =================================================================== --- trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/parser/AbstractI18nParserMojo.java (rev 0) +++ trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/parser/AbstractI18nParserMojo.java 2012-07-09 13:12:35 UTC (rev 1961) @@ -0,0 +1,341 @@ +/* + * #%L + * I18n :: Maven Plugin + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2007 - 2010 CodeLutin, Tony Chemit + * %% + * 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>. + * #L% + */ + +package org.nuiton.i18n.plugin.parser; + +import org.apache.maven.plugins.annotations.Parameter; +import org.nuiton.i18n.plugin.AbstractI18nMojo; +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.List; + +/** + * Abstract implementation for parsing goal. + * + * @author tchemit <chemit@codelutin.com> + */ +public abstract class AbstractI18nParserMojo extends AbstractI18nMojo implements I18nParserConfiguration { + + /** @return the outGetter to use for the instance (java.getter,...) */ + protected abstract String getOutGetter(); + + /** @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(); + + /** + * @return a new file parser to be used in the parser consumer parserExecutor + * @since 1.2 + */ + public abstract FileParser newFileParser(); + + /** + * @param entry the incoming source entry to attach to the file updater + * @return a new file updater to detects files to treate + */ + public abstract FileUpdater newFileUpdater(SourceEntry entry); + + /** Build directory (used to know if files in sources are up-to-date). */ + @Parameter(property = "i18n.cp", defaultValue = "${basedir}/target/classes") + protected File cp; + + /** To treat default entry offered by the mojo. */ + @Parameter(property = "i18n.treateDefaultEntry", defaultValue = "true") + protected boolean treateDefaultEntry; + + /** Source entries (src+includes+excludes) to process. */ + @Parameter(property = "i18n.entries") + protected I18nSourceEntry[] entries; + + /** + * Flag to display touched files while parsing. + * <p/> + * Note: the value will be always {@code true} if {@link #verbose} is + * set at {@code true}. + * + * @since 0.9 + */ + @Parameter(property = "i18n.showTouchedFiles", defaultValue = "${maven.verbose}") + protected boolean showTouchedFiles; + + /** + * 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...) + * + * @since 1.0.2 + */ + @Parameter(property = "i18n.backupGetter", defaultValue = "false") + protected boolean backupGetter; + + /** + * To force reparse of all sources. + * + * @since 1.2 + */ + @Parameter(property = "i18n.force", defaultValue = "false") + protected boolean force; + + private SortedProperties result; + + protected SortedProperties oldParser; + + protected SortedProperties oldLanguage; + + protected long t0; + + ParserExecutor parserExecutor; + + @Override + public boolean isStrictMode() { + return strictMode; + } + + public boolean isForce() { + return force; + } + + @Override + public void init() throws Exception { + super.init(); + t0 = System.nanoTime(); + result = new SortedProperties(encoding); + oldParser = new SortedProperties(encoding); + oldLanguage = new SortedProperties(encoding); + createDirectoryIfNecessary(out); +// // 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."); + } + + if (verbose && entries != null && entries.length > 0) { + if (getLog().isInfoEnabled()) { + + getLog().info("detected entries : " + entries.length); + for (SourceEntry e : entries) { + getLog().info(e.toString() + ", specific goal ? " + + e.getSpecificGoal()); + } + } + } + + parserExecutor = new ParserExecutor(this); + } + + protected boolean onEnterEntry(I18nSourceEntry entry) { + boolean skip = entry.init(this); + return skip; + } + + @Override + protected void doAction() throws Exception { + + if (!silent && strictMode) { + getLog().info("config - strictMode is on (all files will be" + + " parsed)."); + } + if (!silent && force) { + getLog().info("config - force is on (all files will be" + + " parsed)."); + } + + // Reprise sur un ancien parsing + File oldParserFile = getGetterFile(out, getOutGetter(), true); + File saveFile = getBackupFile(oldParserFile); + + oldParser.load(oldParserFile); + if (backupGetter) { + backupFile(oldParserFile); + } + + // 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 + if (treateDefaultEntry) { + addDefaultEntry(); + } + + for (I18nSourceEntry entry : entries) { + + boolean skip = onEnterEntry(entry); + + if (skip) { + if (!silent && verbose) { + getLog().info("skip [" + entry + "] - " + entry.getSkipMessage()); + } + continue; + } + + // launch parser for found files + String[] files = entry.getFiles(); + + if (!silent) { + getLog().info("start entry " + entry.toString()); + getLog().info(files.length + " file(s) to process (among " + + entry.getFoudFiles() + " files)"); + } + + for (String file1 : files) { + String fileName = entry.getBasedir().getAbsolutePath() + + File.separator + file1; + File file = new File(fileName); + parserExecutor.addFile(newFileParser(), file); + } + } + + if (getLog().isDebugEnabled()) { + getLog().debug("ask to terminate " + parserExecutor); + } + + // all files are send to parserExecutor, we ask termination of parserExecutor. + // this termination treat all sending file before really stop + parserExecutor.terminatesAndWaits(); + + List<File> treadedFiles = parserExecutor.getTreatedFiles(); + List<File> touchedFiles = parserExecutor.getTouchedFiles(); + + // Suppression du fichier sauvegarder + if (!backupGetter) { + deleteFile(saveFile); + } + + if (treadedFiles.isEmpty()) { + if (!silent) { + getLog().info("Nothing was parsed - all files are up to date."); + } + } else { + if (showTouchedFiles) { + for (File f : touchedFiles) { + getLog().info("touch " + f); + } + } + if (!silent) { + int i = touchedFiles.size(); + int max = treadedFiles.size(); + getLog().info(getLogEntry( + "Parsing is done. [treated file(s) : " + i + '/' + + max + "]", max, 0, t0)); + } + // save getter + saveGetterFile(); + // add getter + addGetter(); + } + + parserExecutor.clear(); + } + + @Override + public boolean isShowTouchedFiles() { + return showTouchedFiles; + } + + @Override + public SortedProperties getResult() { + return result; + } + + /** + * 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() { + 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; + } + + /** + * 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); + } + + /** + * Construit une chaine de log formatée. + * + * @param msg le prefix du message + * @param nbFiles le nombre de fichiers actuellement traités + * @param time le time de traitement de ce fichier + * @param all le temps de traitement de tous les fichiers + * @return la chaine de log formatée + */ + public static String getLogEntry(String msg, + int nbFiles, + long time, + long all) { + long now = System.nanoTime(); + long delta = now - time; + String s = msg; + if (time > 0 && all == 0) { + s += " (" + PluginHelper.convertTime(delta) + ")"; + } + if (all > 0) { + s += "(total time:" + PluginHelper.convertTime(now - all) + ")"; + } + if (nbFiles > 0) { + s += " ( ~ " + + PluginHelper.convertTime((now - all) / nbFiles) + " / file)"; + } + return s; + } +} Deleted: trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/AbstractParserXmlMojo.java =================================================================== --- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/AbstractParserXmlMojo.java 2012-05-30 14:03:24 UTC (rev 1957) +++ trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/AbstractParserXmlMojo.java 2012-07-09 13:12:35 UTC (rev 1961) @@ -1,414 +0,0 @@ -/* - * #%L - * I18n :: Maven Plugin - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2007 - 2010 CodeLutin, Tony Chemit - * %% - * 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>. - * #L% - */ - -package org.nuiton.i18n.plugin.parser.impl; - -import org.apache.commons.lang.StringUtils; -import org.apache.maven.plugin.MojoFailureException; -import org.apache.maven.plugin.logging.Log; -import org.nuiton.i18n.plugin.parser.AbstractFileParser; -import org.nuiton.i18n.plugin.parser.AbstractI18nParserMojo; -import org.nuiton.i18n.plugin.parser.FileParser; -import org.nuiton.i18n.plugin.parser.ParserException; -import org.nuiton.io.SortedProperties; -import org.w3c.dom.Document; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - -import javax.xml.namespace.NamespaceContext; -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.BufferedInputStream; -import java.io.BufferedReader; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.TreeMap; - -/** - * Abstract xml parser mojo. - * - * @author tchemit <chemit@codelutin.com> - * @author jruchaud <ruchaud@codelutin.com> - * @since 2.0 - */ -public abstract class AbstractParserXmlMojo extends AbstractI18nParserMojo { - - /** Taille du buffer pour les lectures/écritures */ - protected static final int BUFFER_SIZE = 8 * 1024; - - /** available rules to detect i18n keys in xml files. */ - protected String rules; - - /** XPath factory used to detect i18n keys in xml files. */ - protected XPathFactory factory; - - /** Document builder factory to load xml files. */ - protected DocumentBuilderFactory documentBuilderFactory; - - /** - * Extra rules files to use for detecting i18n keys in xml validation files. - * <p/> - * <b>Note : </b> If the {@code coreRulesFile} is not defined, then you must - * fill this parameter. - * - * @parameter - * @since 2.0 - */ - protected String[] userRulesFiles; - - /** - * Defines namespaces mapping if needed. - * <p/> - * Example : - * <pre> - * <namespaces> - * <s>http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd</s> - * </namespaces> - * </pre> - * - * @parameter - * @since 2.0 - */ - protected Map<String, String> namespaces; - - protected abstract String getCoreRuleFile(); - - protected abstract XmlFileParser newXmlFileParser(XPath xpath, - DocumentBuilder builder); - - /** - * Obtain the list of files which define rules to apply. - * - * @return the list of path to rule files to used. - */ - protected List<String> getRulefiles() { - List<String> result = new ArrayList<String>(); - - // load optional core rule file - String s = getCoreRuleFile(); - if (!StringUtils.isEmpty(s)) { - result.add(s); - } - - // load user rile files - String[] userFiles = getUserRuleFiles(); - if (userFiles != null) { - for (String f : userFiles) { - if (!StringUtils.isEmpty(f)) { - result.add(f); - } - } - } - return result; - } - - @Override - public void init() throws Exception { - super.init(); - factory = XPathFactory.newInstance(); - - List<String> files = getRulefiles(); - - if (files.isEmpty()) { - - // no rules file defined - throw new MojoFailureException("No rules files defined, fill the coreRulesFile or userRulesFiles parameters"); - } - - rules = loadRules(files); - - documentBuilderFactory = DocumentBuilderFactory.newInstance(); - documentBuilderFactory.setNamespaceAware(true); - documentBuilderFactory.setValidating(false); - documentBuilderFactory.setCoalescing(false); - documentBuilderFactory.setIgnoringComments(true); - } - - public final String[] getUserRuleFiles() { - return userRulesFiles; - } - - @Override - public final FileParser newFileParser() { - - DocumentBuilder builder; - try { - // never forget this! - builder = documentBuilderFactory.newDocumentBuilder(); - - } catch (ParserConfigurationException ex) { - throw new IllegalStateException( - "could not load DocumentBuilder for reason " + - ex.getMessage(), ex); - } - XPath xpath = factory.newXPath(); - - return newXmlFileParser(xpath, builder); - } - - protected String loadRules(List<String> files) { - - List<String> rules = new ArrayList<String>(); - - boolean verbose = !isSilent() && isVerbose(); - - for (String file : files) { - - getLog().info("Load rules file " + file); - - try { - String fileRules = loadRulesFile(file); - rules.add(fileRules); - - if (verbose) { - getLog().info("Rules for file [" + file + "] : " + fileRules); - } - - } catch (IOException e) { - throw new ParserException(e); - } - } - - String result = StringUtils.join(rules, " | "); - if (verbose) { - getLog().info("Loaded rules : " + result); - } - return result; - } - - protected 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(); - BufferedReader reader = new BufferedReader( - new InputStreamReader(in, encoding)); - - try { - String line; - while ((line = reader.readLine()) != null) { - line = line.trim(); - if (line.startsWith("#")) { - - // comment line - continue; - } - sb.append(" ").append(line); - } - } finally { - reader.close(); - } - // Suppression des espaces au début et à la fin - String txt = sb.toString().trim(); - - // contruction du xpath avec des ou - txt = txt.replaceAll("\\s+", " | "); - - // suppression des ou de début et de fin - txt = txt.replaceAll("(^ \\| )|( \\| $)", ""); - return txt; - } - - public static abstract class XmlFileParser extends AbstractFileParser { - - private final XPath xpath; - - private final String rules; - - private final DocumentBuilder builder; - - private final Map<String, String> namespaces; - - private final Map<String, String> namespaces2; - - private final boolean verbose; - - /** - * Fonction d'extraction de la chaine - * - * @param i18nString le clef i18n - * @return la chaine - */ - public abstract String extract(String i18nString); - - public XmlFileParser(Log log, - String encoding, - SortedProperties oldParser, - boolean showTouchedFiles, - String rules, - XPath xpath, - DocumentBuilder builder, - Map<String, String> namespaces, - boolean verbose) { - super(log, encoding, oldParser, showTouchedFiles); - this.xpath = xpath; - this.rules = rules; - this.builder = builder; - this.verbose = verbose; - - if (namespaces != null && !namespaces.isEmpty()) { - this.namespaces = namespaces; - namespaces2 = new TreeMap<String, String>(); - for (Map.Entry<String, String> e : namespaces.entrySet()) { - namespaces2.put(e.getValue(), e.getKey()); - } - NamespaceContext ctx = new NamespaceContext() { - public String getNamespaceURI(String prefix) { - return XmlFileParser.this.namespaces.get(prefix); - } - - @Override - public String getPrefix(String namespaceURI) { - return namespaces2.get(namespaceURI); - } - - @Override - public Iterator<?> getPrefixes(String namespaceURI) { - return null; - } - }; - xpath.setNamespaceContext(ctx); - } else { - namespaces2 = null; - this.namespaces = null; - } - } - - /** - * To prepare the file (if any thing to be done before scanning it). - * - * @param file the incoming file - * @return the real file to process - * @throws IOException if any IO problem while preparing file - * @since 2.0 - */ - @Override - public File prepareFile(File file) throws IOException { - - // by default, do nothing - return file; - } - - @Override - public void parseFile(File file) throws IOException { - - File fileToProcess = prepareFile(file); - if (fileToProcess == null) { - - // this case means not to treate the file - if (verbose) { - getLog().info("Skip file " + file); - } - return; - } - - try { - - // Recherche des clés à partir d'un xpath - if (verbose) { - getLog().info("Start parsing file " + fileToProcess); - } - Document doc = builder.parse(fileToProcess.getAbsolutePath()); - XPathExpression expression = xpath.compile(rules); - NodeList list = (NodeList) - expression.evaluate(doc, XPathConstants.NODESET); - if (verbose) { - getLog().info("Detected nodes [" + file + "] : " + list.getLength()); - } - for (int index = 0; index < list.getLength(); index++) { - Node node = list.item(index); - - parseLine(fileToProcess, node.getTextContent()); - } - } catch (Exception e) { - throw new ParserException(e); - } - } - - @Override - public void parseLine(File file, String key) throws IOException { - - key = extract(key); - if (key != null) { - setTouched(true); - registerKey(key); - } - } - } -} Copied: trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/AbstractParserXmlMojo.java (from rev 1958, trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/AbstractParserXmlMojo.java) =================================================================== --- trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/AbstractParserXmlMojo.java (rev 0) +++ trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/AbstractParserXmlMojo.java 2012-07-09 13:12:35 UTC (rev 1961) @@ -0,0 +1,415 @@ +/* + * #%L + * I18n :: Maven Plugin + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2007 - 2010 CodeLutin, Tony Chemit + * %% + * 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>. + * #L% + */ + +package org.nuiton.i18n.plugin.parser.impl; + +import org.apache.commons.lang.StringUtils; +import org.apache.maven.plugin.MojoFailureException; +import org.apache.maven.plugin.logging.Log; +import org.apache.maven.plugins.annotations.Parameter; +import org.nuiton.i18n.plugin.parser.AbstractFileParser; +import org.nuiton.i18n.plugin.parser.AbstractI18nParserMojo; +import org.nuiton.i18n.plugin.parser.FileParser; +import org.nuiton.i18n.plugin.parser.ParserException; +import org.nuiton.io.SortedProperties; +import org.w3c.dom.Document; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + +import javax.xml.namespace.NamespaceContext; +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.BufferedInputStream; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.TreeMap; + +/** + * Abstract xml parser mojo. + * + * @author tchemit <chemit@codelutin.com> + * @author jruchaud <ruchaud@codelutin.com> + * @since 2.0 + */ +public abstract class AbstractParserXmlMojo extends AbstractI18nParserMojo { + + /** Taille du buffer pour les lectures/écritures */ + protected static final int BUFFER_SIZE = 8 * 1024; + + /** available rules to detect i18n keys in xml files. */ + protected String rules; + + /** XPath factory used to detect i18n keys in xml files. */ + protected XPathFactory factory; + + /** Document builder factory to load xml files. */ + protected DocumentBuilderFactory documentBuilderFactory; + + /** + * Extra rules files to use for detecting i18n keys in xml validation files. + * <p/> + * <b>Note : </b> If the {@code coreRulesFile} is not defined, then you must + * fill this parameter. + * + * @since 2.0 + */ + @Parameter + protected String[] userRulesFiles; + + /** + * Defines namespaces mapping if needed. + * <p/> + * Example : + * <pre> + * <namespaces> + * <s>http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd</s> + * </namespaces> + * </pre> + * + * @since 2.0 + */ + @Parameter + protected Map<String, String> namespaces; + + protected abstract String getCoreRuleFile(); + + protected abstract XmlFileParser newXmlFileParser(XPath xpath, + DocumentBuilder builder); + + /** + * Obtain the list of files which define rules to apply. + * + * @return the list of path to rule files to used. + */ + protected List<String> getRulefiles() { + List<String> result = new ArrayList<String>(); + + // load optional core rule file + String s = getCoreRuleFile(); + if (!StringUtils.isEmpty(s)) { + result.add(s); + } + + // load user rile files + String[] userFiles = getUserRuleFiles(); + if (userFiles != null) { + for (String f : userFiles) { + if (!StringUtils.isEmpty(f)) { + result.add(f); + } + } + } + return result; + } + + @Override + public void init() throws Exception { + super.init(); + factory = XPathFactory.newInstance(); + + List<String> files = getRulefiles(); + + if (files.isEmpty()) { + + // no rules file defined + throw new MojoFailureException("No rules files defined, fill the coreRulesFile or userRulesFiles parameters"); + } + + rules = loadRules(files); + + documentBuilderFactory = DocumentBuilderFactory.newInstance(); + documentBuilderFactory.setNamespaceAware(true); + documentBuilderFactory.setValidating(false); + documentBuilderFactory.setCoalescing(false); + documentBuilderFactory.setIgnoringComments(true); + } + + public final String[] getUserRuleFiles() { + return userRulesFiles; + } + + @Override + public final FileParser newFileParser() { + + DocumentBuilder builder; + try { + // never forget this! + builder = documentBuilderFactory.newDocumentBuilder(); + + } catch (ParserConfigurationException ex) { + throw new IllegalStateException( + "could not load DocumentBuilder for reason " + + ex.getMessage(), ex); + } + XPath xpath = factory.newXPath(); + + return newXmlFileParser(xpath, builder); + } + + protected String loadRules(List<String> files) { + + List<String> rules = new ArrayList<String>(); + + boolean verbose = !isSilent() && isVerbose(); + + for (String file : files) { + + getLog().info("Load rules file " + file); + + try { + String fileRules = loadRulesFile(file); + rules.add(fileRules); + + if (verbose) { + getLog().info("Rules for file [" + file + "] : " + fileRules); + } + + } catch (IOException e) { + throw new ParserException(e); + } + } + + String result = StringUtils.join(rules, " | "); + if (verbose) { + getLog().info("Loaded rules : " + result); + } + return result; + } + + protected 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(); + BufferedReader reader = new BufferedReader( + new InputStreamReader(in, encoding)); + + try { + String line; + while ((line = reader.readLine()) != null) { + line = line.trim(); + if (line.startsWith("#")) { + + // comment line + continue; + } + sb.append(" ").append(line); + } + } finally { + reader.close(); + } + // Suppression des espaces au début et à la fin + String txt = sb.toString().trim(); + + // contruction du xpath avec des ou + txt = txt.replaceAll("\\s+", " | "); + + // suppression des ou de début et de fin + txt = txt.replaceAll("(^ \\| )|( \\| $)", ""); + return txt; + } + + public static abstract class XmlFileParser extends AbstractFileParser { + + private final XPath xpath; + + private final String rules; + + private final DocumentBuilder builder; + + private final Map<String, String> namespaces; + + private final Map<String, String> namespaces2; + + private final boolean verbose; + + /** + * Fonction d'extraction de la chaine + * + * @param i18nString le clef i18n + * @return la chaine + */ + public abstract String extract(String i18nString); + + public XmlFileParser(Log log, + String encoding, + SortedProperties oldParser, + boolean showTouchedFiles, + String rules, + XPath xpath, + DocumentBuilder builder, + Map<String, String> namespaces, + boolean verbose) { + super(log, encoding, oldParser, showTouchedFiles); + this.xpath = xpath; + this.rules = rules; + this.builder = builder; + this.verbose = verbose; + + if (namespaces != null && !namespaces.isEmpty()) { + this.namespaces = namespaces; + namespaces2 = new TreeMap<String, String>(); + for (Map.Entry<String, String> e : namespaces.entrySet()) { + namespaces2.put(e.getValue(), e.getKey()); + } + NamespaceContext ctx = new NamespaceContext() { + public String getNamespaceURI(String prefix) { + return XmlFileParser.this.namespaces.get(prefix); + } + + @Override + public String getPrefix(String namespaceURI) { + return namespaces2.get(namespaceURI); + } + + @Override + public Iterator<?> getPrefixes(String namespaceURI) { + return null; + } + }; + xpath.setNamespaceContext(ctx); + } else { + namespaces2 = null; + this.namespaces = null; + } + } + + /** + * To prepare the file (if any thing to be done before scanning it). + * + * @param file the incoming file + * @return the real file to process + * @throws IOException if any IO problem while preparing file + * @since 2.0 + */ + @Override + public File prepareFile(File file) throws IOException { + + // by default, do nothing + return file; + } + + @Override + public void parseFile(File file) throws IOException { + + File fileToProcess = prepareFile(file); + if (fileToProcess == null) { + + // this case means not to treate the file + if (verbose) { + getLog().info("Skip file " + file); + } + return; + } + + try { + + // Recherche des clés à partir d'un xpath + if (verbose) { + getLog().info("Start parsing file " + fileToProcess); + } + Document doc = builder.parse(fileToProcess.getAbsolutePath()); + XPathExpression expression = xpath.compile(rules); + NodeList list = (NodeList) + expression.evaluate(doc, XPathConstants.NODESET); + if (verbose) { + getLog().info("Detected nodes [" + file + "] : " + list.getLength()); + } + for (int index = 0; index < list.getLength(); index++) { + Node node = list.item(index); + + parseLine(fileToProcess, node.getTextContent()); + } + } catch (Exception e) { + throw new ParserException(e); + } + } + + @Override + public void parseLine(File file, String key) throws IOException { + + key = extract(key); + if (key != null) { + setTouched(true); + registerKey(key); + } + } + } +} Deleted: trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserGWTJavaMojo.java =================================================================== --- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserGWTJavaMojo.java 2012-05-30 14:03:24 UTC (rev 1957) +++ trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserGWTJavaMojo.java 2012-07-09 13:12:35 UTC (rev 1961) @@ -1,276 +0,0 @@ -/* - * #%L - * I18n :: Maven Plugin - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2011 CodeLutin, Tony Chemit - * %% - * 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>. - * #L% - */ -package org.nuiton.i18n.plugin.parser.impl; - -import org.apache.maven.plugin.logging.Log; -import org.nuiton.i18n.plugin.parser.AbstractFileParser; -import org.nuiton.i18n.plugin.parser.AbstractI18nParserMojo; -import org.nuiton.i18n.plugin.parser.FileParser; -import org.nuiton.i18n.plugin.parser.I18nSourceEntry; -import org.nuiton.i18n.plugin.parser.ParserException; -import org.nuiton.i18n.plugin.parser.SourceEntry; -import org.nuiton.io.FileUpdater; -import org.nuiton.io.MirroredFileUpdater; -import org.nuiton.io.SortedProperties; -import org.nuiton.processor.ProcessorUtil; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.LineNumberReader; -import java.util.HashSet; -import java.util.Set; - -/** - * To detect from GWT java files new I18n keys, says content of patterns : - * <ul> - * <li>{@code @Key("XXX")}</li> - * <li>{@code @LocalizableResource.Key("XXX")}</li> - * <li>{@code @com.google.gwt.i18n.client.LocalizableResource.Key("XXX")}</li> - * </ul> - * <b>Note: </b> this goal must always be invoked before the {@code process-resources} - * phase, otherwise all files will be considered as uptodate. - * - * @author tchemit <chemit@codelutin.com> - * @goal parserGWTJava - * @phase generate-resources - * @since 2.1 - */ -public class ParserGWTJavaMojo extends AbstractI18nParserMojo { - - /** - * Root directory of the default entry. - * - * @parameter expression="${i18n.defaultBasedir}" default-value="${basedir}/src/main/java" - */ - protected File defaultBasedir; - - /** - * Default included files to process (ant-like expression). - * - * @parameter expression="${i18n.defaultIncludes}" default-value="**\/*.java" - */ - protected String defaultIncludes; - - /** - * Defines the file name of the getter where to put detected i18n keys - * while getter phase. - * - * @parameter expression="${i18n.outputGetter}" default-value="gwt-java.getter" - * @since 2.0 - */ - protected String outputGetter; - - /** - * Where to generated temporary processed files. - * - * @parameter expression="${i18n.workdir}" default-value="${basedir}/target/i18n-workdir" - * @since 2.0 - */ - protected File workdir; - - protected MirroredFileUpdater entryUpdater; - - @Override - public String[] getDefaultIncludes() { - return new String[]{defaultIncludes}; - } - - @Override - public String[] getDefaultExcludes() { - return I18nSourceEntry.EMPTY_STRING_ARRAY; - } - - @Override - public File getDefaultBasedir() { - return defaultBasedir; - } - - @Override - protected boolean onEnterEntry(I18nSourceEntry entry) { - boolean b = super.onEnterEntry(entry); - if (!b) { - - // no skipped entry - // keep the file updater - entryUpdater = (MirroredFileUpdater) entry.getUpdater(); - } - return b; - } - - @Override - public FileUpdater newFileUpdater(SourceEntry entry) { - return new MirroredFileUpdater("", "", entry.getBasedir(), workdir) { - - @Override - public File getMirrorFile(File f) { - String file = - f.getAbsolutePath().substring(prefixSourceDirecotory); - return new File(destinationDirectory + File.separator + file); - } - }; - } - - @Override - protected String getOutGetter() { - return outputGetter; - } - - @Override - public FileParser newFileParser() { - - return new GWTJavaFileParser(getLog(), - encoding, - oldParser, - isShowTouchedFiles() - ); - } - - protected class GWTJavaFileParser extends AbstractFileParser { - - - public GWTJavaFileParser(Log log, - String encoding, - SortedProperties oldParser, - boolean showTouchedFiles) { - super(log, encoding, oldParser, showTouchedFiles); - } - - - protected File prepareFile(File file) throws IOException { - - // clean the jsp to make it xml - - File result = entryUpdater.getMirrorFile(file); - if (isVerbose()) { - getLog().info("Will process [" + file + "] to " + result); - } - try { - createDirectoryIfNecessary(result.getParentFile()); - } catch (IOException e) { - // don't care about it... - } - GWTJavaProcessor processor = new GWTJavaProcessor(); - processor.setVerbose(isVerbose()); - processor.process(file, result, getEncoding()); - return result; - } - - @Override - public void parseFile(File file) throws IOException { - - // clean the jsp to make it xml - - File processedFile = prepareFile(file); - - // process file to obtain - String line = null; - LineNumberReader lnr = new LineNumberReader(new InputStreamReader( - new FileInputStream(processedFile), getEncoding())); - try { - while ((line = lnr.readLine()) != null) { - parseLine(processedFile, line); - } - } catch (Exception e) { - if (line != null) { - getLog().error( - "could not parse line (" + lnr.getLineNumber() + ") '" - + line + "' of file " + file); - } - throw new ParserException(e); - } finally { - lnr.close(); - } - } - - @Override - public void parseLine(File file, String line) throws IOException { - - String key = line.trim(); - - if (key.isEmpty()) { - // no key detected on this line - return; - } - - // one key found in file, so file is marked as touched - setTouched(true); - // Found a i18n key, register it. - if (getLog().isDebugEnabled()) { - getLog().debug(file.getName() + " detected key = " + key); - } - registerKey(key); - } - } - - /** - * To Extract i18n keys from GWT java files. - * <p/> - * Says keep content only of those patterns : - * <ul> - * <li>{@code @Key("XXX")}</li> - * <li>{@code @LocalizableResource.Key("XXX")}</li> - * <li>{@code @com.google.gwt.i18n.client.LocalizableResource.Key("XXX")}</li> - * </ul> - * - * @author tchemit <chemit@codelutin.com> - * @since 2.1 - */ - public static class GWTJavaProcessor extends ProcessorHelper.AbstractParserProcessor { - - protected ProcessorUtil.FragmentExtractor filter1 = - new ProcessorUtil.FragmentExtractor( - "@Key(\"", - "\")" - ); - - protected ProcessorUtil.FragmentExtractor filter2 = - new ProcessorUtil.FragmentExtractor( - "@LocalizableResource.Key(\"", - "\")" - ); - - protected ProcessorUtil.FragmentExtractor filter3 = - new ProcessorUtil.FragmentExtractor( - "@com.google.gwt.i18n.client.LocalizableResource.Key(\"", - "\")" - ); - - - @Override - public void process(File filein, - File fileout, - String encoding) throws IOException { - - Set<String> keys = new HashSet<String>(); - extractKeys(filter1, filein, encoding, verbose, keys); - extractKeys(filter2, filein, encoding, verbose, keys); - extractKeys(filter3, filein, encoding, verbose, keys); - saveKeysToFile(fileout, keys); - } - - } -} \ No newline at end of file Copied: trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserGWTJavaMojo.java (from rev 1960, trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserGWTJavaMojo.java) =================================================================== --- trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserGWTJavaMojo.java (rev 0) +++ trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserGWTJavaMojo.java 2012-07-09 13:12:35 UTC (rev 1961) @@ -0,0 +1,278 @@ +/* + * #%L + * I18n :: Maven Plugin + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2011 CodeLutin, Tony Chemit + * %% + * 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>. + * #L% + */ +package org.nuiton.i18n.plugin.parser.impl; + +import org.apache.maven.plugin.logging.Log; +import org.apache.maven.plugins.annotations.LifecyclePhase; +import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.plugins.annotations.Parameter; +import org.nuiton.i18n.plugin.parser.AbstractFileParser; +import org.nuiton.i18n.plugin.parser.AbstractI18nParserMojo; +import org.nuiton.i18n.plugin.parser.FileParser; +import org.nuiton.i18n.plugin.parser.I18nSourceEntry; +import org.nuiton.i18n.plugin.parser.ParserException; +import org.nuiton.i18n.plugin.parser.SourceEntry; +import org.nuiton.io.FileUpdater; +import org.nuiton.io.MirroredFileUpdater; +import org.nuiton.io.SortedProperties; +import org.nuiton.processor.ProcessorUtil; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.LineNumberReader; +import java.util.HashSet; +import java.util.Set; + +/** + * To detect from GWT java files new I18n keys, says content of patterns : + * <ul> + * <li>{@code @Key("XXX")}</li> + * <li>{@code @LocalizableResource.Key("XXX")}</li> + * <li>{@code @com.google.gwt.i18n.client.LocalizableResource.Key("XXX")}</li> + * </ul> + * <b>Note: </b> this goal must always be invoked before the {@code process-resources} + * phase, otherwise all files will be considered as uptodate. + * + * @author tchemit <chemit@codelutin.com> + * @since 2.1 + */ +@Mojo(name = "parserGWTJava", defaultPhase = LifecyclePhase.GENERATE_RESOURCES) +public class ParserGWTJavaMojo extends AbstractI18nParserMojo { + + public static final String DEFAULT_INCLUDES = "**/*.java"; + + /** Root directory of the default entry. */ + @Parameter(property = "i18n.defaultBasedir", defaultValue = "${basedir}/src/main/java") + protected File defaultBasedir; + + /** + * Default included files to process (ant-like expression). + * <p/> + * <strong>Note:</strong> default value is **\/*.java + */ + @Parameter(property = "i18n.defaultIncludes", defaultValue = DEFAULT_INCLUDES, required = true) + protected String defaultIncludes; + + /** + * Defines the file name of the getter where to put detected i18n keys + * while getter phase. + * + * @since 2.0 + */ + @Parameter(property = "i18n.outputGetter", defaultValue = "gwt-java.getter") + protected String outputGetter; + + /** + * Where to generated temporary processed files. + * + * @since 2.0 + */ + @Parameter(property = "i18n.workdir", defaultValue = "${basedir}/target/i18n-workdir") + protected File workdir; + + protected MirroredFileUpdater entryUpdater; + + @Override + public String[] getDefaultIncludes() { + return new String[]{defaultIncludes}; + } + + @Override + public String[] getDefaultExcludes() { + return I18nSourceEntry.EMPTY_STRING_ARRAY; + } + + @Override + public File getDefaultBasedir() { + return defaultBasedir; + } + + @Override + protected boolean onEnterEntry(I18nSourceEntry entry) { + boolean b = super.onEnterEntry(entry); + if (!b) { + + // no skipped entry + // keep the file updater + entryUpdater = (MirroredFileUpdater) entry.getUpdater(); + } + return b; + } + + @Override + public FileUpdater newFileUpdater(SourceEntry entry) { + return new MirroredFileUpdater("", "", entry.getBasedir(), workdir) { + + @Override + public File getMirrorFile(File f) { + String file = + f.getAbsolutePath().substring(prefixSourceDirecotory); + return new File(destinationDirectory + File.separator + file); + } + }; + } + + @Override + protected String getOutGetter() { + return outputGetter; + } + + @Override + public FileParser newFileParser() { + + return new GWTJavaFileParser(getLog(), + encoding, + oldParser, + isShowTouchedFiles() + ); + } + + protected class GWTJavaFileParser extends AbstractFileParser { + + + public GWTJavaFileParser(Log log, + String encoding, + SortedProperties oldParser, + boolean showTouchedFiles) { + super(log, encoding, oldParser, showTouchedFiles); + } + + + protected File prepareFile(File file) throws IOException { + + // clean the jsp to make it xml + + File result = entryUpdater.getMirrorFile(file); + if (isVerbose()) { + getLog().info("Will process [" + file + "] to " + result); + } + try { + createDirectoryIfNecessary(result.getParentFile()); + } catch (IOException e) { + // don't care about it... + } + GWTJavaProcessor processor = new GWTJavaProcessor(); + processor.setVerbose(isVerbose()); + processor.process(file, result, getEncoding()); + return result; + } + + @Override + public void parseFile(File file) throws IOException { + + // clean the jsp to make it xml + + File processedFile = prepareFile(file); + + // process file to obtain + String line = null; + LineNumberReader lnr = new LineNumberReader(new InputStreamReader( + new FileInputStream(processedFile), getEncoding())); + try { + while ((line = lnr.readLine()) != null) { + parseLine(processedFile, line); + } + } catch (Exception e) { + if (line != null) { + getLog().error( + "could not parse line (" + lnr.getLineNumber() + ") '" + + line + "' of file " + file); + } + throw new ParserException(e); + } finally { + lnr.close(); + } + } + + @Override + public void parseLine(File file, String line) throws IOException { + + String key = line.trim(); + + if (key.isEmpty()) { + // no key detected on this line + return; + } + + // one key found in file, so file is marked as touched + setTouched(true); + // Found a i18n key, register it. + if (getLog().isDebugEnabled()) { + getLog().debug(file.getName() + " detected key = " + key); + } + registerKey(key); + } + } + + /** + * To Extract i18n keys from GWT java files. + * <p/> + * Says keep content only of those patterns : + * <ul> + * <li>{@code @Key("XXX")}</li> + * <li>{@code @LocalizableResource.Key("XXX")}</li> + * <li>{@code @com.google.gwt.i18n.client.LocalizableResource.Key("XXX")}</li> + * </ul> + * + * @author tchemit <chemit@codelutin.com> + * @since 2.1 + */ + public static class GWTJavaProcessor extends ProcessorHelper.AbstractParserProcessor { + + protected ProcessorUtil.FragmentExtractor filter1 = + new ProcessorUtil.FragmentExtractor( + "@Key(\"", + "\")" + ); + + protected ProcessorUtil.FragmentExtractor filter2 = + new ProcessorUtil.FragmentExtractor( + "@LocalizableResource.Key(\"", + "\")" + ); + + protected ProcessorUtil.FragmentExtractor filter3 = + new ProcessorUtil.FragmentExtractor( + "@com.google.gwt.i18n.client.LocalizableResource.Key(\"", + "\")" + ); + + + @Override + public void process(File filein, + File fileout, + String encoding) throws IOException { + + Set<String> keys = new HashSet<String>(); + extractKeys(filter1, filein, encoding, verbose, keys); + extractKeys(filter2, filein, encoding, verbose, keys); + extractKeys(filter3, filein, encoding, verbose, keys); + saveKeysToFile(fileout, keys); + } + + } +} \ No newline at end of file Deleted: trunk/i18n-maven-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 2012-05-30 14:03:24 UTC (rev 1957) +++ trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJavaMojo.java 2012-07-09 13:12:35 UTC (rev 1961) @@ -1,180 +0,0 @@ -/* - * #%L - * I18n :: Maven Plugin - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2007 - 2010 CodeLutin, Tony Chemit - * %% - * 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>. - * #L% - */ - -package org.nuiton.i18n.plugin.parser.impl; - -import org.apache.maven.plugin.logging.Log; -import org.nuiton.i18n.plugin.parser.AbstractFileParser; -import org.nuiton.i18n.plugin.parser.AbstractI18nParserMojo; -import org.nuiton.i18n.plugin.parser.FileParser; -import org.nuiton.i18n.plugin.parser.I18nSourceEntry; -import org.nuiton.i18n.plugin.parser.ParserException; -import org.nuiton.i18n.plugin.parser.SourceEntry; -import org.nuiton.io.FileUpdater; -import org.nuiton.io.FileUpdaterHelper; -import org.nuiton.io.SortedProperties; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.LineNumberReader; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * To parse java files to detect new i18n keys. - * <p/> - * <b>Note: </b> this goal must always be invoked before the {@code process-resources} - * phase, otherwise all files will be considered as uptodate. - * - * @author jruchaud <ruchaud@codelutin.com> - * @author tchemit <tchemit@codelutin.com> - * @goal parserJava - * @phase generate-resources - */ -public class ParserJavaMojo extends AbstractI18nParserMojo { - - /** - * Root directory of the default entry. - * - * @parameter expression="${i18n.defaultBasedir}" default-value="${basedir}/src/main/java" - */ - protected File defaultBasedir; - - /** - * Default included files to process (ant-like expression). - * - * @parameter expression="${i18n.defaultIncludes}" default-value="**\/*.java" - */ - protected String defaultIncludes; - - /** - * Defines the file name of the getter where to put detected i18n keys - * while getter phase. - * - * @parameter expression="${i18n.outputGetter}" default-value="java.getter" - * @since 2.0 - */ - protected String outputGetter; - - @Override - public String[] getDefaultIncludes() { - return new String[]{defaultIncludes}; - } - - @Override - public String[] getDefaultExcludes() { - return I18nSourceEntry.EMPTY_STRING_ARRAY; - } - - @Override - public File getDefaultBasedir() { - return defaultBasedir; - } - - @Override - public FileUpdater newFileUpdater(SourceEntry entry) { - return FileUpdaterHelper.newJavaFileUpdater(entry.getBasedir(), cp); - } - - @Override - protected String getOutGetter() { - return outputGetter; - } - - @Override - public FileParser newFileParser() { - - return new JavaFileParser(getLog(), - encoding, - oldParser, - isShowTouchedFiles() - ); - } - - protected static class JavaFileParser extends AbstractFileParser { - - /** - * Pattern used to detect i18n keys. - * - * @since 2.3 - */ - protected final Pattern i18nPattern = - Pattern.compile("(?:^_\\(\\s*\\\"|[^l]_\\(\\s*\\\"|l_\\([^,]+\\s*,\\s*\\\")(.*?)\""); - - public JavaFileParser(Log log, - String encoding, - SortedProperties oldParser, - boolean showTouchedFiles) { - super(log, encoding, oldParser, showTouchedFiles); - } - - public Pattern getI18nPattern() { - return i18nPattern; - } - - @Override - public void parseFile(File file) throws IOException { - String line = null; - LineNumberReader lnr = new LineNumberReader(new InputStreamReader( - new FileInputStream(file), getEncoding())); - try { - while ((line = lnr.readLine()) != null) { - parseLine(file, line); - } - } catch (Exception e) { - if (line != null) { - getLog().error( - "could not parse line (" + lnr.getLineNumber() + ") '" - + line + "' of file " + file); - } - throw new ParserException(e); - } finally { - lnr.close(); - } - } - - @Override - public void parseLine(File file, String line) throws IOException { - - Matcher matcher = i18nPattern.matcher(line); - - while (matcher.find()) { - - String key = matcher.group(1); - if (getLog().isDebugEnabled()) { - getLog().debug(file.getName() + " detected key = " + key); - } - // one key found in file, so file is marked as touched - setTouched(true); - - // register key - registerKey(key); - } - } - } - -} Copied: trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJavaMojo.java (from rev 1960, trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJavaMojo.java) =================================================================== --- trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJavaMojo.java (rev 0) +++ trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJavaMojo.java 2012-07-09 13:12:35 UTC (rev 1961) @@ -0,0 +1,182 @@ +/* + * #%L + * I18n :: Maven Plugin + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2007 - 2010 CodeLutin, Tony Chemit + * %% + * 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>. + * #L% + */ + +package org.nuiton.i18n.plugin.parser.impl; + +import org.apache.maven.plugin.logging.Log; +import org.apache.maven.plugins.annotations.LifecyclePhase; +import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.plugins.annotations.Parameter; +import org.nuiton.i18n.plugin.parser.AbstractFileParser; +import org.nuiton.i18n.plugin.parser.AbstractI18nParserMojo; +import org.nuiton.i18n.plugin.parser.FileParser; +import org.nuiton.i18n.plugin.parser.I18nSourceEntry; +import org.nuiton.i18n.plugin.parser.ParserException; +import org.nuiton.i18n.plugin.parser.SourceEntry; +import org.nuiton.io.FileUpdater; +import org.nuiton.io.FileUpdaterHelper; +import org.nuiton.io.SortedProperties; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.LineNumberReader; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * To parse java files to detect new i18n keys. + * <p/> + * <b>Note: </b> this goal must always be invoked before the {@code process-resources} + * phase, otherwise all files will be considered as uptodate. + * + * @author jruchaud <ruchaud@codelutin.com> + * @author tchemit <tchemit@codelutin.com> + */ +@Mojo(name = "parserJava", defaultPhase = LifecyclePhase.GENERATE_RESOURCES) +public class ParserJavaMojo extends AbstractI18nParserMojo { + + public static final String DEFAULT_INCLUDES = "**/*.java"; + + /** Root directory of the default entry. */ + @Parameter(property = "i18n.defaultBasedir", defaultValue = "${basedir}/src/main/java") + protected File defaultBasedir; + + /** + * Default included files to process (ant-like expression). + * <p/> + * <strong>Note:</strong> default value is **\/*.java + */ + @Parameter(property = "i18n.defaultIncludes", defaultValue = DEFAULT_INCLUDES, required = true) + protected String defaultIncludes; + + /** + * Defines the file name of the getter where to put detected i18n keys + * while getter phase. + * + * @since 2.0 + */ + @Parameter(property = "i18n.outputGetter", defaultValue = "java.getter") + protected String outputGetter; + + @Override + public String[] getDefaultIncludes() { + return new String[]{defaultIncludes}; + } + + @Override + public String[] getDefaultExcludes() { + return I18nSourceEntry.EMPTY_STRING_ARRAY; + } + + @Override + public File getDefaultBasedir() { + return defaultBasedir; + } + + @Override + public FileUpdater newFileUpdater(SourceEntry entry) { + return FileUpdaterHelper.newJavaFileUpdater(entry.getBasedir(), cp); + } + + @Override + protected String getOutGetter() { + return outputGetter; + } + + @Override + public FileParser newFileParser() { + + return new JavaFileParser(getLog(), + encoding, + oldParser, + isShowTouchedFiles() + ); + } + + protected static class JavaFileParser extends AbstractFileParser { + + /** + * Pattern used to detect i18n keys. + * + * @since 2.3 + */ + protected final Pattern i18nPattern = + Pattern.compile("(?:^_\\(\\s*\\\"|[^l]_\\(\\s*\\\"|l_\\([^,]+\\s*,\\s*\\\")(.*?)\""); + + public JavaFileParser(Log log, + String encoding, + SortedProperties oldParser, + boolean showTouchedFiles) { + super(log, encoding, oldParser, showTouchedFiles); + } + + public Pattern getI18nPattern() { + return i18nPattern; + } + + @Override + public void parseFile(File file) throws IOException { + String line = null; + LineNumberReader lnr = new LineNumberReader(new InputStreamReader( + new FileInputStream(file), getEncoding())); + try { + while ((line = lnr.readLine()) != null) { + parseLine(file, line); + } + } catch (Exception e) { + if (line != null) { + getLog().error( + "could not parse line (" + lnr.getLineNumber() + ") '" + + line + "' of file " + file); + } + throw new ParserException(e); + } finally { + lnr.close(); + } + } + + @Override + public void parseLine(File file, String line) throws IOException { + + Matcher matcher = i18nPattern.matcher(line); + + while (matcher.find()) { + + String key = matcher.group(1); + if (getLog().isDebugEnabled()) { + getLog().debug(file.getName() + " detected key = " + key); + } + // one key found in file, so file is marked as touched + setTouched(true); + + // register key + registerKey(key); + } + } + } + +} Deleted: trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJspMojo.java =================================================================== --- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJspMojo.java 2012-05-30 14:03:24 UTC (rev 1957) +++ trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJspMojo.java 2012-07-09 13:12:35 UTC (rev 1961) @@ -1,308 +0,0 @@ -/* - * #%L - * I18n :: Maven Plugin - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2007 - 2010 CodeLutin, Tony Chemit - * %% - * 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>. - * #L% - */ - -package org.nuiton.i18n.plugin.parser.impl; - -import org.apache.commons.lang.StringUtils; -import org.nuiton.i18n.plugin.parser.I18nSourceEntry; -import org.nuiton.i18n.plugin.parser.SourceEntry; -import org.nuiton.io.FileUpdater; -import org.nuiton.io.MirroredFileUpdater; -import org.nuiton.plugin.PluginHelper; -import org.nuiton.processor.ProcessorUtil; -import org.nuiton.processor.filters.DefaultFilter; -import org.nuiton.processor.filters.Filter; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.xpath.XPath; -import java.io.File; -import java.io.IOException; - -/** - * Find i18n keys from jsp files. - * <p/> - * <b>Note: </b> this goal must always be invoked before the {@code process-resources} - * phase, otherwise all files will be considered as uptodate. - * - * @author tchemit <chemit@codelutin.com> - * @goal parserJsp - * @phase generate-resources - * @since 2.0 - */ -public class ParserJspMojo extends AbstractParserXmlMojo { - - /** - * Root directory of the default entry. - * - * @parameter expression="${i18n.defaultBasedir}" default-value="${basedir}/src/main/webapp" - * @required - */ - protected File defaultBasedir; - - /** - * Default included files to process (ant-like expression). - * - * @parameter expression="${i18n.defaultIncludes}" default-value="**\/**.jsp" - */ - protected String defaultIncludes; - - /** - * Defines the core rules file used to detect i18n keys in jsp files. - * <p/> - * <b>Note :</b> If you do not want to use it, set it to empty and fill the - * {@link #userRulesFiles} parameter. - * - * @parameter expression="${i18n.coreRuleFile}" - * @since 2.0 - */ - protected String coreRuleFile; - - /** - * Defines the file name of the getter where to put detected i18n keys - * while getter phase. - * - * @parameter expression="${i18n.outputGetter}" default-value="jsp.getter" - * @since 2.0 - */ - protected String outputGetter; - - /** - * Where to generated temporary processed files. - * - * @parameter expression="${i18n.workdir}" default-value="${basedir}/target/i18n-workdir" - * @since 2.0 - */ - protected File workdir; - - @Override - public String[] getDefaultIncludes() { - return new String[]{defaultIncludes}; - } - - @Override - public String[] getDefaultExcludes() { - return I18nSourceEntry.EMPTY_STRING_ARRAY; - } - - @Override - public File getDefaultBasedir() { - return defaultBasedir; - } - - MirroredFileUpdater entryUpdater; - - @Override - protected boolean onEnterEntry(I18nSourceEntry entry) { - boolean b = super.onEnterEntry(entry); - if (!b) { - - // no skipped entry - // keep the file updater - entryUpdater = (MirroredFileUpdater) entry.getUpdater(); - } - return b; - } - - @Override - public FileUpdater newFileUpdater(SourceEntry entry) { - return new MirroredFileUpdater("", "", entry.getBasedir(), workdir) { - - @Override - public File getMirrorFile(File f) { - String file = - f.getAbsolutePath().substring(prefixSourceDirecotory); - return new File(destinationDirectory + File.separator + file + "~"); - } - }; - } - - @Override - protected String getOutGetter() { - return outputGetter; - } - - @Override - protected String getCoreRuleFile() { - return coreRuleFile; - } - - protected XmlFileParser newXmlFileParser(final XPath xpath, - final DocumentBuilder builder) { - - return new XmlFileParser(getLog(), - encoding, - oldParser, - showTouchedFiles, - rules, - xpath, - builder, - namespaces, - isVerbose()) { - - @Override - public File prepareFile(File file) throws IOException { - - // clean the jsp to make it xml - - File result = entryUpdater.getMirrorFile(file); - createDirectoryIfNecessary(result.getParentFile()); - JspFileProcessor processor = new JspFileProcessor(); - processor.process(file, result, getEncoding()); - String resultFileContent = - PluginHelper.readAsString(result, getEncoding()); - resultFileContent = resultFileContent.trim(); - - if (StringUtils.isBlank(resultFileContent)) { - - // nothing to scan inside this file - result = null; - } else { - - if (resultFileContent.startsWith("<html") || - resultFileContent.startsWith("<HTML") || - resultFileContent.startsWith("<?xml") - ) { - - // document should be well-formed... - - } else { - // to be sure, document is well formed, add a start and end tag - resultFileContent = "<div>\n" + resultFileContent + "\n</div>"; - - PluginHelper.writeString(result, resultFileContent, getEncoding()); - } - - } - - return result; - } - - @Override - public String extract(String i18nString) { - String s = null; - if (!StringUtils.isEmpty(i18nString.trim())) { - s = i18nString.trim(); - } - if (getLog().isDebugEnabled()) { - getLog().debug(i18nString + " = " + s); - } - return s; - } - - }; - } - - /** - * To transform jsp files to valid xml files. - * <p/> - * Says : - * <ul> - * <li>Remove jsp directive</li> - * <li>Remove jsp comment</li> - * <li>Remove any tags in attributes (used for example in struts)</li> - * <li>? Other thing</li> - * </ul> - * - * @author tchemit <chemit@codelutin.com> - * @since 2.0 - */ - public static class JspFileProcessor extends ProcessorHelper.AbstractParserProcessor { - - protected ProcessorHelper.FragmentRemover remover1 = - new ProcessorHelper.FragmentRemover( - "<" + "%" + "-" + "-", - "-" + "-" + "%" + ">" - ); - - protected ProcessorHelper.FragmentRemover remover2 = - new ProcessorHelper.FragmentRemover( - "<" + "%", - "%" + ">" - ); - - protected ProcessorHelper.FragmentRemover remover3 = - new ProcessorHelper.FragmentRemover( - "<" + "!" + "-" + "-", - "-" + "-" + ">" - ); - - public JspFileProcessor() { - setInputFilter( - new Filter[]{ - remover1, - remover2, - remover3, - new JspAttributeWithTagFilter() - } - ); - } - - /** - * @param filein the source file to process - * @param fileout the output file to generate - * @param encoding encoding used to read and write files - * @throws IOException if any io problems while processing - * @since 1.0.4 - */ - @Override - public void process(File filein, - File fileout, - String encoding) throws IOException { - ProcessorUtil.doProcess(this, filein, fileout, encoding); - } - - /** - * To remove in attributes any sub tags inside it (used for example in - * struts) from jsp files. - * - * @author tchemit <chemit@codelutin.com> - * @since 2.0 - */ - public static class JspAttributeWithTagFilter extends DefaultFilter { - - private String header = "=" + "\"" + "<"; - - private String footer = "\"" + "/" + ">" + "\""; - - @Override - protected String performInFilter(String ch) { - return "=\"\""; - } - - @Override - protected String performOutFilter(String ch) { - return ch; - } - - protected String getHeader() { - return header; - } - - protected String getFooter() { - return footer; - } - } - } -} Copied: trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJspMojo.java (from rev 1960, trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJspMojo.java) =================================================================== --- trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJspMojo.java (rev 0) +++ trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJspMojo.java 2012-07-09 13:12:35 UTC (rev 1961) @@ -0,0 +1,315 @@ +/* + * #%L + * I18n :: Maven Plugin + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2007 - 2010 CodeLutin, Tony Chemit + * %% + * 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>. + * #L% + */ + +package org.nuiton.i18n.plugin.parser.impl; + +import org.apache.commons.lang.StringUtils; +import org.apache.maven.plugins.annotations.LifecyclePhase; +import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.plugins.annotations.Parameter; +import org.nuiton.i18n.plugin.parser.I18nSourceEntry; +import org.nuiton.i18n.plugin.parser.SourceEntry; +import org.nuiton.io.FileUpdater; +import org.nuiton.io.MirroredFileUpdater; +import org.nuiton.plugin.PluginHelper; +import org.nuiton.processor.ProcessorUtil; +import org.nuiton.processor.filters.DefaultFilter; +import org.nuiton.processor.filters.Filter; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.xpath.XPath; +import java.io.File; +import java.io.IOException; + +/** + * Find i18n keys from jsp files. + * <p/> + * <b>Note: </b> this goal must always be invoked before the {@code process-resources} + * phase, otherwise all files will be considered as uptodate. + * + * @author tchemit <chemit@codelutin.com> + * @since 2.0 + */ +@Mojo(name = "parserJsp", defaultPhase = LifecyclePhase.GENERATE_RESOURCES) +public class ParserJspMojo extends AbstractParserXmlMojo { + + public static final String DEFAULT_INCLUDES = "**/*.jsp"; + + /** + * Root directory of the default entry. + * + * @since 2.0 + */ + @Parameter(property = "i18n.defaultBasedir", defaultValue = "${basedir}/src/main/webapp", required = true) + protected File defaultBasedir; + + /** + * Default included files to process (ant-like expression). + * <p/> + * <strong>Note:</strong> default value is **\/*.jsp + * + * @since 2.0 + */ + @Parameter(property = "i18n.defaultIncludes", defaultValue = DEFAULT_INCLUDES, required = true) + protected String defaultIncludes; + + /** + * Defines the core rules file used to detect i18n keys in jsp files. + * <p/> + * <b>Note :</b> If you do not want to use it, set it to empty and fill the + * {@link #userRulesFiles} parameter. + * + * @since 2.0 + */ + @Parameter(property = "i18n.coreRuleFile") + protected String coreRuleFile; + + /** + * Defines the file name of the getter where to put detected i18n keys + * while getter phase. + * + * @since 2.0 + */ + @Parameter(property = "i18n.outputGetter", defaultValue = "jsp.getter", required = true) + protected String outputGetter; + + /** + * Where to generated temporary processed files. + * + * @since 2.0 + */ + @Parameter(property = "i18n.workdir", defaultValue = "${basedir}/target/i18n-workdir", required = true) + protected File workdir; + + @Override + public String[] getDefaultIncludes() { + return new String[]{defaultIncludes}; + } + + @Override + public String[] getDefaultExcludes() { + return I18nSourceEntry.EMPTY_STRING_ARRAY; + } + + @Override + public File getDefaultBasedir() { + return defaultBasedir; + } + + MirroredFileUpdater entryUpdater; + + @Override + protected boolean onEnterEntry(I18nSourceEntry entry) { + boolean b = super.onEnterEntry(entry); + if (!b) { + + // no skipped entry + // keep the file updater + entryUpdater = (MirroredFileUpdater) entry.getUpdater(); + } + return b; + } + + @Override + public FileUpdater newFileUpdater(SourceEntry entry) { + return new MirroredFileUpdater("", "", entry.getBasedir(), workdir) { + + @Override + public File getMirrorFile(File f) { + String file = + f.getAbsolutePath().substring(prefixSourceDirecotory); + return new File(destinationDirectory + File.separator + file + "~"); + } + }; + } + + @Override + protected String getOutGetter() { + return outputGetter; + } + + @Override + protected String getCoreRuleFile() { + return coreRuleFile; + } + + protected XmlFileParser newXmlFileParser(final XPath xpath, + final DocumentBuilder builder) { + + return new XmlFileParser(getLog(), + encoding, + oldParser, + showTouchedFiles, + rules, + xpath, + builder, + namespaces, + isVerbose()) { + + @Override + public File prepareFile(File file) throws IOException { + + // clean the jsp to make it xml + + File result = entryUpdater.getMirrorFile(file); + createDirectoryIfNecessary(result.getParentFile()); + JspFileProcessor processor = new JspFileProcessor(); + processor.process(file, result, getEncoding()); + String resultFileContent = + PluginHelper.readAsString(result, getEncoding()); + resultFileContent = resultFileContent.trim(); + + if (StringUtils.isBlank(resultFileContent)) { + + // nothing to scan inside this file + result = null; + } else { + + if (resultFileContent.startsWith("<html") || + resultFileContent.startsWith("<HTML") || + resultFileContent.startsWith("<?xml") + ) { + + // document should be well-formed... + + } else { + // to be sure, document is well formed, add a start and end tag + resultFileContent = "<div>\n" + resultFileContent + "\n</div>"; + + PluginHelper.writeString(result, resultFileContent, getEncoding()); + } + + } + + return result; + } + + @Override + public String extract(String i18nString) { + String s = null; + if (!StringUtils.isEmpty(i18nString.trim())) { + s = i18nString.trim(); + } + if (getLog().isDebugEnabled()) { + getLog().debug(i18nString + " = " + s); + } + return s; + } + + }; + } + + /** + * To transform jsp files to valid xml files. + * <p/> + * Says : + * <ul> + * <li>Remove jsp directive</li> + * <li>Remove jsp comment</li> + * <li>Remove any tags in attributes (used for example in struts)</li> + * <li>? Other thing</li> + * </ul> + * + * @author tchemit <chemit@codelutin.com> + * @since 2.0 + */ + public static class JspFileProcessor extends ProcessorHelper.AbstractParserProcessor { + + protected ProcessorHelper.FragmentRemover remover1 = + new ProcessorHelper.FragmentRemover( + "<" + "%" + "-" + "-", + "-" + "-" + "%" + ">" + ); + + protected ProcessorHelper.FragmentRemover remover2 = + new ProcessorHelper.FragmentRemover( + "<" + "%", + "%" + ">" + ); + + protected ProcessorHelper.FragmentRemover remover3 = + new ProcessorHelper.FragmentRemover( + "<" + "!" + "-" + "-", + "-" + "-" + ">" + ); + + public JspFileProcessor() { + setInputFilter( + new Filter[]{ + remover1, + remover2, + remover3, + new JspAttributeWithTagFilter() + } + ); + } + + /** + * @param filein the source file to process + * @param fileout the output file to generate + * @param encoding encoding used to read and write files + * @throws IOException if any io problems while processing + * @since 1.0.4 + */ + @Override + public void process(File filein, + File fileout, + String encoding) throws IOException { + ProcessorUtil.doProcess(this, filein, fileout, encoding); + } + + /** + * To remove in attributes any sub tags inside it (used for example in + * struts) from jsp files. + * + * @author tchemit <chemit@codelutin.com> + * @since 2.0 + */ + public static class JspAttributeWithTagFilter extends DefaultFilter { + + private String header = "=" + "\"" + "<"; + + private String footer = "\"" + "/" + ">" + "\""; + + @Override + protected String performInFilter(String ch) { + return "=\"\""; + } + + @Override + protected String performOutFilter(String ch) { + return ch; + } + + protected String getHeader() { + return header; + } + + protected String getFooter() { + return footer; + } + } + } +} Deleted: trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserTapestryMojo.java =================================================================== --- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserTapestryMojo.java 2012-05-30 14:03:24 UTC (rev 1957) +++ trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserTapestryMojo.java 2012-07-09 13:12:35 UTC (rev 1961) @@ -1,287 +0,0 @@ -/* - * #%L - * I18n :: Maven Plugin - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2011 CodeLutin, Tony Chemit - * %% - * 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>. - * #L% - */ -package org.nuiton.i18n.plugin.parser.impl; - -import org.apache.maven.plugin.logging.Log; -import org.nuiton.i18n.plugin.parser.AbstractFileParser; -import org.nuiton.i18n.plugin.parser.AbstractI18nParserMojo; -import org.nuiton.i18n.plugin.parser.FileParser; -import org.nuiton.i18n.plugin.parser.I18nSourceEntry; -import org.nuiton.i18n.plugin.parser.ParserException; -import org.nuiton.i18n.plugin.parser.SourceEntry; -import org.nuiton.io.FileUpdater; -import org.nuiton.io.MirroredFileUpdater; -import org.nuiton.io.SortedProperties; -import org.nuiton.processor.ProcessorUtil; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.LineNumberReader; -import java.util.HashSet; -import java.util.Set; - -/** - * To parse Tapestry templates to detect new I18n keys, says content of patterns : - * {@code ${message:XXX}} and {@code ${format:XXX=...}}. - * <p/> - * <p/> - * <b>Note: </b> this goal must always be invoked before the {@code process-resources} - * phase, otherwise all files will be considered as uptodate. - * - * @author tchemit <chemit@codelutin.com> - * @goal parserTapestry - * @phase generate-resources - * @since 2.1 - */ -public class ParserTapestryMojo extends AbstractI18nParserMojo { - - /** - * Root directory of the default entry. - * - * @parameter expression="${i18n.defaultBasedir}" default-value="${basedir}/src/main/webapp" - */ - protected File defaultBasedir; - - /** - * Default included files to process (ant-like expression). - * - * @parameter expression="${i18n.defaultIncludes}" default-value="**\/*.tml" - */ - protected String defaultIncludes; - - /** - * Defines the file name of the getter where to put detected i18n keys - * while getter phase. - * - * @parameter expression="${i18n.outputGetter}" default-value="tapestry.getter" - * @since 2.0 - */ - protected String outputGetter; - - /** - * Where to generated temporary processed files. - * - * @parameter expression="${i18n.workdir}" default-value="${basedir}/target/i18n-workdir" - * @since 2.0 - */ - protected File workdir; - - protected MirroredFileUpdater entryUpdater; - - @Override - public String[] getDefaultIncludes() { - return new String[]{defaultIncludes}; - } - - @Override - public String[] getDefaultExcludes() { - return I18nSourceEntry.EMPTY_STRING_ARRAY; - } - - @Override - public File getDefaultBasedir() { - return defaultBasedir; - } - - @Override - protected boolean onEnterEntry(I18nSourceEntry entry) { - boolean b = super.onEnterEntry(entry); - if (!b) { - - // no skipped entry - // keep the file updater - entryUpdater = (MirroredFileUpdater) entry.getUpdater(); - } - return b; - } - - @Override - public FileUpdater newFileUpdater(SourceEntry entry) { - return new MirroredFileUpdater("", "", entry.getBasedir(), workdir) { - - @Override - public File getMirrorFile(File f) { - String file = - f.getAbsolutePath().substring(prefixSourceDirecotory); - return new File(destinationDirectory + File.separator + file); - } - }; - } - - @Override - protected String getOutGetter() { - return outputGetter; - } - - @Override - public FileParser newFileParser() { - - return new TapestryFileParser(getLog(), - encoding, - oldParser, - isShowTouchedFiles() - ); - } - - protected class TapestryFileParser extends AbstractFileParser { - - - public TapestryFileParser(Log log, - String encoding, - SortedProperties oldParser, - boolean showTouchedFiles) { - super(log, encoding, oldParser, showTouchedFiles); - } - - - protected File prepareFile(File file) throws IOException { - - // clean the jsp to make it xml - - File result = entryUpdater.getMirrorFile(file); - if (isVerbose()) { - getLog().info("Will process [" + file + "] to " + result); - } - try { - createDirectoryIfNecessary(result.getParentFile()); - } catch (IOException e) { - // don't care about it... - } - TapestryFileProcessor processor = new TapestryFileProcessor(); - processor.setVerbose(isVerbose()); - processor.process(file, result, getEncoding()); - return result; - } - - @Override - public void parseFile(File file) throws IOException { - - // clean the jsp to make it xml - - File processedFile = prepareFile(file); - - // process file to obtain - String line = null; - LineNumberReader lnr = new LineNumberReader(new InputStreamReader( - new FileInputStream(processedFile), getEncoding())); - try { - while ((line = lnr.readLine()) != null) { - parseLine(processedFile, line); - } - } catch (Exception e) { - if (line != null) { - getLog().error( - "could not parse line (" + lnr.getLineNumber() + ") '" - + line + "' of file " + file); - } - throw new ParserException(e); - } finally { - lnr.close(); - } - } - - @Override - public void parseLine(File file, String line) throws IOException { - - String key = line.trim(); - - if (key.isEmpty()) { - // no key detected on this line - return; - } - - // one key found in file, so file is marked as touched - setTouched(true); - // Found a i18n key, register it. - if (getLog().isDebugEnabled()) { - getLog().debug(file.getName() + " detected key = " + key); - } - registerKey(key); - } - } - - /** - * To Extract i18n keys from tapestry template files. - * <p/> - * Says : - * <ul> - * <li>Remove all xml comments</li> - * <li>Keep content of {@code ${message:XXX}}</li> - * <li>Keep content of {@code ${format:XXX}}}</li> - * </ul> - * - * @author tchemit <chemit@codelutin.com> - * @since 2.1 - */ - public static class TapestryFileProcessor extends ProcessorHelper.AbstractParserProcessor { - - protected ProcessorHelper.FragmentRemover remover1 = - new ProcessorHelper.FragmentRemover( - "<" + "!" + "-" + "-", - "-" + "-" + ">" - ); - - protected ProcessorUtil.FragmentExtractor extractor1 = - new ProcessorUtil.FragmentExtractor( - "$" + "{" + "m" + "e" + "s" + "s" + "a" + "g" + "e" + ":", - "}" - ); - - protected ProcessorUtil.FragmentExtractor extractor2 = - new ProcessorUtil.FragmentExtractor( - "$" + "{" + "f" + "o" + "r" + "m" + "a" + "t" + ":", - "}") { - - @Override - protected String performInFilter(String ch) { - int i = ch.indexOf('='); - if (verbose) { - log.info("Detected key " + ch); - } - if (i == -1) { - return ""; - } - return ch.substring(0, i) + "\n"; - } - }; - - - public void process(File filein, - File fileout, - String encoding) throws IOException { - - // remove comment fragments - File fileTemp = new File(fileout.getAbsolutePath() + "-no-comment"); - removefragments(remover1, filein, fileTemp, encoding, false); - - Set<String> keys = new HashSet<String>(); - extractKeys(extractor1, fileTemp, encoding, verbose, keys); - extractKeys(extractor2, fileTemp, encoding, verbose, keys); - saveKeysToFile(fileout, keys); - } - } -} Copied: trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserTapestryMojo.java (from rev 1960, trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserTapestryMojo.java) =================================================================== --- trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserTapestryMojo.java (rev 0) +++ trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserTapestryMojo.java 2012-07-09 13:12:35 UTC (rev 1961) @@ -0,0 +1,295 @@ +/* + * #%L + * I18n :: Maven Plugin + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2011 CodeLutin, Tony Chemit + * %% + * 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>. + * #L% + */ +package org.nuiton.i18n.plugin.parser.impl; + +import org.apache.maven.plugin.logging.Log; +import org.apache.maven.plugins.annotations.LifecyclePhase; +import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.plugins.annotations.Parameter; +import org.nuiton.i18n.plugin.parser.AbstractFileParser; +import org.nuiton.i18n.plugin.parser.AbstractI18nParserMojo; +import org.nuiton.i18n.plugin.parser.FileParser; +import org.nuiton.i18n.plugin.parser.I18nSourceEntry; +import org.nuiton.i18n.plugin.parser.ParserException; +import org.nuiton.i18n.plugin.parser.SourceEntry; +import org.nuiton.io.FileUpdater; +import org.nuiton.io.MirroredFileUpdater; +import org.nuiton.io.SortedProperties; +import org.nuiton.processor.ProcessorUtil; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.LineNumberReader; +import java.util.HashSet; +import java.util.Set; + +/** + * To parse Tapestry templates to detect new I18n keys, says content of patterns : + * {@code ${message:XXX}} and {@code ${format:XXX=...}}. + * <p/> + * <p/> + * <b>Note: </b> this goal must always be invoked before the {@code process-resources} + * phase, otherwise all files will be considered as uptodate. + * + * @author tchemit <chemit@codelutin.com> + * @since 2.1 + */ +@Mojo(name = "parserTapestry", defaultPhase = LifecyclePhase.GENERATE_RESOURCES) +public class ParserTapestryMojo extends AbstractI18nParserMojo { + + public static final String DEFAULT_INCLUDES = "**/*.tml"; + + /** + * Root directory of the default entry. + * + * @since 2.1 + */ + @Parameter(property = "i18n.defaultBasedir", defaultValue = "${basedir}/src/main/webapp", required = true) + protected File defaultBasedir; + + /** + * Default included files to process (ant-like expression). + * + * <strong>Note:</strong> default value is **\/*.tml + * + * @since 2.1 + */ + @Parameter(property = "i18n.defaultIncludes", defaultValue = DEFAULT_INCLUDES, required = true) + protected String defaultIncludes; + + /** + * Defines the file name of the getter where to put detected i18n keys + * while getter phase. + * + * @since 2.1 + */ + @Parameter(property = "i18n.outputGetter", defaultValue = "tapestry.getter", required = true) + protected String outputGetter; + + /** + * Where to generated temporary processed files. + * + * @since 2.1 + */ + @Parameter(property = "i18n.workdir", defaultValue = "${basedir}/target/i18n-workdir") + protected File workdir; + + protected MirroredFileUpdater entryUpdater; + + @Override + public String[] getDefaultIncludes() { + return new String[]{defaultIncludes}; + } + + @Override + public String[] getDefaultExcludes() { + return I18nSourceEntry.EMPTY_STRING_ARRAY; + } + + @Override + public File getDefaultBasedir() { + return defaultBasedir; + } + + @Override + protected boolean onEnterEntry(I18nSourceEntry entry) { + boolean b = super.onEnterEntry(entry); + if (!b) { + + // no skipped entry + // keep the file updater + entryUpdater = (MirroredFileUpdater) entry.getUpdater(); + } + return b; + } + + @Override + public FileUpdater newFileUpdater(SourceEntry entry) { + return new MirroredFileUpdater("", "", entry.getBasedir(), workdir) { + + @Override + public File getMirrorFile(File f) { + String file = + f.getAbsolutePath().substring(prefixSourceDirecotory); + return new File(destinationDirectory + File.separator + file); + } + }; + } + + @Override + protected String getOutGetter() { + return outputGetter; + } + + @Override + public FileParser newFileParser() { + + return new TapestryFileParser(getLog(), + encoding, + oldParser, + isShowTouchedFiles() + ); + } + + protected class TapestryFileParser extends AbstractFileParser { + + + public TapestryFileParser(Log log, + String encoding, + SortedProperties oldParser, + boolean showTouchedFiles) { + super(log, encoding, oldParser, showTouchedFiles); + } + + + protected File prepareFile(File file) throws IOException { + + // clean the jsp to make it xml + + File result = entryUpdater.getMirrorFile(file); + if (isVerbose()) { + getLog().info("Will process [" + file + "] to " + result); + } + try { + createDirectoryIfNecessary(result.getParentFile()); + } catch (IOException e) { + // don't care about it... + } + TapestryFileProcessor processor = new TapestryFileProcessor(); + processor.setVerbose(isVerbose()); + processor.process(file, result, getEncoding()); + return result; + } + + @Override + public void parseFile(File file) throws IOException { + + // clean the jsp to make it xml + + File processedFile = prepareFile(file); + + // process file to obtain + String line = null; + LineNumberReader lnr = new LineNumberReader(new InputStreamReader( + new FileInputStream(processedFile), getEncoding())); + try { + while ((line = lnr.readLine()) != null) { + parseLine(processedFile, line); + } + } catch (Exception e) { + if (line != null) { + getLog().error( + "could not parse line (" + lnr.getLineNumber() + ") '" + + line + "' of file " + file); + } + throw new ParserException(e); + } finally { + lnr.close(); + } + } + + @Override + public void parseLine(File file, String line) throws IOException { + + String key = line.trim(); + + if (key.isEmpty()) { + // no key detected on this line + return; + } + + // one key found in file, so file is marked as touched + setTouched(true); + // Found a i18n key, register it. + if (getLog().isDebugEnabled()) { + getLog().debug(file.getName() + " detected key = " + key); + } + registerKey(key); + } + } + + /** + * To Extract i18n keys from tapestry template files. + * <p/> + * Says : + * <ul> + * <li>Remove all xml comments</li> + * <li>Keep content of {@code ${message:XXX}}</li> + * <li>Keep content of {@code ${format:XXX}}}</li> + * </ul> + * + * @author tchemit <chemit@codelutin.com> + * @since 2.1 + */ + public static class TapestryFileProcessor extends ProcessorHelper.AbstractParserProcessor { + + protected ProcessorHelper.FragmentRemover remover1 = + new ProcessorHelper.FragmentRemover( + "<" + "!" + "-" + "-", + "-" + "-" + ">" + ); + + protected ProcessorUtil.FragmentExtractor extractor1 = + new ProcessorUtil.FragmentExtractor( + "$" + "{" + "m" + "e" + "s" + "s" + "a" + "g" + "e" + ":", + "}" + ); + + protected ProcessorUtil.FragmentExtractor extractor2 = + new ProcessorUtil.FragmentExtractor( + "$" + "{" + "f" + "o" + "r" + "m" + "a" + "t" + ":", + "}") { + + @Override + protected String performInFilter(String ch) { + int i = ch.indexOf('='); + if (verbose) { + log.info("Detected key " + ch); + } + if (i == -1) { + return ""; + } + return ch.substring(0, i) + "\n"; + } + }; + + + public void process(File filein, + File fileout, + String encoding) throws IOException { + + // remove comment fragments + File fileTemp = new File(fileout.getAbsolutePath() + "-no-comment"); + removefragments(remover1, filein, fileTemp, encoding, false); + + Set<String> keys = new HashSet<String>(); + extractKeys(extractor1, fileTemp, encoding, verbose, keys); + extractKeys(extractor2, fileTemp, encoding, verbose, keys); + saveKeysToFile(fileout, keys); + } + } +} Deleted: trunk/i18n-maven-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/ParserValidationMojo.java 2012-05-30 14:03:24 UTC (rev 1957) +++ trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserValidationMojo.java 2012-07-09 13:12:35 UTC (rev 1961) @@ -1,220 +0,0 @@ -/* - * #%L - * I18n :: Maven Plugin - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2007 - 2010 CodeLutin, Tony Chemit - * %% - * 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>. - * #L% - */ - -package org.nuiton.i18n.plugin.parser.impl; - -import org.nuiton.i18n.plugin.parser.I18nSourceEntry; -import org.nuiton.i18n.plugin.parser.SourceEntry; -import org.nuiton.io.FileUpdater; -import org.nuiton.io.MirroredFileUpdater; -import org.xml.sax.EntityResolver; -import org.xml.sax.InputSource; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.xpath.XPath; -import java.io.File; -import java.io.IOException; -import java.net.SocketTimeoutException; -import java.net.URL; -import java.net.URLConnection; - -/** - * Find i18n keys from xworks xml validation files. - * <p/> - * <b>Note: </b> this goal must always be invoked before the {@code process-resources} - * phase, otherwise all files will be considered as uptodate. - * - * @author tchemit <chemit@codelutin.com> - * @goal parserValidation - * @phase generate-resources - */ -public class ParserValidationMojo extends AbstractParserXmlMojo { - - final URL xworksResource = getClass().getResource("/xwork-validator-1.0.2.dtd"); - - /** - * Root directory of the default entry. - * - * @parameter expression="${i18n.defaultBasedir}" default-value="${basedir}/src/main/resources" - * @required - */ - protected File defaultBasedir; - - /** - * Default included files to process (ant-like expression). - * - * @parameter expression="${i18n.defaultIncludes}" default-value="**\/**-validation.xml" - */ - protected String defaultIncludes; - - /** - * Defines the core rules file used to detect i18n keys in xml validation - * files. - * <p/> - * <b>Note :</b> If you do not want to use it, set it to empty and fill the - * {@link #userRulesFiles} parameter. - * - * @parameter expression="${i18n.coreRuleFile}" default-value="validation.rules" - * @since 2.0 - */ - protected String coreRuleFile; - - /** - * Always use the local xowrks dtd to increase performance. - * - * @parameter expression="${i18n.useLocalResolver}" default-value="true" - * @since 1.6.0 - */ - protected boolean useLocalResolver; - - /** - * Defines the file name of the getter where to put detected i18n keys - * while getter phase. - * - * @parameter expression="${i18n.outputGetter}" default-value="validation.getter" - * @since 2.0 - */ - protected String outputGetter; - - - @Override - public String[] getDefaultIncludes() { - return new String[]{defaultIncludes}; - } - - @Override - public String[] getDefaultExcludes() { - return I18nSourceEntry.EMPTY_STRING_ARRAY; - } - - @Override - public File getDefaultBasedir() { - return defaultBasedir; - } - - @Override - public FileUpdater newFileUpdater(SourceEntry entry) { - return new MirroredFileUpdater("", "", entry.getBasedir(), cp) { - - @Override - public File getMirrorFile(File f) { - String file = - f.getAbsolutePath().substring(prefixSourceDirecotory); - return new File(destinationDirectory + File.separator + file); - } - }; - } - - @Override - protected String getOutGetter() { - return outputGetter; - } - - @Override - protected String getCoreRuleFile() { - return coreRuleFile; - } - - protected XmlFileParser newXmlFileParser(final XPath xpath, - final DocumentBuilder builder) { - - // add cached entity resolver - builder.setEntityResolver(getEntityResolver()); - - return new XmlFileParser(getLog(), - encoding, - oldParser, - showTouchedFiles, - rules, - xpath, - builder, - namespaces, - isVerbose()) { - @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; - } - }; - } - - protected 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 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/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserValidationMojo.java (from rev 1960, trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserValidationMojo.java) =================================================================== --- trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserValidationMojo.java (rev 0) +++ trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserValidationMojo.java 2012-07-09 13:12:35 UTC (rev 1961) @@ -0,0 +1,221 @@ +/* + * #%L + * I18n :: Maven Plugin + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2007 - 2010 CodeLutin, Tony Chemit + * %% + * 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>. + * #L% + */ + +package org.nuiton.i18n.plugin.parser.impl; + +import org.apache.maven.plugins.annotations.LifecyclePhase; +import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.plugins.annotations.Parameter; +import org.nuiton.i18n.plugin.parser.I18nSourceEntry; +import org.nuiton.i18n.plugin.parser.SourceEntry; +import org.nuiton.io.FileUpdater; +import org.nuiton.io.MirroredFileUpdater; +import org.xml.sax.EntityResolver; +import org.xml.sax.InputSource; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.xpath.XPath; +import java.io.File; +import java.io.IOException; +import java.net.SocketTimeoutException; +import java.net.URL; +import java.net.URLConnection; + +/** + * Find i18n keys from xworks xml validation files. + * <p/> + * <b>Note: </b> this goal must always be invoked before the {@code process-resources} + * phase, otherwise all files will be considered as uptodate. + * + * @author tchemit <chemit@codelutin.com> + */ +@Mojo(name = "parserValidation", defaultPhase = LifecyclePhase.GENERATE_RESOURCES) +public class ParserValidationMojo extends AbstractParserXmlMojo { + + public static final String DEFAULT_INCLUDES = "**/*-validation.xml"; + + final URL xworksResource = getClass().getResource("/xwork-validator-1.0.2.dtd"); + + /** Root directory of the default entry. */ + @Parameter(property = "i18n.defaultBasedir", defaultValue = "${basedir}/src/main/resources", required = true) + protected File defaultBasedir; + + /** + * Default included files to process (ant-like expression). + * <p/> + * <strong>Note:</strong> default value is **\/**-validation.xml + */ + @Parameter(property = "i18n.defaultIncludes", defaultValue = DEFAULT_INCLUDES, required = true) + protected String defaultIncludes; + + /** + * Defines the core rules file used to detect i18n keys in xml validation + * files. + * <p/> + * <b>Note :</b> If you do not want to use it, set it to empty and fill the + * {@link #userRulesFiles} parameter. + * + * @since 2.0 + */ + @Parameter(property = "i18n.coreRuleFile", defaultValue = "validation.rules", required = true) + protected String coreRuleFile; + + /** + * Always use the local xowrks dtd to increase performance. + * + * @since 1.6.0 + */ + @Parameter(property = "i18n.useLocalResolver", defaultValue = "true") + protected boolean useLocalResolver; + + /** + * Defines the file name of the getter where to put detected i18n keys + * while getter phase. + * + * @since 2.0 + */ + @Parameter(property = "i18n.outputGetter", defaultValue = "validation.getter", required = true) + protected String outputGetter; + + + @Override + public String[] getDefaultIncludes() { + return new String[]{defaultIncludes}; + } + + @Override + public String[] getDefaultExcludes() { + return I18nSourceEntry.EMPTY_STRING_ARRAY; + } + + @Override + public File getDefaultBasedir() { + return defaultBasedir; + } + + @Override + public FileUpdater newFileUpdater(SourceEntry entry) { + return new MirroredFileUpdater("", "", entry.getBasedir(), cp) { + + @Override + public File getMirrorFile(File f) { + String file = + f.getAbsolutePath().substring(prefixSourceDirecotory); + return new File(destinationDirectory + File.separator + file); + } + }; + } + + @Override + protected String getOutGetter() { + return outputGetter; + } + + @Override + protected String getCoreRuleFile() { + return coreRuleFile; + } + + protected XmlFileParser newXmlFileParser(final XPath xpath, + final DocumentBuilder builder) { + + // add cached entity resolver + builder.setEntityResolver(getEntityResolver()); + + return new XmlFileParser(getLog(), + encoding, + oldParser, + showTouchedFiles, + rules, + xpath, + builder, + namespaces, + isVerbose()) { + @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; + } + }; + } + + protected EntityResolver getEntityResolver() { + + return new EntityResolver() { + + public static final String XWORK_PUBLIC_ID = + "-//Apache Struts//XWork Validator 1.0.3//EN"; + + boolean useLocal = useLocalResolver; + + @Override + public InputSource resolveEntity(String publicId, + String systemId) throws 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; + } + }; + } +} Deleted: trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserXmlUserMojo.java =================================================================== --- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserXmlUserMojo.java 2012-05-30 14:03:24 UTC (rev 1957) +++ trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserXmlUserMojo.java 2012-07-09 13:12:35 UTC (rev 1961) @@ -1,149 +0,0 @@ -/* - * #%L - * I18n :: Maven Plugin - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2007 - 2010 CodeLutin, Tony Chemit - * %% - * 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>. - * #L% - */ -package org.nuiton.i18n.plugin.parser.impl; - -import org.nuiton.i18n.plugin.parser.I18nSourceEntry; -import org.nuiton.i18n.plugin.parser.SourceEntry; -import org.nuiton.io.FileUpdater; -import org.nuiton.io.MirroredFileUpdater; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.xpath.XPath; -import java.io.File; - -/** - * To obtain i18n keys from xml files using the {@code userRulesFiles} (and - * an optional {@code coreRuleFile} if any serves your purpose). - * <p/> - * <b>Note: </b> this goal must always be invoked before the - * {@code process-resources} phase, otherwise all files will be considered as - * uptodate. - * - * @author tchemit <chemit@codelutin.com> - * @goal parserXml - * @phase generate-resources - * @since 2.0 - */ -public class ParserXmlUserMojo extends AbstractParserXmlMojo { - - /** - * Default directory where to look for files. - * - * @parameter expression="${i18n.xmlBasedir}" default-value="${basedir}/src/main/resources" - * @required - * @since 2.0 - */ - protected File basedir; - - /** - * Defines files to parse. - * - * @parameter expression="${i18n.xmlIncludes}" - * @required - * @since 2.0 - */ - protected String includes; - - /** - * Defines an optional files which contain xpath rules to obtain i18n - * keys in xml files and is defined in plugin. - * - * @parameter expression="${i18n.coreRuleFiles}" - * @since 2.0 - */ - protected String coreRuleFile; - - /** - * Defines the file name of the getter where to put detected i18n keys while getter phase. - * - * @parameter expression="${i18n.outputGetter}" default-value="xmlUser.getter" - * @since 2.0 - */ - protected String outputGetter; - - @Override - public String[] getDefaultIncludes() { - return new String[]{includes}; - } - - @Override - public String[] getDefaultExcludes() { - return I18nSourceEntry.EMPTY_STRING_ARRAY; - } - - @Override - public File getDefaultBasedir() { - return basedir; - } - - @Override - protected String getCoreRuleFile() { - return coreRuleFile; - } - - @Override - protected XmlFileParser newXmlFileParser(XPath xpath, DocumentBuilder builder) { - XmlFileParser fileParser = new XmlFileParser(getLog(), - encoding, - oldParser, - showTouchedFiles, - rules, - xpath, - builder, - namespaces, - isVerbose()) { - @Override - public String extract(String i18nString) { - String s = null; - if (!i18nString.trim().isEmpty()) { - s = i18nString.trim(); - } - if (getLog().isDebugEnabled()) { - getLog().debug(i18nString + " = " + s); - } - return s; - } - }; - return fileParser; - } - - @Override - protected String getOutGetter() { - return outputGetter; - } - - @Override - public FileUpdater newFileUpdater(SourceEntry entry) { - return new MirroredFileUpdater("", "", entry.getBasedir(), cp) { - - @Override - public File getMirrorFile(File f) { - String file = - f.getAbsolutePath().substring(prefixSourceDirecotory); - return new File(destinationDirectory + File.separator + file); - } - }; - } -} \ No newline at end of file Copied: trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserXmlUserMojo.java (from rev 1958, trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserXmlUserMojo.java) =================================================================== --- trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserXmlUserMojo.java (rev 0) +++ trunk/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserXmlUserMojo.java 2012-07-09 13:12:35 UTC (rev 1961) @@ -0,0 +1,149 @@ +/* + * #%L + * I18n :: Maven Plugin + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2007 - 2010 CodeLutin, Tony Chemit + * %% + * 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>. + * #L% + */ +package org.nuiton.i18n.plugin.parser.impl; + +import org.apache.maven.plugins.annotations.LifecyclePhase; +import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.plugins.annotations.Parameter; +import org.nuiton.i18n.plugin.parser.I18nSourceEntry; +import org.nuiton.i18n.plugin.parser.SourceEntry; +import org.nuiton.io.FileUpdater; +import org.nuiton.io.MirroredFileUpdater; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.xpath.XPath; +import java.io.File; + +/** + * To obtain i18n keys from xml files using the {@code userRulesFiles} (and + * an optional {@code coreRuleFile} if any serves your purpose). + * <p/> + * <b>Note: </b> this goal must always be invoked before the + * {@code process-resources} phase, otherwise all files will be considered as + * uptodate. + * + * @author tchemit <chemit@codelutin.com> + * @since 2.0 + */ +@Mojo(name = "parserXml", defaultPhase = LifecyclePhase.GENERATE_RESOURCES) +public class ParserXmlUserMojo extends AbstractParserXmlMojo { + + /** + * Default directory where to look for files. + * + * @since 2.0 + */ + @Parameter(property = "i18n.xmlBasedir", defaultValue = "${basedir}/src/main/resources", required = true) + protected File basedir; + + /** + * Defines files to parse. + * + * @since 2.0 + */ + @Parameter(property = "i18n.xmlIncludes", required = true) + protected String includes; + + /** + * Defines an optional files which contain xpath rules to obtain i18n + * keys in xml files and is defined in plugin. + * + * @since 2.0 + */ + @Parameter(property = "i18n.coreRuleFiles") + protected String coreRuleFile; + + /** + * Defines the file name of the getter where to put detected i18n keys while getter phase. + * + * @since 2.0 + */ + @Parameter(property = "i18n.outputGetter", defaultValue = "xmlUser.getter", required = true) + protected String outputGetter; + + @Override + public String[] getDefaultIncludes() { + return new String[]{includes}; + } + + @Override + public String[] getDefaultExcludes() { + return I18nSourceEntry.EMPTY_STRING_ARRAY; + } + + @Override + public File getDefaultBasedir() { + return basedir; + } + + @Override + protected String getCoreRuleFile() { + return coreRuleFile; + } + + @Override + protected XmlFileParser newXmlFileParser(XPath xpath, DocumentBuilder builder) { + XmlFileParser fileParser = new XmlFileParser(getLog(), + encoding, + oldParser, + showTouchedFiles, + rules, + xpath, + builder, + namespaces, + isVerbose()) { + @Override + public String extract(String i18nString) { + String s = null; + if (!i18nString.trim().isEmpty()) { + s = i18nString.trim(); + } + if (getLog().isDebugEnabled()) { + getLog().debug(i18nString + " = " + s); + } + return s; + } + }; + return fileParser; + } + + @Override + protected String getOutGetter() { + return outputGetter; + } + + @Override + public FileUpdater newFileUpdater(SourceEntry entry) { + return new MirroredFileUpdater("", "", entry.getBasedir(), cp) { + + @Override + public File getMirrorFile(File f) { + String file = + f.getAbsolutePath().substring(prefixSourceDirecotory); + return new File(destinationDirectory + File.separator + file); + } + }; + } +} \ No newline at end of file Copied: trunk/i18n-maven-plugin/src/main/resources/xwork-validator-1.0.3.dtd (from rev 1960, trunk/maven-i18n-plugin/src/main/resources/xwork-validator-1.0.3.dtd) =================================================================== --- trunk/i18n-maven-plugin/src/main/resources/xwork-validator-1.0.3.dtd (rev 0) +++ trunk/i18n-maven-plugin/src/main/resources/xwork-validator-1.0.3.dtd 2012-07-09 13:12:35 UTC (rev 1961) @@ -0,0 +1,42 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- + XWork Validators DTD. + Used the following DOCTYPE. + + <!DOCTYPE validators PUBLIC + "-//Apache Struts//XWork Validator 1.0.3//EN" + "http://struts.apache.org/dtds/xwork-validator-1.0.3.dtd"> +--> + + +<!ELEMENT validators (field|validator)+> + +<!ELEMENT field (field-validator+)> +<!ATTLIST field + name CDATA #REQUIRED +> + +<!ELEMENT field-validator (param*, message)> +<!ATTLIST field-validator + type CDATA #REQUIRED + short-circuit (true|false) "false" +> + +<!ELEMENT validator (param*, message)> +<!ATTLIST validator + type CDATA #REQUIRED + short-circuit (true|false) "false" +> + +<!ELEMENT param (#PCDATA)> +<!ATTLIST param + name CDATA #REQUIRED +> + +<!ELEMENT message (#PCDATA|param)*> +<!ATTLIST message + key CDATA #IMPLIED +> + + Modified: trunk/i18n-maven-plugin/src/site/apt/usages.apt =================================================================== --- trunk/maven-i18n-plugin/src/site/apt/usages.apt 2012-05-30 14:03:24 UTC (rev 1957) +++ trunk/i18n-maven-plugin/src/site/apt/usages.apt 2012-07-09 13:12:35 UTC (rev 1961) @@ -83,7 +83,7 @@ ----------------------------------------------------------------------------- <plugin> <groupId>org.nuiton.i18n</groupId> - <artifactId>maven-i18n-plugin</artifactId> + <artifactId>i18n-maven-plugin</artifactId> <executions> <execution> <goals> @@ -103,7 +103,7 @@ ----------------------------------------------------------------------------- <plugin> <groupId>org.nuiton.i18n</groupId> - <artifactId>maven-i18n-plugin</artifactId> + <artifactId>i18n-maven-plugin</artifactId> <configuration> <entries> <entry> @@ -132,7 +132,7 @@ ----------------------------------------------------------------------------- <plugin> <groupId>org.nuiton.i18n</groupId> - <artifactId>maven-i18n-plugin</artifactId> + <artifactId>i18n-maven-plugin</artifactId> <configuration> <treateDefaultEntry>true</treateDefaultEntry> <entries> @@ -176,7 +176,7 @@ ----------------------------------------------------------------------------- <plugin> <groupId>org.nuiton.i18n</groupId> - <artifactId>maven-i18n-plugin</artifactId> + <artifactId>i18n-maven-plugin</artifactId> <executions> <execution> <goals> @@ -201,7 +201,7 @@ ----------------------------------------------------------------------------- <plugin> <groupId>org.nuiton.i18n</groupId> - <artifactId>maven-i18n-plugin</artifactId> + <artifactId>i18n-maven-plugin</artifactId> <executions> <execution> <goals> @@ -218,7 +218,7 @@ ----------------------------------------------------------------------------- <plugin> <groupId>org.nuiton.i18n</groupId> - <artifactId>maven-i18n-plugin</artifactId> + <artifactId>i18n-maven-plugin</artifactId> <executions> <execution> <goals> Modified: trunk/i18n-maven-plugin/src/site/en/apt/usages.apt =================================================================== --- trunk/maven-i18n-plugin/src/site/en/apt/usages.apt 2012-05-30 14:03:24 UTC (rev 1957) +++ trunk/i18n-maven-plugin/src/site/en/apt/usages.apt 2012-07-09 13:12:35 UTC (rev 1961) @@ -83,7 +83,7 @@ ----------------------------------------------------------------------------- <plugin> <groupId>org.nuiton.i18n</groupId> - <artifactId>maven-i18n-plugin</artifactId> + <artifactId>i18n-maven-plugin</artifactId> <executions> <execution> <goals> @@ -103,7 +103,7 @@ ----------------------------------------------------------------------------- <plugin> <groupId>org.nuiton.i18n</groupId> - <artifactId>maven-i18n-plugin</artifactId> + <artifactId>i18n-maven-plugin</artifactId> <configuration> <entries> <entry> @@ -132,7 +132,7 @@ ----------------------------------------------------------------------------- <plugin> <groupId>org.nuiton.i18n</groupId> - <artifactId>maven-i18n-plugin</artifactId> + <artifactId>i18n-maven-plugin</artifactId> <configuration> <treateDefaultEntry>true</treateDefaultEntry> <entries> @@ -176,7 +176,7 @@ ----------------------------------------------------------------------------- <plugin> <groupId>org.nuiton.i18n</groupId> - <artifactId>maven-i18n-plugin</artifactId> + <artifactId>i18n-maven-plugin</artifactId> <executions> <execution> <goals> @@ -201,7 +201,7 @@ ----------------------------------------------------------------------------- <plugin> <groupId>org.nuiton.i18n</groupId> - <artifactId>maven-i18n-plugin</artifactId> + <artifactId>i18n-maven-plugin</artifactId> <executions> <execution> <goals> @@ -218,7 +218,7 @@ ----------------------------------------------------------------------------- <plugin> <groupId>org.nuiton.i18n</groupId> - <artifactId>maven-i18n-plugin</artifactId> + <artifactId>i18n-maven-plugin</artifactId> <executions> <execution> <goals> Deleted: trunk/i18n-maven-plugin/src/site/site_en.xml =================================================================== --- trunk/maven-i18n-plugin/src/site/site_en.xml 2012-05-30 14:03:24 UTC (rev 1957) +++ trunk/i18n-maven-plugin/src/site/site_en.xml 2012-07-09 13:12:35 UTC (rev 1961) @@ -1,136 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - #%L - I18n :: Maven Plugin - - $Id$ - $HeadURL$ - %% - Copyright (C) 2007 - 2010 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>. - #L% - --> - -<project name="${project.name}"> - - <bannerLeft> - <name>${project.name}</name> - <href>index.html</href> - </bannerLeft> - - <bannerRight> - <src>http://www.codelutin.com/images/lutinorange-codelutin.png</src> - <href>http://www.codelutin.com</href> - </bannerRight> - - <skin> - <groupId>org.apache.maven.skins</groupId> - <artifactId>maven-fluido-skin</artifactId> - <version>1.2.1</version> - </skin> - - <custom> - <fluidoSkin> - <topBarEnabled>true</topBarEnabled> - <googleSearch/> - <sideBarEnabled>false</sideBarEnabled> - <searchEnabled>true</searchEnabled> - <sourceLineNumbersEnabled>true</sourceLineNumbersEnabled> - </fluidoSkin> - </custom> - - <publishDate position="right" format="dd/MM/yyyy"/> - <version position="right"/> - - <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="index.html"/> - </breadcrumbs> - - <links> - <item name="[fr" href="../index.html"/> - <item name="en]" href="index.html"/> - </links> - - <menu name="Project Parent"> - <item name="I18n" href="../../en/index.html"/> - </menu> - - <menu name="User"> - <item name="Home" href="index.html"/> - <item name="Usages" href="usages.html"/> - <item name="Parser Goals" href="plugin-info.html"> - <item name="parserJava" href="parserJava-mojo.html"/> - <item name="parserXml" href="parserXml-mojo.html"/> - <item name="parserJsp" href="parserJsp-mojo.html"/> - <item name="parserGWTJava" href="parserGWTJava-mojo.html"/> - <item name="parserTapestry" href="parserTapestry-mojo.html"/> - <item name="parserValidation" href="parserValidation-mojo.html"/> - <item name="get" href="get-mojo.html"/> - <item name="gen" href="gen-mojo.html"/> - </item> - <item name="Bundle Goals" href="plugin-info.html"> - <item name="collect-i18n-artifacts" - href="collect-i18n-artifacts-mojo.html"/> - <item name="bundle" href="bundle-mojo.html"/> - <item name="tapestry-bundle" href="tapestry-bundle-mojo.html"/> - </item> - <item name="Other Goals" href="plugin-info.html"> - <item name="help" href="help-mojo.html"/> - </item> - </menu> - - <menu name="Downloads"> - <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"/> - - <footer> - - <script type="text/javascript" - src="http://maven-site.nuiton.org/public/js/maven-site-nuiton.org.js"> - </script> - - <div id='projectMetas' - projectversion='${project.version}' - platform='${project.platform}' - projectid='${project.projectId}' - scm='${project.scm.connection}' - scmwebeditorenabled='${project.scmwebeditorEnabled}' - scmwebeditorurl='${project.scmwebeditorUrl}' - siteSourcesType='${project.siteSourcesType}' - piwikEnabled='${project.piwikEnabled}' - piwikId='${project.piwikId}'> - </div> - </footer> - - </body> -</project> Copied: trunk/i18n-maven-plugin/src/site/site_en.xml (from rev 1958, trunk/maven-i18n-plugin/src/site/site_en.xml) =================================================================== --- trunk/i18n-maven-plugin/src/site/site_en.xml (rev 0) +++ trunk/i18n-maven-plugin/src/site/site_en.xml 2012-07-09 13:12:35 UTC (rev 1961) @@ -0,0 +1,136 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + #%L + I18n :: Maven Plugin + + $Id$ + $HeadURL$ + %% + Copyright (C) 2007 - 2010 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>. + #L% + --> + +<project name="${project.name}"> + + <bannerLeft> + <name>${project.name}</name> + <href>index.html</href> + </bannerLeft> + + <bannerRight> + <src>http://www.codelutin.com/images/lutinorange-codelutin.png</src> + <href>http://www.codelutin.com</href> + </bannerRight> + + <skin> + <groupId>org.apache.maven.skins</groupId> + <artifactId>maven-fluido-skin</artifactId> + <version>1.2.1</version> + </skin> + + <custom> + <fluidoSkin> + <topBarEnabled>true</topBarEnabled> + <googleSearch/> + <sideBarEnabled>false</sideBarEnabled> + <searchEnabled>true</searchEnabled> + <sourceLineNumbersEnabled>true</sourceLineNumbersEnabled> + </fluidoSkin> + </custom> + + <publishDate position="right" format="dd/MM/yyyy"/> + <version position="right"/> + + <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="index.html"/> + </breadcrumbs> + + <links> + <item name="[fr" href="../index.html"/> + <item name="en]" href="index.html"/> + </links> + + <menu name="Project Parent"> + <item name="I18n" href="../../en/index.html"/> + </menu> + + <menu name="User"> + <item name="Home" href="index.html"/> + <item name="Usages" href="usages.html"/> + <item name="Parser Goals" href="plugin-info.html"> + <item name="parserJava" href="parserJava-mojo.html"/> + <item name="parserXml" href="parserXml-mojo.html"/> + <item name="parserJsp" href="parserJsp-mojo.html"/> + <item name="parserGWTJava" href="parserGWTJava-mojo.html"/> + <item name="parserTapestry" href="parserTapestry-mojo.html"/> + <item name="parserValidation" href="parserValidation-mojo.html"/> + <item name="get" href="get-mojo.html"/> + <item name="gen" href="gen-mojo.html"/> + </item> + <item name="Bundle Goals" href="plugin-info.html"> + <item name="collect-i18n-artifacts" + href="collect-i18n-artifacts-mojo.html"/> + <item name="bundle" href="bundle-mojo.html"/> + <item name="tapestry-bundle" href="tapestry-bundle-mojo.html"/> + </item> + <item name="Other Goals" href="plugin-info.html"> + <item name="help" href="help-mojo.html"/> + </item> + </menu> + + <menu name="Downloads"> + <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"/> + + <footer> + + <script type="text/javascript" + src="http://maven-site.nuiton.org/public/js/maven-site-nuiton.org.js"> + </script> + + <div id='projectMetas' + projectversion='${project.version}' + platform='${project.platform}' + projectid='${project.projectId}' + scm='${project.scm.developerConnection}' + scmwebeditorenabled='${project.scmwebeditorEnabled}' + scmwebeditorurl='${project.scmwebeditorUrl}' + siteSourcesType='${project.siteSourcesType}' + piwikEnabled='${project.piwikEnabled}' + piwikId='${project.piwikId}'> + </div> + </footer> + + </body> +</project> Deleted: trunk/i18n-maven-plugin/src/site/site_fr.xml =================================================================== --- trunk/maven-i18n-plugin/src/site/site_fr.xml 2012-05-30 14:03:24 UTC (rev 1957) +++ trunk/i18n-maven-plugin/src/site/site_fr.xml 2012-07-09 13:12:35 UTC (rev 1961) @@ -1,134 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - #%L - I18n :: Maven Plugin - - $Id$ - $HeadURL$ - %% - Copyright (C) 2007 - 2010 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>. - #L% - --> - -<project name="${project.name}"> - - <bannerLeft> - <name>${project.name}</name> - <href>index.html</href> - </bannerLeft> - - <bannerRight> - <src>http://www.codelutin.com/images/lutinorange-codelutin.png</src> - <href>http://www.codelutin.com</href> - </bannerRight> - - <skin> - <groupId>org.apache.maven.skins</groupId> - <artifactId>maven-fluido-skin</artifactId> - <version>1.2.1</version> - </skin> - - <custom> - <fluidoSkin> - <topBarEnabled>true</topBarEnabled> - <googleSearch/> - <sideBarEnabled>false</sideBarEnabled> - <searchEnabled>true</searchEnabled> - <sourceLineNumbersEnabled>true</sourceLineNumbersEnabled> - </fluidoSkin> - </custom> - - <publishDate position="right" format="dd/MM/yyyy"/> - <version position="right"/> - - <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="index.html"/> - </breadcrumbs> - - <links> - <item name="[fr" href="index.html"/> - <item name="en]" href="en/index.html"/> - </links> - - <menu ref="parent"/> - - <menu name="Utilisateur"> - <item name="Introduction" href="index.html"/> - <item name="Usages" href="usages.html"/> - <item name="Parser Goals" href="plugin-info.html"> - <item name="parserJava" href="parserJava-mojo.html"/> - <item name="parserXml" href="parserXml-mojo.html"/> - <item name="parserJsp" href="parserJsp-mojo.html"/> - <item name="parserTapestry" href="parserTapestry-mojo.html"/> - <item name="parserGWTJava" href="parserGWTJava-mojo.html"/> - <item name="parserValidation" href="parserValidation-mojo.html"/> - <item name="get" href="get-mojo.html"/> - <item name="gen" href="gen-mojo.html"/> - </item> - <item name="Bundle Goals" href="plugin-info.html"> - <item name="collect-i18n-artifacts" - href="collect-i18n-artifacts-mojo.html"/> - <item name="bundle" href="bundle-mojo.html"/> - <item name="tapestry-bundle" href="tapestry-bundle-mojo.html"/> - </item> - <item name="Other Goals" href="plugin-info.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"/> - - <footer> - - <script type="text/javascript" - src="http://maven-site.nuiton.org/public/js/maven-site-nuiton.org.js"> - </script> - - <div id='projectMetas' - projectversion='${project.version}' - platform='${project.platform}' - projectid='${project.projectId}' - scm='${project.scm.connection}' - scmwebeditorenabled='${project.scmwebeditorEnabled}' - scmwebeditorurl='${project.scmwebeditorUrl}' - siteSourcesType='${project.siteSourcesType}' - piwikEnabled='${project.piwikEnabled}' - piwikId='${project.piwikId}'> - </div> - </footer> - - </body> -</project> Copied: trunk/i18n-maven-plugin/src/site/site_fr.xml (from rev 1958, trunk/maven-i18n-plugin/src/site/site_fr.xml) =================================================================== --- trunk/i18n-maven-plugin/src/site/site_fr.xml (rev 0) +++ trunk/i18n-maven-plugin/src/site/site_fr.xml 2012-07-09 13:12:35 UTC (rev 1961) @@ -0,0 +1,134 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + #%L + I18n :: Maven Plugin + + $Id$ + $HeadURL$ + %% + Copyright (C) 2007 - 2010 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>. + #L% + --> + +<project name="${project.name}"> + + <bannerLeft> + <name>${project.name}</name> + <href>index.html</href> + </bannerLeft> + + <bannerRight> + <src>http://www.codelutin.com/images/lutinorange-codelutin.png</src> + <href>http://www.codelutin.com</href> + </bannerRight> + + <skin> + <groupId>org.apache.maven.skins</groupId> + <artifactId>maven-fluido-skin</artifactId> + <version>1.2.1</version> + </skin> + + <custom> + <fluidoSkin> + <topBarEnabled>true</topBarEnabled> + <googleSearch/> + <sideBarEnabled>false</sideBarEnabled> + <searchEnabled>true</searchEnabled> + <sourceLineNumbersEnabled>true</sourceLineNumbersEnabled> + </fluidoSkin> + </custom> + + <publishDate position="right" format="dd/MM/yyyy"/> + <version position="right"/> + + <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="index.html"/> + </breadcrumbs> + + <links> + <item name="[fr" href="index.html"/> + <item name="en]" href="en/index.html"/> + </links> + + <menu ref="parent"/> + + <menu name="Utilisateur"> + <item name="Introduction" href="index.html"/> + <item name="Usages" href="usages.html"/> + <item name="Parser Goals" href="plugin-info.html"> + <item name="parserJava" href="parserJava-mojo.html"/> + <item name="parserXml" href="parserXml-mojo.html"/> + <item name="parserJsp" href="parserJsp-mojo.html"/> + <item name="parserTapestry" href="parserTapestry-mojo.html"/> + <item name="parserGWTJava" href="parserGWTJava-mojo.html"/> + <item name="parserValidation" href="parserValidation-mojo.html"/> + <item name="get" href="get-mojo.html"/> + <item name="gen" href="gen-mojo.html"/> + </item> + <item name="Bundle Goals" href="plugin-info.html"> + <item name="collect-i18n-artifacts" + href="collect-i18n-artifacts-mojo.html"/> + <item name="bundle" href="bundle-mojo.html"/> + <item name="tapestry-bundle" href="tapestry-bundle-mojo.html"/> + </item> + <item name="Other Goals" href="plugin-info.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"/> + + <footer> + + <script type="text/javascript" + src="http://maven-site.nuiton.org/public/js/maven-site-nuiton.org.js"> + </script> + + <div id='projectMetas' + projectversion='${project.version}' + platform='${project.platform}' + projectid='${project.projectId}' + scm='${project.scm.developerConnection}' + scmwebeditorenabled='${project.scmwebeditorEnabled}' + scmwebeditorurl='${project.scmwebeditorUrl}' + siteSourcesType='${project.siteSourcesType}' + piwikEnabled='${project.piwikEnabled}' + piwikId='${project.piwikId}'> + </div> + </footer> + + </body> +</project> Copied: trunk/i18n-maven-plugin/src/test/java/org/nuiton/i18n/plugin/parser/SourceEntryTest.java (from rev 1960, trunk/maven-i18n-plugin/src/test/java/org/nuiton/i18n/plugin/parser/SourceEntryTest.java) =================================================================== --- trunk/i18n-maven-plugin/src/test/java/org/nuiton/i18n/plugin/parser/SourceEntryTest.java (rev 0) +++ trunk/i18n-maven-plugin/src/test/java/org/nuiton/i18n/plugin/parser/SourceEntryTest.java 2012-07-09 13:12:35 UTC (rev 1961) @@ -0,0 +1,43 @@ +package org.nuiton.i18n.plugin.parser; + +import org.junit.Assert; +import org.junit.Test; +import org.nuiton.i18n.plugin.parser.impl.ParserJavaMojo; +import org.nuiton.i18n.plugin.parser.impl.ParserValidationMojo; + +import java.io.File; + +/** + * Tests the {@link SourceEntry}. + * + * @author tchemit <chemit@codelutin.com> + * @since 2.4.3 + */ +public class SourceEntryTest { + + @Test + public void testGetIncludedFiles() throws Exception { + SourceEntry entry = new SourceEntry(); + File basedir = new File("."); + + File defaultBasedir = new File(basedir, "src" + File.separator + "test" + File.separator + "java"); + File defaultBasedir2 = new File(basedir, "src" + File.separator + "test" + File.separator + "resources"); + + String[] includedFiles; + + includedFiles = entry.getIncludedFiles(defaultBasedir, + new String[]{ParserJavaMojo.DEFAULT_INCLUDES}, + I18nSourceEntry.EMPTY_STRING_ARRAY); + Assert.assertNotNull(includedFiles); + Assert.assertTrue(includedFiles.length > 0); + + + includedFiles = entry.getIncludedFiles(defaultBasedir2, + new String[]{ParserValidationMojo.DEFAULT_INCLUDES}, + I18nSourceEntry.EMPTY_STRING_ARRAY); + Assert.assertNotNull(includedFiles); + Assert.assertTrue(includedFiles.length > 0); + + + } +} Modified: trunk/src/site/apt/gwt.apt =================================================================== --- trunk/src/site/apt/gwt.apt 2012-07-09 12:53:13 UTC (rev 1960) +++ trunk/src/site/apt/gwt.apt 2012-07-09 13:12:35 UTC (rev 1961) @@ -147,7 +147,7 @@ -------------------------------------------------------------------------------- <plugin> <groupId>org.nuiton.i18n</groupId> - <artifactId>maven-i18n-plugin</artifactId> + <artifactId>i18n-maven-plugin</artifactId> <executions> <execution> <id>scan-gwt-sources</id> Modified: trunk/src/site/apt/index.apt =================================================================== --- trunk/src/site/apt/index.apt 2012-07-09 12:53:13 UTC (rev 1960) +++ trunk/src/site/apt/index.apt 2012-07-09 13:12:35 UTC (rev 1961) @@ -50,7 +50,15 @@ - {{{./ant-i18n-task/index.html}I18n Ant task}} (ce module a été désactivé depuis la version 2.0) +Quoi de neuf dans la version 2.5 +* Renommage du plugin en i18n-maven-plugin. + + Le plugin a été renommé de <maven-i18n-plugin> en <i18n-maven-plugin>. + + Pensez à mettre à jour vos pom. + + Quoi de neuf dans la version 2.4 * Meilleure utilisation des encodings Modified: trunk/src/site/apt/library.apt.vm =================================================================== --- trunk/src/site/apt/library.apt.vm 2012-07-09 12:53:13 UTC (rev 1960) +++ trunk/src/site/apt/library.apt.vm 2012-07-09 13:12:35 UTC (rev 1961) @@ -47,7 +47,7 @@ ------------------------------------------------------------------------------- <plugin> <groupId>org.nuiton.i18n</groupId> - <artifactId>maven-i18n-plugin</artifactId> + <artifactId>i18n-maven-plugin</artifactId> <version>${projet.version}</version> <executions> <execution> Modified: trunk/src/site/en/apt/gwt.apt =================================================================== --- trunk/src/site/en/apt/gwt.apt 2012-07-09 12:53:13 UTC (rev 1960) +++ trunk/src/site/en/apt/gwt.apt 2012-07-09 13:12:35 UTC (rev 1961) @@ -135,7 +135,7 @@ -------------------------------------------------------------------------------- <plugin> <groupId>org.nuiton.i18n</groupId> - <artifactId>maven-i18n-plugin</artifactId> + <artifactId>i18n-maven-plugin</artifactId> <executions> <execution> <id>scan-gwt-sources</id> Modified: trunk/src/site/en/apt/index.apt =================================================================== --- trunk/src/site/en/apt/index.apt 2012-07-09 12:53:13 UTC (rev 1960) +++ trunk/src/site/en/apt/index.apt 2012-07-09 13:12:35 UTC (rev 1961) @@ -85,6 +85,14 @@ another one, using a different syntax from the one used by translations will not work properly. +What's new in 2.5 version + +* Plugin module renamed to i18n-maven-plugin. + + the i18n maven plugin was renamed from <maven-i18n-plugin> to <i18n-maven-plugin>. + + Think to update your poms. + What's new in 2.3 version Version 2.3 improves a lot performance on detection of java file i18n keys Modified: trunk/src/site/en/apt/library.apt.vm =================================================================== --- trunk/src/site/en/apt/library.apt.vm 2012-07-09 12:53:13 UTC (rev 1960) +++ trunk/src/site/en/apt/library.apt.vm 2012-07-09 13:12:35 UTC (rev 1961) @@ -45,7 +45,7 @@ ------------------------------------------------------------------------------- <plugin> <groupId>org.nuiton.i18n</groupId> - <artifactId>maven-i18n-plugin</artifactId> + <artifactId>i18n-maven-plugin</artifactId> <version>${project.version}</version> <executions> <execution>