Index: lutinprocessor/src/java/org/codelutin/processor/ant/ProcessorTask.java diff -u lutinprocessor/src/java/org/codelutin/processor/ant/ProcessorTask.java:1.5 lutinprocessor/src/java/org/codelutin/processor/ant/ProcessorTask.java:1.6 --- lutinprocessor/src/java/org/codelutin/processor/ant/ProcessorTask.java:1.5 Mon May 10 15:00:59 2004 +++ lutinprocessor/src/java/org/codelutin/processor/ant/ProcessorTask.java Tue Aug 3 16:11:50 2004 @@ -23,10 +23,10 @@ * * @author Benjamin Poussin * Copyright Code Lutin -* @version $Revision: 1.5 $ +* @version $Revision: 1.6 $ * -* Mise a jour: $Date: 2004/05/10 15:00:59 $ -* par : $Author: pineau $ +* Mise a jour: $Date: 2004/08/03 16:11:50 $ +* par : $Author: bpoussin $ */ package org.codelutin.processor.ant; @@ -52,25 +52,22 @@ return filename.replaceAll(fileInPattern, fileOutPattern); } - protected String[] getDestinationFiles(String sourceFile) { - return new String[] { - absoluteDestinationName(applyTransformationFilename(sourceFile))}; - } - protected void doExecute() throws BuildException { Processor processor = new Processor(getFilters()); for (int i = 0; i < files.length; i++) { String inputFileName = absoluteSourceName(files[i]); String outputFileName = absoluteDestinationName(applyTransformationFilename(files[i])); - // creation du repertoire pour le fichier destination - new File(outputFileName).getParentFile().mkdirs(); - try { - processor.process( - new FileReader(inputFileName), - new FileWriter(outputFileName)); - } catch (IOException eee) { - throw new BuildException(eee); + if(overwrite || isNewer(inputFileName, outputFileName)){ + // creation du repertoire pour le fichier destination + new File(outputFileName).getParentFile().mkdirs(); + try { + processor.process( + new FileReader(inputFileName), + new FileWriter(outputFileName)); + } catch (IOException eee) { + throw new BuildException(eee); + } } } } @@ -87,6 +84,11 @@ protected String fileInPattern = ""; protected String fileOutPattern = ""; protected String filters = "org.codelutin.processor.filters.NoActionFilter"; + protected boolean overwrite = true; + + public void setOverwrite(boolean v){ + overwrite = v; + } public void setFileOutPattern(String fileOutPattern) { this.fileOutPattern = fileOutPattern; @@ -113,7 +115,7 @@ Filter[] result = new Filter[filterList.length]; for (int i = 0; i < filterList.length; i++) { try { - // Warning : don't replace that for a Class.forName(...) has it does NOT behave the same way ! + // Warning : don't replace that for a Class.forName(...) has it does NOT behave the same way ! result[i] = (Filter) getClass().forName(filterList[i].trim()).newInstance(); } catch (Exception eee) { @@ -172,29 +174,7 @@ ds.scan(); // on recherche ceux que l'on doit vraiment refaire - String[] tmpfiles = ds.getIncludedFiles(); - ArrayList result = new ArrayList(); - for (int i = 0; i < tmpfiles.length; i++) { - String[] generatedFiles = getDestinationFiles(tmpfiles[i]); - - // si generatedFiles est null alors il faut refaire la generation - boolean todo = generatedFiles == null; - - // des que todo est vrai on peut sortir de la boucle - for (int g = 0; !todo && g < generatedFiles.length; g++) - todo = - todo - || isNewer( - absoluteSourceName(tmpfiles[i]), - generatedFiles[g]); - - // on regenere que si todo est vrai - if (todo) - result.add(tmpfiles[i]); - } - - // on met le resultat dans files - files = (String[]) result.toArray(new String[result.size()]); + files = ds.getIncludedFiles(); } protected boolean isNewer(String filein, String fileout) {