Author: tchemit Date: 2009-12-29 18:35:17 +0100 (Tue, 29 Dec 2009) New Revision: 1691 Removed: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJaxxMojo.java trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserSwixatMojo.java Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nBundleMojo.java trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nMojo.java trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/BundleMojo.java trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/CollectI18nArtifactsMojo.java trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/GenerateMojo.java trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/GetterMojo.java trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/AbstractI18nParserMojo.java trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJavaMojo.java Log: use AbstractPlugin Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nBundleMojo.java =================================================================== --- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nBundleMojo.java 2009-12-28 10:27:28 UTC (rev 1690) +++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nBundleMojo.java 2009-12-29 17:35:17 UTC (rev 1691) @@ -79,13 +79,4 @@ return bundleOut; } - @Override - public void init() throws Exception { - super.init(); - - if (locales == null || locales.length == 0) { - throw new IllegalStateException("il faut au moins une locale declaree (utiliser la propriete 'bundles')"); - } - } - } Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nMojo.java =================================================================== --- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nMojo.java 2009-12-28 10:27:28 UTC (rev 1690) +++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nMojo.java 2009-12-29 17:35:17 UTC (rev 1691) @@ -19,9 +19,9 @@ * ##%* */ package org.nuiton.i18n.plugin; -import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.project.MavenProject; import org.nuiton.i18n.I18nUtil; +import org.nuiton.plugin.AbstractPlugin; import org.nuiton.plugin.PluginHelper; import java.io.File; @@ -36,7 +36,7 @@ * * @author julien */ -public abstract class AbstractI18nMojo extends AbstractMojo { +public abstract class AbstractI18nMojo extends AbstractPlugin { /** * Le nombre de getters détectés pendant le cycle de vie du build. @@ -119,15 +119,23 @@ * @parameter expression="${i18n.strictMode}" default-value="false" */ protected boolean strictMode; - + /** + * les locales a traiter + */ protected Locale[] locales; /** * logger verbeux */ protected I18nLogger verboseLog; + @Override + protected boolean checkPackaging() { + // nothing to do on a pom module + return !acceptPackaging(Packaging.pom); + } public void init() throws Exception { +// public boolean init() throws Exception { verboseLog = new I18nLogger(this); @@ -135,6 +143,10 @@ getLog().info("config - verbose mode is on"); } locales = I18nUtil.parseLocales(bundles); + if (locales == null || locales.length == 0) { + throw new IllegalStateException("Il faut au moins une locale declaree (utiliser la propriete 'bundles')"); + } +// return true; } public String getArtifactId() { @@ -175,8 +187,7 @@ public File getI18nFile(File root, String artifactId, Locale locale, boolean create) throws IOException { File file = new File(root.getAbsolutePath() + File.separatorChar + artifactId + "-" + locale.toString() + ".properties"); if (create && !file.exists()) { - PluginHelper.createDirectoryIfNecessary(file.getParentFile()); - PluginHelper.createNewFile(file); + createNewFile(file); } return file; } @@ -191,31 +202,31 @@ public File getGetterFile(File root, String getter, boolean create) throws IOException { File file = new File(root.getAbsolutePath() + File.separatorChar + getter); if (create && !file.exists()) { - PluginHelper.createDirectoryIfNecessary(file.getParentFile()); - PluginHelper.createNewFile(file); + createNewFile(file); } return file; } - /** - * @param root le repertoire ou sont stockes les fichiers getter - * @param getter le nom du getter - * @return le fichier i18n - */ - public File getGetterFileBackup(File root, String getter) { - return new File(root.getAbsolutePath() + File.separatorChar + getter + '~'); - } - /** - * @param root le reertoire ou sont stockes les fichiers i18n - * @param artifactId le nom de l'artifact - * @param bundle le nom du bundle - * @return le fichier i18n de backup - */ - public File getI18nFileBackup(File root, String artifactId, Locale bundle) { - return new File(root.getAbsolutePath() + File.separatorChar + artifactId + "-" + bundle.toString() + ".properties~"); - } +// /** +// * @param root le repertoire ou sont stockes les fichiers getter +// * @param getter le nom du getter +// * @return le fichier i18n +// */ +// public File getGetterFileBackup(File root, String getter) { +// return new File(root.getAbsolutePath() + File.separatorChar + getter + '~'); +// } +// /** +// * @param root le reertoire ou sont stockes les fichiers i18n +// * @param artifactId le nom de l'artifact +// * @param bundle le nom du bundle +// * @return le fichier i18n de backup +// */ +// public File getI18nFileBackup(File root, String artifactId, Locale bundle) { +// return new File(root.getAbsolutePath() + File.separatorChar + artifactId + "-" + bundle.toString() + ".properties~"); +// } + protected void checkBundle(Locale locale, Properties propertiesOut, boolean showEmpty) { // on verifie qu'il n'y a pas de traduction vide SortedSet<String> emptyEntries = PluginHelper.getEmptyKeys(propertiesOut); @@ -245,11 +256,42 @@ } } + + public File getBackupFile(File file) { + return new File(file.getAbsolutePath() + "~"); + } + protected void backupFile(File f) throws IOException { - PluginHelper.copy(f, new File(f.getAbsolutePath() + "~")); + File dst = getBackupFile(f); + copyFile(f, dst); } - protected void copyFile(File src, File dst) throws IOException { - PluginHelper.copy(src, dst); +// protected void copyFile(File src, File dst) throws IOException { +// PluginHelper.copy(src, dst); +// } + + + public String getEncoding() { + return encoding; } + + public void setEncoding(String encoding) { + this.encoding = encoding; + } + + public MavenProject getProject() { + return project; + } + + public void setProject(MavenProject project) { + this.project = project; + } + + public boolean isVerbose() { + return verbose; + } + + public void setVerbose(boolean verbose) { + this.verbose = verbose; + } } Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/BundleMojo.java =================================================================== --- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/BundleMojo.java 2009-12-28 10:27:28 UTC (rev 1690) +++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/BundleMojo.java 2009-12-29 17:35:17 UTC (rev 1691) @@ -19,9 +19,6 @@ * ##%* */ package org.nuiton.i18n.plugin; -import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugin.MojoFailureException; -import org.apache.maven.project.MavenProject; import org.nuiton.i18n.bundle.I18nBundleEntry; import org.nuiton.i18n.bundle.I18nBundleFactory; import org.nuiton.io.SortedProperties; @@ -95,42 +92,23 @@ * @since 1.0.0 */ protected boolean showEmpty; - /** - * Dependance du projet. - * - * @parameter default-value="${project}" - * @required - * @since 1.0.0 - */ - protected MavenProject project; @Override public void init() throws Exception { super.init(); - PluginHelper.createDirectoryIfNecessary(bundleOutputDir); + createDirectoryIfNecessary(bundleOutputDir); // ajout de repertoire de generation (le parent en fait) // dans les resources du projet - PluginHelper.addResourceDir(bundleOutputDir.getParentFile(), project, "**/*.properties"); + addResourceDir(bundleOutputDir.getParentFile(), "**/*.properties"); } @Override - public void execute() throws MojoExecutionException, MojoFailureException { - - if ("pom".equals(project.getPackaging()) || "site".equals(project.getPackaging())) { - return; - } - + protected void doAction() throws Exception { long t00 = System.nanoTime(); - try { - init(); - } catch (Exception e) { - throw new MojoExecutionException("could not init gaol for reason " + e.getMessage(), e); - } - if (!silent) { getLog().info("config - bundle name : " + bundleOutputName); getLog().info("config - basedir : " + bundleOutputDir); @@ -139,80 +117,170 @@ Map<Locale, String> bundleDico = new LinkedHashMap<Locale, String>(locales.length); - try { + for (Locale locale : locales) { - for (Locale locale : locales) { + long t0 = System.nanoTime(); - long t0 = System.nanoTime(); + File bundleOut = getI18nFile(bundleOutputDir, bundleOutputName, locale, false); - File bundleOut = getI18nFile(bundleOutputDir, bundleOutputName, locale, false); + if (!silent) { + getLog().info("generate bundle for locale " + locale); + } - if (!silent) { - getLog().info("generate bundle for locale " + locale); - } + SortedProperties propertiesOut = new SortedProperties(encoding, false); + StringBuilder buffer = new StringBuilder(); - SortedProperties propertiesOut = new SortedProperties(encoding, false); - StringBuilder buffer = new StringBuilder(); + URL[] urls = getCollectI18nResources(locale); + if (urls.length == 0) { + getLog().warn("no bundle for locale " + locale); + continue; + } - URL[] urls = getCollectI18nResources(locale); - if (urls.length == 0) { - getLog().warn("no bundle for locale " + locale); - continue; - } + for (URL url : urls) { + long t000 = System.nanoTime(); + I18nBundleEntry bundleEntry = new I18nBundleEntry(url, locale, null); + bundleEntry.load(propertiesOut); + String strPath = bundleEntry.getPath().toString(); + int index = strPath.indexOf("i18n/"); - for (URL url : urls) { - long t000 = System.nanoTime(); - I18nBundleEntry bundleEntry = new I18nBundleEntry(url, locale, null); - bundleEntry.load(propertiesOut); - String strPath = bundleEntry.getPath().toString(); - int index = strPath.indexOf("i18n/"); - - buffer.append(',').append(strPath.substring(index)); - if (verbose) { - getLog().info("loaded " + bundleEntry.getPath() + " in " + PluginHelper.convertTime(t000, System.nanoTime())); - } + buffer.append(',').append(strPath.substring(index)); + if (verbose) { + getLog().info("loaded " + bundleEntry.getPath() + " in " + PluginHelper.convertTime(t000, System.nanoTime())); } + } - if (buffer.length() > 0) { - bundleDico.put(locale, buffer.substring(1)); - if (!silent) { - getLog().info("bundles for locale : " + bundleDico.get(locale)); - } + if (buffer.length() > 0) { + bundleDico.put(locale, buffer.substring(1)); + if (!silent) { + getLog().info("bundles for locale : " + bundleDico.get(locale)); } - propertiesOut.store(bundleOut); - if (!silent && verbose) { - getLog().info("bundle created in " + PluginHelper.convertTime(t0, System.nanoTime()) + " (detected sentences : " + propertiesOut.size() + ")"); - } - if (checkBundle) { - checkBundle(locale, propertiesOut, showEmpty); - } } - - // ecriture du ficher des definitions i18n (permet de faire une - // recherche extact sur un fichier puis d'en deduire les bundles a - // charger - String f = String.format(I18nBundleFactory.UNIQUE_BUNDLE_DEF, bundleOutputName); - File defOut = new File(bundleOutputDir, f); - if (!silent) { - getLog().info("prepare i18n definition " + defOut.getAbsolutePath()); + propertiesOut.store(bundleOut); + if (!silent && verbose) { + getLog().info("bundle created in " + PluginHelper.convertTime(t0, System.nanoTime()) + " (detected sentences : " + propertiesOut.size() + ")"); } - SortedProperties p = new SortedProperties(encoding, false); - p.setProperty(I18nBundleFactory.BUNDLE_DEF_LOCALES, bundles); - for (Entry<Locale, String> e : bundleDico.entrySet()) { - p.setProperty(I18nBundleFactory.BUNDLES_FOR_LOCALE + e.getKey().toString(), e.getValue()); + if (checkBundle) { + checkBundle(locale, propertiesOut, showEmpty); } - p.store(new FileOutputStream(defOut), null); + } - if (!silent && verbose) { - getLog().info("done in " + PluginHelper.convertTime(t00, System.nanoTime())); - } - } catch (IOException e) { - getLog().error("File Error I/O ", e); - throw new MojoFailureException("File Error I/O "); + // ecriture du ficher des definitions i18n (permet de faire une + // recherche extact sur un fichier puis d'en deduire les bundles a + // charger + String f = String.format(I18nBundleFactory.UNIQUE_BUNDLE_DEF, bundleOutputName); + File defOut = new File(bundleOutputDir, f); + if (!silent) { + getLog().info("prepare i18n definition " + defOut.getAbsolutePath()); } + SortedProperties p = new SortedProperties(encoding, false); + p.setProperty(I18nBundleFactory.BUNDLE_DEF_LOCALES, bundles); + for (Entry<Locale, String> e : bundleDico.entrySet()) { + p.setProperty(I18nBundleFactory.BUNDLES_FOR_LOCALE + e.getKey().toString(), e.getValue()); + } + p.store(new FileOutputStream(defOut), null); + + if (!silent && verbose) { + getLog().info("done in " + PluginHelper.convertTime(t00, System.nanoTime())); + } } +// @Override +// public void execute() throws MojoExecutionException, MojoFailureException { +// +// if ("pom".equals(project.getPackaging()) || "site".equals(project.getPackaging())) { +// return; +// } +// +// long t00 = System.nanoTime(); +// +// try { +// init(); +// } catch (Exception e) { +// throw new MojoExecutionException("could not init gaol for reason " + e.getMessage(), e); +// } +// +// if (!silent) { +// getLog().info("config - bundle name : " + bundleOutputName); +// getLog().info("config - basedir : " + bundleOutputDir); +// getLog().info("config - locales : " + Arrays.toString(locales)); +// } +// +// Map<Locale, String> bundleDico = new LinkedHashMap<Locale, String>(locales.length); +// +// try { +// +// for (Locale locale : locales) { +// +// long t0 = System.nanoTime(); +// +// File bundleOut = getI18nFile(bundleOutputDir, bundleOutputName, locale, false); +// +// if (!silent) { +// getLog().info("generate bundle for locale " + locale); +// } +// +// SortedProperties propertiesOut = new SortedProperties(encoding, false); +// StringBuilder buffer = new StringBuilder(); +// +// URL[] urls = getCollectI18nResources(locale); +// if (urls.length == 0) { +// getLog().warn("no bundle for locale " + locale); +// continue; +// } +// +// for (URL url : urls) { +// long t000 = System.nanoTime(); +// I18nBundleEntry bundleEntry = new I18nBundleEntry(url, locale, null); +// bundleEntry.load(propertiesOut); +// String strPath = bundleEntry.getPath().toString(); +// int index = strPath.indexOf("i18n/"); +// +// buffer.append(',').append(strPath.substring(index)); +// if (verbose) { +// getLog().info("loaded " + bundleEntry.getPath() + " in " + PluginHelper.convertTime(t000, System.nanoTime())); +// } +// } +// +// if (buffer.length() > 0) { +// bundleDico.put(locale, buffer.substring(1)); +// if (!silent) { +// getLog().info("bundles for locale : " + bundleDico.get(locale)); +// } +// } +// propertiesOut.store(bundleOut); +// if (!silent && verbose) { +// getLog().info("bundle created in " + PluginHelper.convertTime(t0, System.nanoTime()) + " (detected sentences : " + propertiesOut.size() + ")"); +// } +// if (checkBundle) { +// checkBundle(locale, propertiesOut, showEmpty); +// } +// } +// +// // ecriture du ficher des definitions i18n (permet de faire une +// // recherche extact sur un fichier puis d'en deduire les bundles a +// // charger +// String f = String.format(I18nBundleFactory.UNIQUE_BUNDLE_DEF, bundleOutputName); +// File defOut = new File(bundleOutputDir, f); +// if (!silent) { +// getLog().info("prepare i18n definition " + defOut.getAbsolutePath()); +// } +// SortedProperties p = new SortedProperties(encoding, false); +// p.setProperty(I18nBundleFactory.BUNDLE_DEF_LOCALES, bundles); +// for (Entry<Locale, String> e : bundleDico.entrySet()) { +// p.setProperty(I18nBundleFactory.BUNDLES_FOR_LOCALE + e.getKey().toString(), e.getValue()); +// } +// p.store(new FileOutputStream(defOut), null); +// +// if (!silent && verbose) { +// getLog().info("done in " + PluginHelper.convertTime(t00, System.nanoTime())); +// } +// } catch (IOException e) { +// getLog().error("File Error I/O ", e); +// throw new MojoFailureException("File Error I/O "); +// } +// } + @Override protected URL[] getCollectI18nResources(Locale locale) throws IOException { File file = getCollectOutputFile(locale, false); Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/CollectI18nArtifactsMojo.java =================================================================== --- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/CollectI18nArtifactsMojo.java 2009-12-28 10:27:28 UTC (rev 1690) +++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/CollectI18nArtifactsMojo.java 2009-12-29 17:35:17 UTC (rev 1691) @@ -27,8 +27,6 @@ import org.apache.maven.artifact.resolver.ArtifactCollector; import org.apache.maven.artifact.resolver.filter.ArtifactFilter; import org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter; -import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.shared.dependency.tree.DependencyNode; import org.apache.maven.shared.dependency.tree.DependencyTreeBuilder; import org.apache.maven.shared.dependency.tree.DependencyTreeBuilderException; @@ -56,7 +54,6 @@ * $Author: tchemit $ * @goal collect-i18n-artifacts * @phase generate-resources - * @execute goal=gen * @requiresProject true * @requiresDependencyResolution runtime * @since 1.0.2 @@ -106,62 +103,89 @@ public void init() throws Exception { super.init(); - if (locales == null || locales.length == 0) { - throw new IllegalStateException("il faut au moins une locale declaree (utiliser la propriete 'bundles')"); - } - PluginHelper.createDirectoryIfNecessary(collectOutputDir); } @Override - public void execute() throws MojoExecutionException, MojoFailureException { + protected void doAction() throws Exception { - if ("pom".equals(project.getPackaging()) || "site".equals(project.getPackaging())) { - getLog().info("skip goal for none java-based packaging."); + // detects the i18n artifacts (only once since it cost some times)... + i18nArtifacts = detectI18nArtifacts(); + + if (i18nArtifacts.length == 0) { + getLog().warn("no i18n artifact detected."); return; } - try { - init(); - } catch (Exception e) { - throw new MojoExecutionException("could not init goal for reason " + e.getMessage(), e); - } + for (Locale locale : locales) { - try { + if (!silent) { + getLog().info("generate collected i18n artifacts for locale " + locale); + } + URL[] urls = getCollectI18nResources(locale); - // detects the i18n artifacts (only once since it cost some times)... - i18nArtifacts = detectI18nArtifacts(); - - if (i18nArtifacts.length == 0) { - getLog().warn("no i18n artifact detected."); + if (urls.length == 0) { + getLog().warn("no i18n bundles for locale " + locale); return; } - for (Locale locale : locales) { + File bundleOut = getCollectOutputFile(locale, true); - if (!silent) { - getLog().info("generate collected i18n artifacts for locale " + locale); - } - URL[] urls = getCollectI18nResources(locale); + storeCollectI18nResources(bundleOut, urls); - if (urls.length == 0) { - getLog().warn("no i18n bundles for locale " + locale); - return; - } - - File bundleOut = getCollectOutputFile(locale, true); - - storeCollectI18nResources(bundleOut, urls); - - getLog().info("collected " + urls.length + " i18n artifacts for locale " + locale + " stored in " + bundleOut); - } - } catch (IOException e) { - throw new MojoExecutionException("could not treate i18n artifacts", e); - } catch (DependencyTreeBuilderException e) { - throw new MojoExecutionException("could not obtain i18n artifacts", e); + getLog().info("collected " + urls.length + " i18n artifacts for locale " + locale + " stored in " + bundleOut); } } +// @Override +// public void execute() throws MojoExecutionException, MojoFailureException { +// +// if ("pom".equals(project.getPackaging()) || "site".equals(project.getPackaging())) { +// getLog().info("skip goal for none java-based packaging."); +// return; +// } +// +// try { +// init(); +// } catch (Exception e) { +// throw new MojoExecutionException("could not init goal for reason " + e.getMessage(), e); +// } +// +// try { +// +// // detects the i18n artifacts (only once since it cost some times)... +// i18nArtifacts = detectI18nArtifacts(); +// +// if (i18nArtifacts.length == 0) { +// getLog().warn("no i18n artifact detected."); +// return; +// } +// +// for (Locale locale : locales) { +// +// if (!silent) { +// getLog().info("generate collected i18n artifacts for locale " + locale); +// } +// URL[] urls = getCollectI18nResources(locale); +// +// if (urls.length == 0) { +// getLog().warn("no i18n bundles for locale " + locale); +// return; +// } +// +// File bundleOut = getCollectOutputFile(locale, true); +// +// storeCollectI18nResources(bundleOut, urls); +// +// getLog().info("collected " + urls.length + " i18n artifacts for locale " + locale + " stored in " + bundleOut); +// } +// } catch (IOException e) { +// throw new MojoExecutionException("could not treate i18n artifacts", e); +// } catch (DependencyTreeBuilderException e) { +// throw new MojoExecutionException("could not obtain i18n artifacts", e); +// } +// } + @Override protected URL[] getCollectI18nResources(Locale locale) throws IOException, DependencyTreeBuilderException { @@ -194,7 +218,7 @@ getLog().info("add " + path); } } - PluginHelper.writeString(bundleOut, buffer.toString(), encoding); + writeFile(bundleOut, buffer.toString(), encoding); } /** Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/GenerateMojo.java =================================================================== --- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/GenerateMojo.java 2009-12-28 10:27:28 UTC (rev 1690) +++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/GenerateMojo.java 2009-12-29 17:35:17 UTC (rev 1691) @@ -19,13 +19,10 @@ * ##%* */ package org.nuiton.i18n.plugin; -import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugin.MojoFailureException; import org.nuiton.io.SortedProperties; import java.io.File; import java.io.FileOutputStream; -import java.io.IOException; import java.util.Arrays; import java.util.Locale; @@ -64,19 +61,16 @@ protected boolean keepBackup; @Override - public void execute() throws MojoExecutionException, MojoFailureException { - - try { - init(); - } catch (Exception e) { - throw new MojoExecutionException("could not init goal for reason " + e.getMessage(), e); - } - + protected boolean checkSkip() { if (!needGeneration()) { - getLog().info("Nothing to generate - all files are up to date."); - return; + getLog().info("No getter detected - all files are up to date."); + return false; } + return true; + } + @Override + protected void doAction() throws Exception { if (!silent) { getLog().info("config - src basedir : " + src.getAbsolutePath()); getLog().info("config - out basedir : " + out.getAbsolutePath()); @@ -86,72 +80,156 @@ if (!silent) { getLog().info("prepare bundle for locale " + locale); } - try { - // Merge - File bundleSrc = getI18nFile(src, artifactId, locale, false); - File bundleOut = getI18nFile(out, artifactId, locale, false); + // Merge + File bundleSrc = getI18nFile(src, artifactId, locale, false); + File bundleOut = getI18nFile(out, artifactId, locale, false); - SortedProperties propertiesSrc = new SortedProperties(encoding); + SortedProperties propertiesSrc = new SortedProperties(encoding); - if (bundleSrc.exists()) { - propertiesSrc.load(bundleSrc); - } + if (bundleSrc.exists()) { + propertiesSrc.load(bundleSrc); + } - SortedProperties propertiesOut = new SortedProperties(encoding); + SortedProperties propertiesOut = new SortedProperties(encoding); - if (!strictMode) { - // si on n'est pas en mode strict, on doit push back in bundle out, all the bundle src keys - propertiesOut.putAll(propertiesSrc); - } - propertiesOut.load(bundleOut); + if (!strictMode) { + // si on n'est pas en mode strict, on doit push back in bundle out, all the bundle src keys + propertiesOut.putAll(propertiesSrc); + } + propertiesOut.load(bundleOut); - // Parcours des clés - for (Object key : propertiesOut.keySet()) { - Object oldKey = propertiesOut.get(key); - Object value = propertiesSrc.get(oldKey); + // Parcours des clés + for (Object key : propertiesOut.keySet()) { + Object oldKey = propertiesOut.get(key); + Object value = propertiesSrc.get(oldKey); - // Récupération de la clé si elle a été renommée - if (!key.equals(oldKey) && value == null) { - value = propertiesSrc.get(key); - } + // Récupération de la clé si elle a été renommée + if (!key.equals(oldKey) && value == null) { + value = propertiesSrc.get(key); + } - if (value != null) { - propertiesOut.put(key, value); - } else { - propertiesOut.put(key, ""); - } + if (value != null) { + propertiesOut.put(key, value); + } else { + propertiesOut.put(key, ""); } + } - //fixme : on devrait laisser le fichier en utf8 ? - //propertiesOut.store(bundleOut); - propertiesOut.store(new FileOutputStream(bundleOut)); + //fixme : on devrait laisser le fichier en utf8 ? + //propertiesOut.store(bundleOut); + propertiesOut.store(new FileOutputStream(bundleOut)); - // Sauvegarde avant copie - if (genSrc && keepBackup) { - backupFile(bundleSrc); - } - if (!silent) { - getLog().info("merge bundle " + locale + " to out"); - } + // Sauvegarde avant copie + if (genSrc && keepBackup) { + backupFile(bundleSrc); + } + if (!silent) { + getLog().info("merge bundle " + locale + " to out"); + } - if (checkBundle) { - checkBundle(locale, propertiesOut, showEmpty); - } + if (checkBundle) { + checkBundle(locale, propertiesOut, showEmpty); + } - if (genSrc) { - // Copie des fichiers dans les sources - copyFile(bundleOut, bundleSrc); - //if (verbose) { - if (!silent) { - getLog().info("copy bundle " + locale + " to src"); - } - //} + if (genSrc) { + // Copie des fichiers dans les sources + copyFile(bundleOut, bundleSrc); + if (!silent) { + getLog().info("copy bundle " + locale + " to src"); } - - } catch (IOException e) { - getLog().error("File Error I/O ", e); - throw new MojoFailureException("File Error I/O "); } } } + +// @Override +// public void execute() throws MojoExecutionException, MojoFailureException { +// +// try { +// init(); +// } catch (Exception e) { +// throw new MojoExecutionException("could not init goal for reason " + e.getMessage(), e); +// } +// +// if (!needGeneration()) { +// getLog().info("Nothing to generate - all files are up to date."); +// return; +// } +// +// if (!silent) { +// getLog().info("config - src basedir : " + src.getAbsolutePath()); +// getLog().info("config - out basedir : " + out.getAbsolutePath()); +// getLog().info("config - locales : " + Arrays.toString(locales)); +// } +// for (Locale locale : locales) { +// if (!silent) { +// getLog().info("prepare bundle for locale " + locale); +// } +// try { +// // Merge +// File bundleSrc = getI18nFile(src, artifactId, locale, false); +// File bundleOut = getI18nFile(out, artifactId, locale, false); +// +// SortedProperties propertiesSrc = new SortedProperties(encoding); +// +// if (bundleSrc.exists()) { +// propertiesSrc.load(bundleSrc); +// } +// +// SortedProperties propertiesOut = new SortedProperties(encoding); +// +// if (!strictMode) { +// // si on n'est pas en mode strict, on doit push back in bundle out, all the bundle src keys +// propertiesOut.putAll(propertiesSrc); +// } +// propertiesOut.load(bundleOut); +// +// // Parcours des clés +// for (Object key : propertiesOut.keySet()) { +// Object oldKey = propertiesOut.get(key); +// Object value = propertiesSrc.get(oldKey); +// +// // Récupération de la clé si elle a été renommée +// if (!key.equals(oldKey) && value == null) { +// value = propertiesSrc.get(key); +// } +// +// if (value != null) { +// propertiesOut.put(key, value); +// } else { +// propertiesOut.put(key, ""); +// } +// } +// +// //fixme : on devrait laisser le fichier en utf8 ? +// //propertiesOut.store(bundleOut); +// propertiesOut.store(new FileOutputStream(bundleOut)); +// +// // Sauvegarde avant copie +// if (genSrc && keepBackup) { +// backupFile(bundleSrc); +// } +// if (!silent) { +// getLog().info("merge bundle " + locale + " to out"); +// } +// +// if (checkBundle) { +// checkBundle(locale, propertiesOut, showEmpty); +// } +// +// if (genSrc) { +// // Copie des fichiers dans les sources +// copyFile(bundleOut, bundleSrc); +// //if (verbose) { +// if (!silent) { +// getLog().info("copy bundle " + locale + " to src"); +// } +// //} +// } +// +// } catch (IOException e) { +// getLog().error("File Error I/O ", e); +// throw new MojoFailureException("File Error I/O "); +// } +// } +// } } Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/GetterMojo.java =================================================================== --- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/GetterMojo.java 2009-12-28 10:27:28 UTC (rev 1690) +++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/GetterMojo.java 2009-12-29 17:35:17 UTC (rev 1691) @@ -19,8 +19,6 @@ * ##%* */ package org.nuiton.i18n.plugin; -import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugin.MojoFailureException; import org.codehaus.plexus.util.DirectoryScanner; import org.nuiton.io.SortedProperties; import org.nuiton.plugin.PluginHelper; @@ -40,69 +38,124 @@ public class GetterMojo extends AbstractI18nMojo { @Override - public void execute() throws MojoExecutionException, MojoFailureException { + protected boolean checkSkip() { - try { - init(); - } catch (Exception e) { - throw new MojoExecutionException("could not init goal for reason " + e.getMessage(), e); + if (!needGeneration()) { +// if (verbose) { + getLog().info("No getter detected - all files are up to date."); +// } + return false; } + return true; + } - if (!needGeneration()) { - if (verbose) { - getLog().info("Nothing to generate - all files are up to date."); - } - return; - } + @Override + protected void doAction() throws Exception { + if (!silent) { getLog().info("config - basedir : " + out.getAbsolutePath()); getLog().info("config - locales : " + Arrays.toString(locales)); } - try { - File bundleGetters = new File(out.getAbsolutePath() + File.separatorChar + artifactId + ".properties"); - boolean b = bundleGetters.createNewFile(); - if (!b) { - throw new IOException("could not create file " + bundleGetters); - } - DirectoryScanner ds = new DirectoryScanner(); - ds.setBasedir(out); - ds.setIncludes(new String[]{"*.getter"}); - ds.scan(); - String[] files = ds.getIncludedFiles(); + File bundleGetters = new File(out.getAbsolutePath() + File.separatorChar + artifactId + ".properties"); + createNewFile(bundleGetters); + DirectoryScanner ds = new DirectoryScanner(); + ds.setBasedir(out); + ds.setIncludes(new String[]{"*.getter"}); + ds.scan(); + String[] files = ds.getIncludedFiles(); - // Fusion des fichiers propriétés des différents parsers - for (String file : files) { - long t0 = System.nanoTime(); - File bundleGetter = getGetterFile(out, file, false); - concactProperties(bundleGetter, bundleGetters); - if (genSrc) { - PluginHelper.deleteFile(bundleGetter); - } - if (!silent) { - getLog().info("import getter " + bundleGetter.getName() + " in " + PluginHelper.convertTime(System.nanoTime() - t0)); - } + // Fusion des fichiers propriétés des différents parsers + for (String file : files) { + long t0 = System.nanoTime(); + File bundleGetter = getGetterFile(out, file, false); + concactProperties(bundleGetter, bundleGetters); + if (genSrc) { + deleteFile(bundleGetter); } + if (!silent) { + getLog().info("import getter " + bundleGetter.getName() + " in " + PluginHelper.convertTime(System.nanoTime() - t0)); + } + } - // Création des bundles - for (Locale locale : locales) { - if (getLog().isDebugEnabled()) { - getLog().debug("generate bundle for locale " + locale); - } - File bundleOut = getI18nFile(out, artifactId, locale, false); - copyFile(bundleGetters, bundleOut); - if (!silent && verbose) { - getLog().info("generate bundle " + locale); - } + // Création des bundles + for (Locale locale : locales) { + if (getLog().isDebugEnabled()) { + getLog().debug("generate bundle for locale " + locale); } - PluginHelper.deleteFile(bundleGetters); - } catch (IOException e) { - getLog().error("File Error I/O ", e); - throw new MojoFailureException("File Error I/O"); + File bundleOut = getI18nFile(out, artifactId, locale, false); + copyFile(bundleGetters, bundleOut); + if (!silent && verbose) { + getLog().info("generate bundle " + locale); + } } + deleteFile(bundleGetters); } +// @Override +// public void execute() throws MojoExecutionException, MojoFailureException { +// +// try { +// init(); +// } catch (Exception e) { +// throw new MojoExecutionException("could not init goal for reason " + e.getMessage(), e); +// } +// +// if (!needGeneration()) { +// if (verbose) { +// getLog().info("Nothing to generate - all files are up to date."); +// } +// return; +// } +// if (!silent) { +// getLog().info("config - basedir : " + out.getAbsolutePath()); +// getLog().info("config - locales : " + Arrays.toString(locales)); +// } +// +// try { +// File bundleGetters = new File(out.getAbsolutePath() + File.separatorChar + artifactId + ".properties"); +// boolean b = bundleGetters.createNewFile(); +// if (!b) { +// throw new IOException("could not create file " + bundleGetters); +// } +// DirectoryScanner ds = new DirectoryScanner(); +// ds.setBasedir(out); +// ds.setIncludes(new String[]{"*.getter"}); +// ds.scan(); +// String[] files = ds.getIncludedFiles(); +// +// // Fusion des fichiers propriétés des différents parsers +// for (String file : files) { +// long t0 = System.nanoTime(); +// File bundleGetter = getGetterFile(out, file, false); +// concactProperties(bundleGetter, bundleGetters); +// if (genSrc) { +// PluginHelper.deleteFile(bundleGetter); +// } +// if (!silent) { +// getLog().info("import getter " + bundleGetter.getName() + " in " + PluginHelper.convertTime(System.nanoTime() - t0)); +// } +// } +// +// // Création des bundles +// for (Locale locale : locales) { +// if (getLog().isDebugEnabled()) { +// getLog().debug("generate bundle for locale " + locale); +// } +// File bundleOut = getI18nFile(out, artifactId, locale, false); +// copyFile(bundleGetters, bundleOut); +// if (!silent && verbose) { +// getLog().info("generate bundle " + locale); +// } +// } +// PluginHelper.deleteFile(bundleGetters); +// } catch (IOException e) { +// getLog().error("File Error I/O ", e); +// throw new MojoFailureException("File Error I/O"); +// } +// } + /** * Concatene deux fichiers de proprietes * Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/AbstractI18nParserMojo.java =================================================================== --- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/AbstractI18nParserMojo.java 2009-12-28 10:27:28 UTC (rev 1690) +++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/AbstractI18nParserMojo.java 2009-12-29 17:35:17 UTC (rev 1691) @@ -19,14 +19,11 @@ * ##%* */ package org.nuiton.i18n.plugin.parser; -import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugin.MojoFailureException; import org.nuiton.i18n.plugin.AbstractI18nMojo; import org.nuiton.i18n.plugin.I18nLogger; import org.nuiton.i18n.plugin.SourceEntry; import org.nuiton.io.FileUpdater; import org.nuiton.io.SortedProperties; -import org.nuiton.plugin.PluginHelper; import java.io.File; import java.io.IOException; @@ -110,6 +107,15 @@ */ protected boolean safeMode; /** + * flag to save previous getter in a backup before doing parsing. + * <p/> + * Note: by default, do not perform backup (but it was here originaly so let it possible...) + * + * @parameter expression="${i18n.backupGetter}" default-value="false" + * @since 1.0.2 + */ + protected boolean backupGetter; + /** * Liste des évènements */ protected List<ParserEvent> events = new ArrayList<ParserEvent>(); @@ -132,12 +138,19 @@ result = new SortedProperties(encoding); oldParser = new SortedProperties(encoding); oldLanguage = new SortedProperties(encoding); - PluginHelper.createDirectoryIfNecessary(out); + createDirectoryIfNecessary(out); // out.mkdirs(); // evenements if (keysModifier) { addParserEvent(KeysModifier.getInstance(getKeyModifierStart(), getKeyModifierEnd(), encoding)); } + + // check there is something to treate + if (entries == null || entries.length == 0 && !treateDefaultEntry) { + // nothing to do + throw new IllegalStateException("No entry defined and treateDefaultEntry is false, will skip the goal."); + } + treadedFiles = new ArrayList<File>(); if (!silent && verbose) { showTouchedFiles = true; @@ -145,19 +158,7 @@ } @Override - public void execute() throws MojoExecutionException, MojoFailureException { - - try { - init(); - } catch (Exception e) { - throw new MojoExecutionException("could not init goal for reason " + e.getMessage(), e); - } - - if (entries == null || entries.length == 0 && !treateDefaultEntry) { - // nothing to do - return; - } - + protected void doAction() throws Exception { if (!silent && safeMode) { getLog().info("config - safeMode is on (could be slower)."); } @@ -165,48 +166,108 @@ getLog().info("config - strictMode is on (all files will be parsed)."); } - try { - // Reprise sur un ancien parsing - File oldParserFile = getGetterFile(out, getOutGetter(), true); - File saveFile = getGetterFileBackup(out, getOutGetter()); + // Reprise sur un ancien parsing + File oldParserFile = getGetterFile(out, getOutGetter(), true); + File saveFile = getBackupFile(oldParserFile); +// File saveFile = getGetterFileBackup(out, getOutGetter()); - oldParser.load(oldParserFile); - copyFile(oldParserFile, saveFile); + oldParser.load(oldParserFile); + if (backupGetter) { + backupFile(oldParserFile); +// copyFile(oldParserFile, saveFile); + } - // Anciennes cles disponnibles - //fixme : pourquoi on utilise un bundle precis ? le premier ici, je ne comprends pas - File oldLanguageFile = getI18nFile(src, artifactId, locales[0], true); + // Anciennes cles disponnibles + //fixme : pourquoi on utilise un bundle precis ? le premier ici, je ne comprends pas + File oldLanguageFile = getI18nFile(src, artifactId, locales[0], true); - oldLanguage.load(oldLanguageFile); + oldLanguage.load(oldLanguageFile); - // Parsing - parse(); + // Parsing + parse(); - // Suppression du fichier sauvegarder - boolean b = saveFile.delete(); - if (!b) { - throw new IOException("could not delete file " + saveFile); - } + // Suppression du fichier sauvegarder + if (!backupGetter) { + deleteFile(saveFile); + } - int i = treadedFiles.size(); - if (fileTreated == 0) { - if (!silent) { - getLog().info("Nothing to generate - all files are up to date."); - } - } else { - if (!silent) { - getLog().info(getVerboseLog().getLogEntry("parsing is done. [treated file(s) : " + i + '/' + fileTreated + "]", fileTreated, 0, t0)); - } - addGetter(); + int i = treadedFiles.size(); + + if (fileTreated == 0) { + if (!silent) { + getLog().info("Nothing was parsed - all files are up to date."); } - - } catch (Exception e) { - getLog().error("Error code parsing ", e); - throw new MojoFailureException("Error code parsing"); + } else { + if (!silent) { + getLog().info(getVerboseLog().getLogEntry("Parsing is done. [treated file(s) : " + i + '/' + fileTreated + "]", fileTreated, 0, t0)); + } + addGetter(); } - } +// @Override +// public void execute() throws MojoExecutionException, MojoFailureException { +// +// try { +// init(); +// } catch (Exception e) { +// throw new MojoExecutionException("could not init goal for reason " + e.getMessage(), e); +// } +// +// if (entries == null || entries.length == 0 && !treateDefaultEntry) { +// // nothing to do +// return; +// } +// +// if (!silent && safeMode) { +// getLog().info("config - safeMode is on (could be slower)."); +// } +// if (!silent && strictMode) { +// getLog().info("config - strictMode is on (all files will be parsed)."); +// } +// +// try { +// // Reprise sur un ancien parsing +// File oldParserFile = getGetterFile(out, getOutGetter(), true); +// File saveFile = getGetterFileBackup(out, getOutGetter()); +// +// oldParser.load(oldParserFile); +// copyFile(oldParserFile, saveFile); +// +// // Anciennes cles disponnibles +// //fixme : pourquoi on utilise un bundle precis ? le premier ici, je ne comprends pas +// File oldLanguageFile = getI18nFile(src, artifactId, locales[0], true); +// +// oldLanguage.load(oldLanguageFile); +// +// // Parsing +// parse(); +// +// // Suppression du fichier sauvegarder +// boolean b = saveFile.delete(); +// if (!b) { +// throw new IOException("could not delete file " + saveFile); +// } +// +// int i = treadedFiles.size(); +// if (fileTreated == 0) { +// if (!silent) { +// getLog().info("Nothing to generate - all files are up to date."); +// } +// } else { +// if (!silent) { +// getLog().info(getVerboseLog().getLogEntry("parsing is done. [treated file(s) : " + i + '/' + fileTreated + "]", fileTreated, 0, t0)); +// } +// addGetter(); +// } +// +// } catch (Exception e) { +// getLog().error("Error code parsing ", e); +// throw new MojoFailureException("Error code parsing"); +// } +// +// } + @Override public void parse() throws IOException { if (treateDefaultEntry) { Modified: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJavaMojo.java =================================================================== --- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJavaMojo.java 2009-12-28 10:27:28 UTC (rev 1690) +++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJavaMojo.java 2009-12-29 17:35:17 UTC (rev 1691) @@ -20,7 +20,6 @@ package org.nuiton.i18n.plugin.parser.impl; -import org.apache.maven.project.MavenProject; import org.nuiton.i18n.plugin.SourceEntry; import org.nuiton.i18n.plugin.parser.AbstractI18nParserMojo; import org.nuiton.i18n.plugin.parser.ParserEvent; @@ -58,14 +57,6 @@ protected File defaultBasedir; /** - * Dependance du projet. - * - * @parameter default-value="${project}" - * @readonly - */ - protected MavenProject project; - - /** * Repertoire sources des fichiers i18n. * * @parameter expression="${i18n.cp}" default-value="${basedir}/target/classes" @@ -118,7 +109,7 @@ @Override public void parseFile(File srcFile) { - LineNumberReader lnr = null; + LineNumberReader lnr; String line = null; try { lnr = new LineNumberReader(new InputStreamReader(new FileInputStream(srcFile))); Deleted: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJaxxMojo.java =================================================================== --- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJaxxMojo.java 2009-12-28 10:27:28 UTC (rev 1690) +++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserJaxxMojo.java 2009-12-29 17:35:17 UTC (rev 1691) @@ -1,111 +0,0 @@ -/* - * *##% - * I18n :: Maven Plugin - * Copyright (C) 2007 - 2009 CodeLutin - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * ##%* */ - -package org.nuiton.i18n.plugin.parser.impl; - -import org.nuiton.i18n.plugin.SourceEntry; -import org.nuiton.io.FileUpdater; -import org.nuiton.io.FileUpdaterHelper; - -import java.io.File; - -/** - * Récupération des chaine à traduire depuis les fichiers xml Jaxx. - * - * @author julien - * @goal parserJaxx - * @phase generate-resources - * @deprecated since 1.0.0, prefer use the java parser since xml parser can not - * be easly extendable - */ -@Deprecated -public class ParserJaxxMojo extends ParserXmlMojo { - - /** - * Source entries (src+includes+excludes) . - * - * @parameter expression="${i18n.defaultIncludes}" default-value="**\/*.jaxx" - */ - protected String defaultIncludes; - - /** - * Where jaxx files should have been generated. - * - * @parameter expression="${i18n.defaultGenerateBasedir}" default-value="${basedir}/target/generated-sources/java" - */ - protected File defaultGenerateBasedir; - - /** - * Regles xml. - * - * @parameter expression="${i18n.rulesJaxx}" default-value="jaxx.rules" - */ - protected String rulesJaxx; - - @Override - public String[] getDefaultIncludes() { - return new String[]{defaultIncludes}; - } - - @Override - public String[] getDefaultExcludes() { - return new String[]{}; - } - - @Override - public FileUpdater newFileUpdater(SourceEntry entry) { - return FileUpdaterHelper.newJavaFileUpdater(entry.getBasedir(), defaultGenerateBasedir); - } - - @Override - protected String getOutGetter() { - return "jaxx.getter"; - } - - @Override - protected String getKeyModifierStart() { - return "=\\s*[\"\']"; - } - - @Override - protected String getKeyModifierEnd() { - return "[\"\']"; - } - - @Override - protected String getFileRules() { - return rulesJaxx; - } - - @Override - protected String getCoreFileRules() { - return "jaxx.rules"; - } - - public void setRulesJaxx(String rulesJaxx) { - this.rulesJaxx = rulesJaxx; - } - - @Override - public String extract(String i18nString) { - return i18nString.length() == 0 ? null : i18nString; - } - -} Deleted: trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserSwixatMojo.java =================================================================== --- trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserSwixatMojo.java 2009-12-28 10:27:28 UTC (rev 1690) +++ trunk/maven-i18n-plugin/src/main/java/org/nuiton/i18n/plugin/parser/impl/ParserSwixatMojo.java 2009-12-29 17:35:17 UTC (rev 1691) @@ -1,102 +0,0 @@ -/* - * *##% - * I18n :: Maven Plugin - * Copyright (C) 2007 - 2009 CodeLutin - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * ##%* */ - -package org.nuiton.i18n.plugin.parser.impl; - -import org.nuiton.i18n.plugin.SourceEntry; -import org.nuiton.io.FileUpdater; - -/** - * Recuperation des chaines à traduire depuis les fichiers xml Swixat. - * - * @author julien - * @goal parserSwixat - * @phase generate-resources - * @deprecated since 1.0.0 : swixat is dead... - */ -@Deprecated -public class ParserSwixatMojo extends ParserXmlMojo { - - /** - * Source entries (src+includes) . - * - * @parameter expression="${i18n.defaultIncludes}" default-value="**\/*.xml" - */ - protected String defaultIncludes; - - /** - * Source entries (src+excludes) . - * - * @parameter expression="${i18n.defaultIncludes}" default-value="**\/context.xml" - */ - protected String defaultExcludes; - - /** - * Regles xml. - * - * @parameter expression="${i18n.rulesSwixat}" default-value="swixat.rules" - */ - protected String rulesSwixat; - - @Override - public String[] getDefaultIncludes() { - return new String[]{defaultIncludes}; - } - - @Override - public String[] getDefaultExcludes() { - return new String[]{defaultExcludes}; - } - - @Override - public FileUpdater newFileUpdater(SourceEntry entry) { - return null; - } - - @Override - protected String getKeyModifierStart() { - return "=\\s*[\"\']"; - } - - @Override - protected String getKeyModifierEnd() { - return "[\"\']"; - } - - @Override - protected String getOutGetter() { - return "swixat.getter"; - } - - @Override - protected String getFileRules() { - return rulesSwixat; - } - - @Override - protected String getCoreFileRules() { - return "swixat.rules"; - } - - @Override - public String extract(String i18nString) { - return i18nString; - } -}