Author: tchemit Date: 2008-07-21 01:03:32 +0000 (Mon, 21 Jul 2008) New Revision: 746 Modified: trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/ActionGeneratorGoal.java Log: copy generated file also to classpath to make possible to have it at next launch with no resources:resources goal needed Modified: trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/ActionGeneratorGoal.java =================================================================== --- trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/ActionGeneratorGoal.java 2008-07-21 00:25:38 UTC (rev 745) +++ trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/ActionGeneratorGoal.java 2008-07-21 01:03:32 UTC (rev 746) @@ -30,6 +30,7 @@ import org.codelutin.jaxx.action.ActionConfig; import org.codelutin.jaxx.action.SelectActionConfig; import org.codelutin.jaxx.action.ToggleActionConfig; +import org.codelutin.util.FileUtil; import org.codelutin.util.SortedProperties; import java.io.File; @@ -65,6 +66,12 @@ /** * @description Nom du fichier destination � g�n�rer. + * @parameter expression="${jaxx.baseResource}" default-value="${basedir}/src/main/resources" + */ + protected File baseResource; + + /** + * @description Nom du fichier destination � g�n�rer. * @parameter expression="${jaxx.out}" default-value="${basedir}/src/main/resources/jaxx/${project.artifactId}-actions.properties" */ protected File out; @@ -94,6 +101,13 @@ */ protected boolean verbose; + /** + * @description flag to copy generated file to cp + * @parameter expression="${jaxx.copyToCP}" default-value="false" + */ + protected boolean copyToCP; + + protected String[] files; private static final String[] INCLUDES = {"**\\/*.java"}; @@ -118,23 +132,6 @@ } - protected void saveProperties(Properties result) throws IOException { - OutputStream writer = null; - try { - writer = new org.codelutin.util.PropertiesDateRemoveFilterStream(new java.io.FileOutputStream(out)); - - result.store(writer, null); - - } finally { - if (writer != null) { - - writer.flush(); - writer.close(); - - } - } - } - protected Properties loadProperties() { Properties result = new SortedProperties(); for (String file : files) { @@ -205,6 +202,42 @@ return result; } + protected void saveProperties(Properties result) throws IOException { + OutputStream writer = null; + File parent = out.getParentFile(); + if (!parent.exists()) { + parent.mkdirs(); + } + try { + writer = new org.codelutin.util.PropertiesDateRemoveFilterStream(new java.io.FileOutputStream(out)); + + result.store(writer, null); + + + } finally { + if (writer != null) { + + writer.flush(); + writer.close(); + + } + } + + if (copyToCP) { + // save it also in classes + String path = out.getAbsolutePath().substring(baseResource.getAbsolutePath().length() + 1); + File compiledFile = new File(cp, path); + if (getLog().isDebugEnabled()) { + getLog().debug("copy to classapth generated file " + compiledFile); + } + parent = compiledFile.getParentFile(); + if (!parent.exists()) { + parent.mkdirs(); + } + FileUtil.copy(out, compiledFile); + } + } + public File getSrc() { return src; }