Author: tchemit Date: 2009-05-14 05:19:42 +0000 (Thu, 14 May 2009) New Revision: 1545 Removed: maven-i18n-plugin/trunk/src/main/java/org/nuiton/i18n/plugin/PluginHelper.java maven-i18n-plugin/trunk/src/site/rst/Todo.rst Modified: maven-i18n-plugin/trunk/pom.xml maven-i18n-plugin/trunk/src/main/java/org/nuiton/i18n/plugin/AbstractI18nPlugin.java maven-i18n-plugin/trunk/src/main/java/org/nuiton/i18n/plugin/Bundle.java maven-i18n-plugin/trunk/src/main/java/org/nuiton/i18n/plugin/Generate.java maven-i18n-plugin/trunk/src/main/java/org/nuiton/i18n/plugin/Getter.java maven-i18n-plugin/trunk/src/main/java/org/nuiton/i18n/plugin/I18nLogger.java maven-i18n-plugin/trunk/src/main/java/org/nuiton/i18n/plugin/parser/AbstractI18nParser.java maven-i18n-plugin/trunk/src/site/site.xml Log: utilisation nuiton-i18n-api Modified: maven-i18n-plugin/trunk/pom.xml =================================================================== --- maven-i18n-plugin/trunk/pom.xml 2009-05-14 05:19:13 UTC (rev 1544) +++ maven-i18n-plugin/trunk/pom.xml 2009-05-14 05:19:42 UTC (rev 1545) @@ -24,6 +24,13 @@ <dependency> <groupId>org.nuiton</groupId> + <artifactId>nuiton-i18n-api</artifactId> + <version>1.0.0-SNAPSHOT</version> + <scope>compile</scope> + </dependency> + + <dependency> + <groupId>org.nuiton</groupId> <artifactId>nuitonprocessor</artifactId> <version>${processor.version}</version> <scope>compile</scope> @@ -36,6 +43,28 @@ <scope>compile</scope> </dependency> + <dependency> + <groupId>xalan</groupId> + <artifactId>xalan</artifactId> + <version>2.7.1</version> + <scope>compile</scope> + </dependency> + + <dependency> + <groupId>commons-collections</groupId> + <artifactId>commons-collections</artifactId> + <version>3.1</version> + <scope>compile</scope> + </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> + <version>1.5.5</version> + <scope>compile</scope> + </dependency> + <!-- tests dependencies --> <dependency> @@ -53,27 +82,13 @@ <scope>test</scope> </dependency> - <dependency> + <!--dependency> <groupId>org.apache.maven.shared</groupId> <artifactId>maven-dependency-tree</artifactId> <version>1.2</version> </dependency> <dependency> - <groupId>xalan</groupId> - <artifactId>xalan</artifactId> - <version>2.7.0</version> - <scope>compile</scope> - </dependency> - - <dependency> - <groupId>commons-collections</groupId> - <artifactId>commons-collections</artifactId> - <version>3.1</version> - <scope>compile</scope> - </dependency> - - <dependency> <groupId>org.apache.maven</groupId> <artifactId>maven-plugin-api</artifactId> <version>${maven.version}</version> @@ -85,24 +100,17 @@ <artifactId>maven-project</artifactId> <version>${maven.version}</version> <scope>provided</scope> - </dependency> + </dependency--> - <dependency> - <groupId>org.codelutin</groupId> - <artifactId>lutinutil</artifactId> - <version>${lutinutil.version}</version> - <scope>provided</scope> - </dependency> - </dependencies> <!-- ************************************************************* --> <!-- *** Project Information ************************************* --> <!-- ************************************************************* --> - <name>Plugin maven pour lutini18n</name> + <name>Plugin maven pour i18n</name> <description> - Plugin pour maven 2 pour la génération des bundles pour l'internationnalisation des applications java fait par - lutinutil-i18n + Plugin pour maven 2 de génération des bundles pour l'internationnalisation (i18n) des applications java + basé sur nuiton-i18n-api. </description> <inceptionYear>2007</inceptionYear> @@ -126,7 +134,6 @@ <helper.licenseName>lgpl_v3</helper.licenseName> <site.home.url>http://lutinutil.labs.libre-entreprise.org</site.home.url> <repository.home.url>http://lutinbuilder.labs.libre-entreprise.org/maven2</repository.home.url> - <lutinutil.version>1.0.6</lutinutil.version> </properties> <build> Modified: maven-i18n-plugin/trunk/src/main/java/org/nuiton/i18n/plugin/AbstractI18nPlugin.java =================================================================== --- maven-i18n-plugin/trunk/src/main/java/org/nuiton/i18n/plugin/AbstractI18nPlugin.java 2009-05-14 05:19:13 UTC (rev 1544) +++ maven-i18n-plugin/trunk/src/main/java/org/nuiton/i18n/plugin/AbstractI18nPlugin.java 2009-05-14 05:19:42 UTC (rev 1545) @@ -19,12 +19,13 @@ import org.apache.maven.plugin.AbstractMojo; import org.nuiton.i18n.plugin.parser.ParserEvent; +import org.codelutin.i18n.I18nUtil; import java.io.File; +import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.Locale; -import org.codelutin.i18n.I18n; /** * Classe permettant d'obenir les parametres pendant les différentes phases @@ -151,11 +152,7 @@ if (verbose) { getLog().info("config - verbose mode is on"); } - locales = I18n.parseLocales(bundles); -// bundlesToUse = bundles.split(","); -// for (int i = 0, j = bundlesToUse.length; i < j; i++) { -// bundlesToUse[i] = bundlesToUse[i].trim(); -// } + locales = I18nUtil.parseLocales(bundles); } public String getArtifactId() { @@ -185,4 +182,60 @@ protected I18nLogger getVerboseLog() { return verboseLog; } + + /** + * @param root le repertoire ou sont stockes les fichiers i18n + * @param artifactId le nom de l'artifact + * @param locale le nom du bundle + * @param create <code>true</code> pour creer le fichier si non present + * @return le fichier i18n + * @throws java.io.IOException si probleme lors de la creation du fichier + */ + public File getI18nFile(File root, String artifactId, Locale locale, boolean create) throws IOException { + File file = new File(root.getAbsolutePath() + File.separatorChar + artifactId + "-" + locale.toString() + ".properties"); + if (create && !file.exists()) { + if (!file.exists()) { + file.getParentFile().mkdirs(); + } + file.createNewFile(); + } + return file; + } + + /** + * @param root le repertoire ou sont stockes les fichiers getter + * @param getter le nom du getter + * @param create <code>true</code> pour creer le fichier si non present + * @return le fichier i18n + * @throws java.io.IOException si probleme lors de la creation du fichier + */ + public File getGetterFile(File root, String getter, boolean create) throws IOException { + File file = new File(root.getAbsolutePath() + File.separatorChar + getter); + if (create && !file.exists()) { + if (!file.exists()) { + file.getParentFile().mkdirs(); + } + file.createNewFile(); + } + return file; + } + + /** + * @param root le repertoire ou sont stockes les fichiers getter + * @param getter le nom du getter + * @return le fichier i18n + */ + public File getGetterFileBackup(File root, String getter) { + return new File(root.getAbsolutePath() + File.separatorChar + getter + '~'); + } + + /** + * @param root le reertoire ou sont stockes les fichiers i18n + * @param artifactId le nom de l'artifact + * @param bundle le nom du bundle + * @return le fichier i18n de backup + */ + public File getI18nFileBackup(File root, String artifactId, Locale bundle) { + return new File(root.getAbsolutePath() + File.separatorChar + artifactId + "-" + bundle.toString() + ".properties~"); + } } Modified: maven-i18n-plugin/trunk/src/main/java/org/nuiton/i18n/plugin/Bundle.java =================================================================== --- maven-i18n-plugin/trunk/src/main/java/org/nuiton/i18n/plugin/Bundle.java 2009-05-14 05:19:13 UTC (rev 1544) +++ maven-i18n-plugin/trunk/src/main/java/org/nuiton/i18n/plugin/Bundle.java 2009-05-14 05:19:42 UTC (rev 1545) @@ -43,10 +43,10 @@ import org.apache.maven.shared.dependency.tree.DependencyTreeBuilder; import org.apache.maven.shared.dependency.tree.DependencyTreeBuilderException; import org.codelutin.i18n.bundle.I18nBundleEntry; +import org.nuiton.util.PluginHelper.SortedProperties; +import org.nuiton.util.DependencyUtil; import org.codelutin.i18n.bundle.I18nBundleFactory; -import org.nuiton.i18n.plugin.PluginHelper.I18nProperties; -import org.nuiton.util.DependencyUtil; -import org.codelutin.util.StringUtil; +import org.nuiton.util.PluginHelper; /** * Créer un bundle pour une application finale. @@ -223,11 +223,11 @@ long t0 = System.nanoTime(); - File bundleOut = PluginHelper.getI18nFile(bundleOutputDir, bundleOutputName, locale, false); + File bundleOut = getI18nFile(bundleOutputDir, bundleOutputName, locale, false); getLog().info("prepare bundle " + bundleOut.getAbsolutePath()); - I18nProperties propertiesOut = new I18nProperties(encoding, false); + SortedProperties propertiesOut = new SortedProperties(encoding, false); for (I18nArtifact artifact : i18nArtifacts) { I18nBundleEntry[] bundleEntries = artifact.getBundleEntries(locale, defaultLocale); @@ -236,13 +236,13 @@ bundleEntry.load(propertiesOut); if (verbose) { - getLog().info("loaded " + bundleEntry.getPath() + " in " + StringUtil.convertTime(t0, System.nanoTime())); + getLog().info("loaded " + bundleEntry.getPath() + " in " + PluginHelper.convertTime(t0, System.nanoTime())); } } } propertiesOut.store(bundleOut); if (verbose) { - getLog().info("bundle created in " + StringUtil.convertTime(t0, System.nanoTime()) + " (detected sentences : " + propertiesOut.size() + ")"); + getLog().info("bundle created in " + PluginHelper.convertTime(t0, System.nanoTime()) + " (detected sentences : " + propertiesOut.size() + ")"); } } @@ -257,7 +257,7 @@ p.store(new FileOutputStream(defOut), null); if (verbose) { - getLog().info("done in " + StringUtil.convertTime(t00, System.nanoTime())); + getLog().info("done in " + PluginHelper.convertTime(t00, System.nanoTime())); } } catch (IOException e) { getLog().error("File Error I/O ", e); Modified: maven-i18n-plugin/trunk/src/main/java/org/nuiton/i18n/plugin/Generate.java =================================================================== --- maven-i18n-plugin/trunk/src/main/java/org/nuiton/i18n/plugin/Generate.java 2009-05-14 05:19:13 UTC (rev 1544) +++ maven-i18n-plugin/trunk/src/main/java/org/nuiton/i18n/plugin/Generate.java 2009-05-14 05:19:42 UTC (rev 1545) @@ -15,12 +15,11 @@ * You should have received a copy of the GNU General Lesser Public * License along with this program. If not, see * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%* */ - package org.nuiton.i18n.plugin; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; -import org.nuiton.i18n.plugin.PluginHelper.I18nProperties; +import org.nuiton.util.PluginHelper.SortedProperties; import org.nuiton.util.FileUtil; import java.io.File; @@ -51,14 +50,14 @@ for (Locale bundle : locales) { try { // Merge - File bundleSrc = PluginHelper.getI18nFile(src, artifactId, bundle, false); - File bundleOut = PluginHelper.getI18nFile(out, artifactId, bundle, false); + File bundleSrc = getI18nFile(src, artifactId, bundle, false); + File bundleOut = getI18nFile(out, artifactId, bundle, false); if (bundleSrc.exists()) { - I18nProperties propertiesSrc = new I18nProperties(encoding).load(bundleSrc); + SortedProperties propertiesSrc = new SortedProperties(encoding).load(bundleSrc); - I18nProperties propertiesOut = new I18nProperties(encoding); + SortedProperties propertiesOut = new SortedProperties(encoding); if (!strictMode) { // push back in bundle out, all the bundle src keys @@ -89,7 +88,7 @@ // Sauvegarde avant copie if (genSrc && keepBackup) { - FileUtil.copy(bundleSrc, PluginHelper.getI18nFileBackup(src, artifactId, bundle)); + FileUtil.copy(bundleSrc, getI18nFileBackup(src, artifactId, bundle)); } getLog().info("merge bundle " + bundleSrc.getAbsolutePath()); @@ -109,5 +108,4 @@ } } } - } Modified: maven-i18n-plugin/trunk/src/main/java/org/nuiton/i18n/plugin/Getter.java =================================================================== --- maven-i18n-plugin/trunk/src/main/java/org/nuiton/i18n/plugin/Getter.java 2009-05-14 05:19:13 UTC (rev 1544) +++ maven-i18n-plugin/trunk/src/main/java/org/nuiton/i18n/plugin/Getter.java 2009-05-14 05:19:42 UTC (rev 1545) @@ -21,12 +21,12 @@ import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.codehaus.plexus.util.DirectoryScanner; -import org.nuiton.i18n.plugin.PluginHelper.I18nProperties; import org.nuiton.util.FileUtil; import java.io.File; import java.io.IOException; import java.util.Locale; +import org.nuiton.util.PluginHelper.SortedProperties; /** * Recupere les différents fichiers des parsers en un fichier de proprietes. @@ -65,7 +65,7 @@ // Fusion des fichiers propriétés des différents parsers for (String file : files) { - File bundleGetter = PluginHelper.getGetterFile(out, file, false); + File bundleGetter = getGetterFile(out, file, false); concactProperties(bundleGetter, bundleGetters); if (genSrc) { bundleGetter.delete(); @@ -75,7 +75,7 @@ // Création des bundles for (Locale bundle : locales) { - File bundleOut = PluginHelper.getI18nFile(out, artifactId, bundle, false); + File bundleOut = getI18nFile(out, artifactId, bundle, false); FileUtil.copy(bundleGetters, bundleOut); if (verbose) { getVerboseLog().infoAction("generate", bundleOut.getAbsolutePath()); @@ -97,9 +97,9 @@ * @throws IOException si problème pendant la sauvegarde ou fichier non trouvé. */ protected void concactProperties(File in, File out) throws IOException { - I18nProperties propertiesIn = new I18nProperties(encoding).load(in); + SortedProperties propertiesIn = new SortedProperties(encoding).load(in); - I18nProperties propertiesOut = new I18nProperties(encoding).load(out); + SortedProperties propertiesOut = new SortedProperties(encoding).load(out); propertiesOut.putAll(propertiesIn); propertiesOut.store(out); } Modified: maven-i18n-plugin/trunk/src/main/java/org/nuiton/i18n/plugin/I18nLogger.java =================================================================== --- maven-i18n-plugin/trunk/src/main/java/org/nuiton/i18n/plugin/I18nLogger.java 2009-05-14 05:19:13 UTC (rev 1544) +++ maven-i18n-plugin/trunk/src/main/java/org/nuiton/i18n/plugin/I18nLogger.java 2009-05-14 05:19:42 UTC (rev 1545) @@ -4,7 +4,7 @@ import java.beans.Introspector; import java.io.File; - +import org.nuiton.util.PluginHelper; /** * Le logger utilisé par les mojo. * Deleted: maven-i18n-plugin/trunk/src/main/java/org/nuiton/i18n/plugin/PluginHelper.java =================================================================== --- maven-i18n-plugin/trunk/src/main/java/org/nuiton/i18n/plugin/PluginHelper.java 2009-05-14 05:19:13 UTC (rev 1544) +++ maven-i18n-plugin/trunk/src/main/java/org/nuiton/i18n/plugin/PluginHelper.java 2009-05-14 05:19:42 UTC (rev 1545) @@ -1,278 +0,0 @@ -/** - * *##% Plugin maven pour lutini18n - * Copyright (C) 2007 - 2008 CodeLutin - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%* - */ -package org.nuiton.i18n.plugin; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.FilterOutputStream; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.OutputStream; -import java.io.OutputStreamWriter; -import java.text.MessageFormat; -import java.util.Collections; -import java.util.Enumeration; -import java.util.List; -import java.util.Locale; -import java.util.Properties; -import java.util.Vector; - -/** - * Une classe pour mutualiser toutes les méthodes utiles dans ce plugin. - * <p/> - * Note : On a dupliqué ici du code de la librairie lutinutil, pour casser la dépendance ver ce projet qui utilise ce plugin - * et donc introduit un cycle dans le graphe des dépendances, ce qui n'est pas souhaitable. - * - * @author chemit - */ -public class PluginHelper { - - /** - * @param root le repertoire ou sont stockes les fichiers i18n - * @param artifactId le nom de l'artifact - * @param locale le nom du bundle - * @param create <code>true</code> pour creer le fichier si non present - * @return le fichier i18n - * @throws java.io.IOException si probleme lors de la creation du fichier - */ - public static File getI18nFile(File root, String artifactId, Locale locale, boolean create) throws IOException { - File file = new File(root.getAbsolutePath() + File.separatorChar + artifactId + "-" + locale.toString() + ".properties"); - if (create && !file.exists()) { - if (!file.exists()) { - file.getParentFile().mkdirs(); - } - file.createNewFile(); - } - return file; - } - - /** - * @param root le repertoire ou sont stockes les fichiers getter - * @param getter le nom du getter - * @param create <code>true</code> pour creer le fichier si non present - * @return le fichier i18n - * @throws java.io.IOException si probleme lors de la creation du fichier - */ - public static File getGetterFile(File root, String getter, boolean create) throws IOException { - File file = new File(root.getAbsolutePath() + File.separatorChar + getter); - if (create && !file.exists()) { - if (!file.exists()) { - file.getParentFile().mkdirs(); - } - file.createNewFile(); - } - return file; - } - - /** - * @param root le repertoire ou sont stockes les fichiers getter - * @param getter le nom du getter - * @return le fichier i18n - */ - public static File getGetterFileBackup(File root, String getter) { - return new File(root.getAbsolutePath() + File.separatorChar + getter + '~'); - } - - /** - * @param root le reertoire ou sont stockes les fichiers i18n - * @param artifactId le nom de l'artifact - * @param bundle le nom du bundle - * @return le fichier i18n de backup - */ - public static File getI18nFileBackup(File root, String artifactId, Locale bundle) { - return new File(root.getAbsolutePath() + File.separatorChar + artifactId + "-" + bundle.toString() + ".properties~"); - } - - /** - * Permet de convertir une liste non typee, en une liste typee. - * <p/> - * La liste en entree en juste bien castee. - * <p/> - * On effectue une verification sur le typage des elements de la liste. - * <p/> - * Note : <b>Aucune liste n'est creee, ni recopiee</b> - * - * @param <O> le type des objets de la liste - * @param list la liste a convertir - * @param type le type des elements de la liste - * @return la liste typee - * @throws IllegalArgumentException si un element de la liste en entree n'est - * pas en adequation avec le type voulue. - */ - @SuppressWarnings({"unchecked"}) - static public <O> List<O> toGenericList(List<?> list, Class<O> type) throws IllegalArgumentException { - if (list.isEmpty()) { - return (List<O>) list; - } - for (Object o : list) { - if (!(type.isAssignableFrom(o.getClass()))) { - throw new IllegalArgumentException("can not cast List with object of type " + o.getClass() + " to " + type + " type!"); - } - } - return (List<O>) list; - } - static final protected double[] timeFactors = {1000000, 1000, 60, 60, 24}; - static final protected String[] timeUnites = {"ns", "ms", "s", "m", "h", "d"}; - - static public String convertTime(long value) { - return convert(value, timeFactors, timeUnites); - } - - static public String convertTime(long value, long value2) { - return convertTime(value2 - value); - } - - static public String convert(long value, double[] factors, String[] unites) { - long sign = value == 0 ? 1 : value / Math.abs(value); - int i = 0; - double tmp = Math.abs(value); - while (i < factors.length && i < unites.length && tmp > factors[i]) { - tmp = tmp / factors[i++]; - } - - tmp *= sign; - String result; - result = MessageFormat.format("{0,number,0.###}{1}", tmp, - unites[i]); - return result; - } - - /** - * Permet d'avoir les fichiers de proprietes tries. - * - * @author julien - * @author chemit - */ - public static class I18nProperties extends Properties { - - private static final long serialVersionUID = -1147150444452577558L; - /** l'encoding a utiliser pour lire et ecrire le properties. */ - protected String encoding; - /** un drapeau pour savoir s'il faut enlever l'entete generere */ - protected boolean removeHeader; - - public I18nProperties(String encoding) { - this(encoding, true); - } - - public I18nProperties(String encoding, boolean removeHeader) { - super(); - this.encoding = encoding; - this.removeHeader = removeHeader; - } - - public I18nProperties(Properties defaults) { - super(defaults); - } - - @Override - public synchronized Enumeration<Object> keys() { - List<Object> objects = Collections.list(super.keys()); - Vector<Object> result; - try { - // Attention, si les clef ne sont pas des string, ca ne marchera pas - List<String> list = toGenericList(objects, String.class); - Collections.sort(list); - result = new Vector<Object>(list); - } catch (IllegalArgumentException e) { - // keys are not string !!! - // can not sort keys - result = new Vector<Object>(objects); - } - return result.elements(); - } - - /** - * Charge le properties a partir d'un fichier. - * - * @param src le fichier src a charger en utilisant l'encoding declare - * @return l'instance du properties - * @throws IOException if any io pb - */ - public I18nProperties load(File src) throws IOException { - super.load(new InputStreamReader(new FileInputStream(src), encoding)); - return this; - } - - /** - * Sauvegarde le properties dans un fichier, sans commentaire et en utilisant l'encoding declare. - * - * @param dst the fichier de destination - * @throws IOException if any io pb - */ - public void store(File dst) throws IOException { - if (removeHeader) { - super.store(new OutputStreamWriter(new PropertiesDateRemoveFilterStream(new FileOutputStream(dst)), encoding), null); - } else { - super.store(new FileOutputStream(dst), null); - } - } - - /** - * Sauvegarde le properties dans un fichier, sans commentaire en laissant java encode en unicode. - * - * @param dst le fichier de destination - * @throws IOException if any io pb - */ - public void store(OutputStream dst) throws IOException { - if (removeHeader) { - super.store(new PropertiesDateRemoveFilterStream(dst), null); - } else { - super.store(dst, null); - } - } - } - - /** - * Un ecrivain qui supprime la premiere ligne rencontree dans le flux. - * - * - * <b>Note: </b> Attention, les performance d'utilisation de cet ecrivain - * est problèmatique, car sur de gros fichiers (>1000 entrees) les - * performances se degradent serieusement : pour 1200 entrees on arrive à - * plus de 5 secondes, alors que sans on a 76 ms! ... - * - * FIXME : implanter quelque chose de plus performant dans tous les cas - */ - public static class PropertiesDateRemoveFilterStream extends FilterOutputStream { - - private boolean firstLineOver; - char endChar; - - public PropertiesDateRemoveFilterStream(OutputStream out) { - super(out); - firstLineOver = false; - String lineSeparator = System.getProperty("line.separator"); - endChar = lineSeparator.charAt(lineSeparator.length() - 1); - } - - @Override - public void write(int b) throws IOException { - if (!firstLineOver) { - char c = (char) b; - if (c == endChar) { - firstLineOver = true; - } - } else { - out.write(b); - } - } - } -} Modified: maven-i18n-plugin/trunk/src/main/java/org/nuiton/i18n/plugin/parser/AbstractI18nParser.java =================================================================== --- maven-i18n-plugin/trunk/src/main/java/org/nuiton/i18n/plugin/parser/AbstractI18nParser.java 2009-05-14 05:19:13 UTC (rev 1544) +++ maven-i18n-plugin/trunk/src/main/java/org/nuiton/i18n/plugin/parser/AbstractI18nParser.java 2009-05-14 05:19:42 UTC (rev 1545) @@ -1,5 +1,5 @@ /* -* *##% Plugin maven pour lutini18n + * *##% Plugin maven pour lutini18n * Copyright (C) 2007 - 2008 CodeLutin * * This program is free software: you can redistribute it and/or modify @@ -21,13 +21,12 @@ import org.apache.maven.plugin.MojoFailureException; import org.nuiton.i18n.plugin.AbstractI18nPlugin; import org.nuiton.i18n.plugin.I18nLogger; -import org.nuiton.i18n.plugin.PluginHelper; -import org.nuiton.i18n.plugin.PluginHelper.I18nProperties; +import org.nuiton.util.PluginHelper.SortedProperties; import org.nuiton.i18n.plugin.SourceEntry; import org.nuiton.i18n.plugin.parser.event.KeysModifier; import org.nuiton.util.FileUpdater; import org.nuiton.util.FileUtil; - +import org.nuiton.util.PluginHelper; import java.io.File; import java.io.IOException; import java.util.ArrayList; @@ -60,21 +59,18 @@ protected abstract File getDefaultBasedir(); public abstract FileUpdater newFileUpdater(SourceEntry entry); - /** * treate default entry * * @parameter expression="${i18n.treateDefaultEntry}" default-value="true" */ protected boolean treateDefaultEntry; - /** * Source entries (src+includes+excludes) . * * @parameter expression="${i18n.entries}" */ protected MySourceEntry[] entries; - /** * flag to display touched files while parsing. * <p/> @@ -92,15 +88,11 @@ * @since 0.9 */ protected boolean safeMode; - - protected I18nProperties result; - - protected I18nProperties oldParser; - - protected I18nProperties oldLanguage; + protected SortedProperties result; + protected SortedProperties oldParser; + protected SortedProperties oldLanguage; protected int fileTreated = 0; protected long t0; - protected boolean touchFile; protected List<File> treadedFiles; @@ -108,9 +100,9 @@ public void init() { super.init(); t0 = System.nanoTime(); - result = new I18nProperties(encoding); - oldParser = new I18nProperties(encoding); - oldLanguage = new I18nProperties(encoding); + result = new SortedProperties(encoding); + oldParser = new SortedProperties(encoding); + oldLanguage = new SortedProperties(encoding); out.mkdirs(); // evenements if (keysModifier) { @@ -124,9 +116,9 @@ /* - * (non-Javadoc) - * @see org.apache.maven.plugin.AbstractMojo#execute() - */ + * (non-Javadoc) + * @see org.apache.maven.plugin.AbstractMojo#execute() + */ @Override public void execute() throws MojoExecutionException, MojoFailureException { @@ -145,15 +137,15 @@ try { // Reprise sur un ancien parsing - File oldParserFile = PluginHelper.getGetterFile(out, getOutGetter(), true); - File saveFile = PluginHelper.getGetterFileBackup(out, getOutGetter()); + File oldParserFile = getGetterFile(out, getOutGetter(), true); + File saveFile = getGetterFileBackup(out, getOutGetter()); oldParser.load(oldParserFile); FileUtil.copy(oldParserFile, saveFile); // Anciennes cles disponnibles //fixme : pourquoi on utilise un bundle precis ? le premier ici, je ne comprends pas - File oldLanguageFile = PluginHelper.getI18nFile(src, artifactId, locales[0], true); + File oldLanguageFile = getI18nFile(src, artifactId, locales[0], true); oldLanguage.load(oldLanguageFile); @@ -215,7 +207,7 @@ if (verbose) { // log skipped files for (String skipFile : entry.getSkipFiles()) { - vLog.setFile( new File(entry.getBasedir(), skipFile)); + vLog.setFile(new File(entry.getBasedir(), skipFile)); vLog.infoFile("skip", null); } } @@ -227,7 +219,6 @@ } } - /** * Add the default entry to entries given in configuration. * <p/> @@ -308,11 +299,10 @@ * @throws IOException if any io pb */ protected void saveGetterFile() throws IOException { - File getterFile = PluginHelper.getGetterFile(out, getOutGetter(), false); + File getterFile = getGetterFile(out, getOutGetter(), false); result.store(getterFile); } - public static class MySourceEntry extends SourceEntry { public boolean init(AbstractI18nParser mojo) { @@ -363,7 +353,6 @@ return false; } - /** * Obtain all the relative path of files to treate for a given entry. * @@ -373,6 +362,5 @@ protected String[] getFilesForEntry(AbstractI18nParser mojo) { return getIncludedFiles(mojo.getDefaultBasedir(), mojo.getDefaultIncludes(), mojo.getDefaultExcludes()); } - } } Deleted: maven-i18n-plugin/trunk/src/site/rst/Todo.rst =================================================================== --- maven-i18n-plugin/trunk/src/site/rst/Todo.rst 2009-05-14 05:19:13 UTC (rev 1544) +++ maven-i18n-plugin/trunk/src/site/rst/Todo.rst 2009-05-14 05:19:42 UTC (rev 1545) @@ -1,4 +0,0 @@ -TODO -==== - -Any idea ? Modified: maven-i18n-plugin/trunk/src/site/site.xml =================================================================== --- maven-i18n-plugin/trunk/src/site/site.xml 2009-05-14 05:19:13 UTC (rev 1544) +++ maven-i18n-plugin/trunk/src/site/site.xml 2009-05-14 05:19:42 UTC (rev 1545) @@ -58,10 +58,6 @@ name="Sources (jar)"/> </menu> - <menu name="Développeur"> - <item name="A faire" href="Todo.html"/> - </menu> - <menu ref="reports"/> </body>