Index: maven-i18n-plugin/src/java/org/codelutin/i18n/plugin/extension/ParserXml.java diff -u maven-i18n-plugin/src/java/org/codelutin/i18n/plugin/extension/ParserXml.java:1.3 maven-i18n-plugin/src/java/org/codelutin/i18n/plugin/extension/ParserXml.java:1.4 --- maven-i18n-plugin/src/java/org/codelutin/i18n/plugin/extension/ParserXml.java:1.3 Fri Nov 2 15:02:59 2007 +++ maven-i18n-plugin/src/java/org/codelutin/i18n/plugin/extension/ParserXml.java Fri Nov 2 15:20:04 2007 @@ -112,6 +112,8 @@ InputSource inputSource = new InputSource(file.getAbsolutePath()); // TODO: A déplacer pour les performances try { + int size = result.size(); + // Recherche des clés à partir d'un xpath XPathExpression expression = xpath.compile(rules); list = (NodeList) expression.evaluate(inputSource, XPathConstants.NODESET); @@ -121,9 +123,11 @@ parseLine(file, node.getTextContent()); } - // Sauvegarde dans le fichier de sortie - OutputStream xmlparserOut = new FileOutputStream(out.getAbsolutePath() + File.separatorChar + outGetter); - result.store(xmlparserOut, null); + // Détection de nouvelles clés, sauvegarde du fichier pour pouvoir le restaurer en cas de plantage + if(size != result.size()) { + OutputStream xmlparserOut = new FileOutputStream(out.getAbsolutePath() + File.separatorChar + outGetter); + result.store(xmlparserOut, null); + } } catch (Exception e) { throw new ParserException(e); } Index: maven-i18n-plugin/src/java/org/codelutin/i18n/plugin/extension/ParserJava.java diff -u maven-i18n-plugin/src/java/org/codelutin/i18n/plugin/extension/ParserJava.java:1.3 maven-i18n-plugin/src/java/org/codelutin/i18n/plugin/extension/ParserJava.java:1.4 --- maven-i18n-plugin/src/java/org/codelutin/i18n/plugin/extension/ParserJava.java:1.3 Fri Nov 2 15:02:59 2007 +++ maven-i18n-plugin/src/java/org/codelutin/i18n/plugin/extension/ParserJava.java Fri Nov 2 15:20:04 2007 @@ -23,9 +23,9 @@ * Created: Aug 16, 2004 * * @author Cédric Pineau - * @version $Revision: 1.3 $ + * @version $Revision: 1.4 $ * - * Last update : $Date: 2007-11-02 15:02:59 $ + * Last update : $Date: 2007-11-02 15:20:04 $ * by : $Author: ruchaud $ */ @@ -131,14 +131,19 @@ */ public void parseFile(File srcFile) { try { + int size = result.size(); + LineNumberReader lnr = new LineNumberReader(new InputStreamReader(new FileInputStream(srcFile))); while (lnr.ready()) { String line = lnr.readLine(); parseLine(srcFile, line); } - OutputStream xmlparserOut = new FileOutputStream(out.getAbsolutePath() + File.separatorChar + "java.getter"); - result.store(xmlparserOut, null); + // Détection de nouvelles clés, sauvegarde du fichier pour pouvoir le restaurer en cas de plantage + if(size != result.size()) { + OutputStream xmlparserOut = new FileOutputStream(out.getAbsolutePath() + File.separatorChar + "java.getter"); + result.store(xmlparserOut, null); + } } catch (Exception e) { throw new ParserException(e); }