[Lutinprocessor-commits] r208 - in nuitonprocessor/trunk: . src/main/java/org/nuiton/processor src/main/java/org/nuiton/processor/ant src/site
Author: tchemit Date: 2009-05-13 20:09:46 +0000 (Wed, 13 May 2009) New Revision: 208 Added: nuitonprocessor/trunk/src/main/java/org/nuiton/processor/ProcessorUtil.java Modified: nuitonprocessor/trunk/pom.xml nuitonprocessor/trunk/src/main/java/org/nuiton/processor/ant/ProcessorTask.java nuitonprocessor/trunk/src/site/site.xml Log: processor migrated to nuiton :) refactor processor plugin : no more used of AntTask todo remove from nuitonprocessor the Ant Taskes (at least put them in the plugin) Modified: nuitonprocessor/trunk/pom.xml =================================================================== --- nuitonprocessor/trunk/pom.xml 2009-05-13 20:09:31 UTC (rev 207) +++ nuitonprocessor/trunk/pom.xml 2009-05-13 20:09:46 UTC (rev 208) @@ -136,23 +136,7 @@ <build> <plugins> - <plugin> - <groupId>org.nuiton</groupId> - <artifactId>maven-helper-plugin</artifactId> - <version>${helper.version}</version> - <executions> - <execution> - <id>attach-licenses</id> - <goals> - <goal>add-license</goal> - <goal>add-third-party</goal> - </goals> - </execution> - </executions> - </plugin> - - <plugin> <artifactId>maven-assembly-plugin</artifactId> <executions> <execution> Added: nuitonprocessor/trunk/src/main/java/org/nuiton/processor/ProcessorUtil.java =================================================================== --- nuitonprocessor/trunk/src/main/java/org/nuiton/processor/ProcessorUtil.java (rev 0) +++ nuitonprocessor/trunk/src/main/java/org/nuiton/processor/ProcessorUtil.java 2009-05-13 20:09:46 UTC (rev 208) @@ -0,0 +1,53 @@ +package org.nuiton.processor; + +import org.nuiton.processor.filters.Filter; + +/** + * Utilities methods. + * + * @author chemit + * @since 1.0.0.0 + */ +public class ProcessorUtil { + + /** + * Instanciate a new {@link Processor} given an array of filters given by + * their FQN separated by the given separator. + * + * @param filters the string representionf of the filters + * @param separator the separator of filter + * @return the instanciated processor + * @throws java.lang.Exception if any pb + */ + public static Processor newProcessor(String filters, String separator) throws Exception { + Filter[] result = getFilters(filters, separator); + Processor processor = new Processor(result); + return processor; + } + + /** + * Instanciate a array of filters given by thier FQN separated by the + * given separator. + * + * @param filters the list of filters separated by the given separator + * @param separator filter separator + * @return the array of instanciated filters. + * + * @throws java.lang.Exception if any pb + */ + public static Filter[] getFilters(String filters, String separator) throws Exception { + String[] filterList = filters.split(separator); + Filter[] result = new Filter[filterList.length]; + for (int i = 0; i < filterList.length; i++) { + + try { + // Class.forName semble fonctionner maintenant + // avant il fallait utiliser getClass().forName + result[i] = (Filter) Class.forName(filterList[i].trim()).newInstance(); + } catch (Exception eee) { + throw new IllegalArgumentException("Error during looking for '" + filterList[i].trim() + "' class", eee); + } + } + return result; + } +} Modified: nuitonprocessor/trunk/src/main/java/org/nuiton/processor/ant/ProcessorTask.java =================================================================== --- nuitonprocessor/trunk/src/main/java/org/nuiton/processor/ant/ProcessorTask.java 2009-05-13 20:09:31 UTC (rev 207) +++ nuitonprocessor/trunk/src/main/java/org/nuiton/processor/ant/ProcessorTask.java 2009-05-13 20:09:46 UTC (rev 208) @@ -16,19 +16,18 @@ * License along with this program. If not, see * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%* */ - package org.nuiton.processor.ant; import java.io.File; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.taskdefs.MatchingTask; import org.nuiton.processor.Processor; -import org.nuiton.processor.filters.Filter; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import org.apache.tools.ant.DirectoryScanner; import org.apache.tools.ant.Project; +import org.nuiton.processor.ProcessorUtil; /** * Tache ant pour lutinprocessor. @@ -53,29 +52,18 @@ public class ProcessorTask extends MatchingTask { // ProcessorTask public static final int MSG_VERBOSE = Project.MSG_VERBOSE; - protected File srcDir; - protected File destDir; - - protected String[] includes = new String[] {}; - - protected String[] excludes = new String[] {}; - + protected String[] includes = new String[]{}; + protected String[] excludes = new String[]{}; protected String[] files; - protected String fileInPattern = ""; - protected String fileOutPattern = ""; - protected String filters = "org.codelutin.processor.filters.NoActionFilter"; - protected boolean overwrite = true; - protected boolean verbose = false; public ProcessorTask() { - } public void setVerbose(boolean verbose) { @@ -111,7 +99,13 @@ } protected void doExecute() throws BuildException { - Processor processor = new Processor(getFilters()); + Processor processor=null; + try { + processor = ProcessorUtil.newProcessor(this.filters, ","); + } catch (Exception ex) { + throw new BuildException("Could nto instanciate processor for reason : "+ex.getMessage(), ex); + } +// Processor processor = new Processor(getFilters()); int numberFiles; for (numberFiles = 0; numberFiles < files.length; numberFiles++) { String inputFileName = absoluteSourceName(files[numberFiles]); @@ -136,22 +130,28 @@ log("Generating " + numberFiles + " files to " + destDir); } - protected Filter[] getFilters() throws BuildException { - String[] filterList = filters.split(","); - Filter[] result = new Filter[filterList.length]; - for (int i = 0; i < filterList.length; i++) { - try { - // Class.forName semble fonctionner maintenant - // avant il fallait utiliser getClass().forName - result[i] = (Filter) Class.forName(filterList[i].trim()) - .newInstance(); - } catch (Exception eee) { - throw new BuildException("Error during looking for '" - + filterList[i].trim() + "' class", eee); - } - } - return result; - } +// protected Filter[] getFilters() throws BuildException { +// Filter[] result; +// try { +// result = ProcessorUtil.getFilters(filters, ","); +// } catch (Exception eee) { +// throw new BuildException(eee.getMessage(), eee); +// } +//// String[] filterList = filters.split(","); +//// Filter[] result = new Filter[filterList.length]; +//// for (int i = 0; i < filterList.length; i++) { +//// try { +//// // Class.forName semble fonctionner maintenant +//// // avant il fallait utiliser getClass().forName +//// result[i] = (Filter) Class.forName(filterList[i].trim()) +//// .newInstance(); +//// } catch (Exception eee) { +//// throw new BuildException("Error during looking for '" +//// + filterList[i].trim() + "' class", eee); +//// } +//// } +// return result; +// } @Override public void execute() throws BuildException { @@ -161,16 +161,14 @@ getLocation()); } if (!srcDir.exists()) { - throw new BuildException("srcdir \"" + srcDir.getPath() - + "\" does not exist!", getLocation()); + throw new BuildException("srcdir \"" + srcDir.getPath() + "\" does not exist!", getLocation()); } if (destDir == null) { destDir = srcDir; } if (!destDir.isDirectory()) { - throw new BuildException("destination directory \"" + destDir - + "\" does not exist or is not a directory", getLocation()); + throw new BuildException("destination directory \"" + destDir + "\" does not exist or is not a directory", getLocation()); } // Build the list of files to compute @@ -193,7 +191,7 @@ if (excludes.length > 0) { ds.setExcludes(excludes); } - + ds.scan(); // on recherche ceux que l'on doit vraiment refaire @@ -201,8 +199,7 @@ } protected boolean isNewer(String filein, String fileout) { - boolean result = new File(filein).lastModified() > new File(fileout) - .lastModified(); + boolean result = new File(filein).lastModified() > new File(fileout).lastModified(); if (result) { log(filein + " is newer than " + fileout, MSG_VERBOSE); } @@ -242,5 +239,4 @@ protected String absoluteSourceName(String fileName) { return srcDir.getPath() + File.separator + fileName; } - } // ProcessorTask Modified: nuitonprocessor/trunk/src/site/site.xml =================================================================== --- nuitonprocessor/trunk/src/site/site.xml 2009-05-13 20:09:31 UTC (rev 207) +++ nuitonprocessor/trunk/src/site/site.xml 2009-05-13 20:09:46 UTC (rev 208) @@ -28,12 +28,13 @@ <links> <item name="Maven-processor-plugin" href="http://lutinprocessor.labs.libre-entreprise.org/maven-processor-plugin/"/> <item name="Labs" href="http://labs.libre-entreprise.org/"/> + <item name="Nuiton" href="http://www.nuiton.org"/> <item name="${project.organization.name}" href="${project.organization.url}"/> </links> <menu name="Utilisateur"> <item href="/index.html" name="Accueil"/> - <item href="http://lutinbuilder.labs.libre-entreprise.org/maven2/org/codelutin/${project.artifactId}/" name="Téléchargement"/> + </menu> <menu name="Téléchargement"> @@ -43,6 +44,10 @@ name="Javadoc (jar)"/> <item href="${repository.home.url}/org/nuiton/${project.artifactId}/${project.version}/${project.build.finalName}-sources.jar" name="Sources (jar)"/> + <item href="${repository.home.url}/org/nuiton/${project.artifactId}/${project.version}/${project.build.finalName}-deps.zip" + name="Bundle sans sources (zip)"/> + <item href="${repository.home.url}/org/nuiton/${project.artifactId}/${project.version}/${project.build.finalName}-full.zip" + name="Bundle complêt (zip)"/> </menu> <menu name="Developpeur">
participants (1)
-
tchemit@users.labs.libre-entreprise.org