Author: tchemit Date: 2009-05-13 20:09:31 +0000 (Wed, 13 May 2009) New Revision: 207 Added: maven-processor-plugin/trunk/src/main/java/org/nuiton/processor/ maven-processor-plugin/trunk/src/main/java/org/nuiton/processor/plugin/ maven-processor-plugin/trunk/src/main/java/org/nuiton/processor/plugin/ProcessorPlugin.java Modified: maven-processor-plugin/trunk/pom.xml maven-processor-plugin/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: maven-processor-plugin/trunk/pom.xml =================================================================== --- maven-processor-plugin/trunk/pom.xml 2009-05-13 20:09:14 UTC (rev 206) +++ maven-processor-plugin/trunk/pom.xml 2009-05-13 20:09:31 UTC (rev 207) @@ -11,28 +11,56 @@ <groupId>org.codelutin</groupId> <artifactId>lutinproject</artifactId> <version>3.5.4</version> + <!--groupId>org.nuiton</groupId> + <artifactId>mavenpom</artifactId> + <version>1.0.0-SNAPSHOT</version--> </parent> + <groupId>org.nuiton</groupId> + <artifactId>maven-processor-plugin</artifactId> <version>1.0.0-SNAPSHOT</version> <dependencies> <dependency> - <groupId>org.codelutin</groupId> - <artifactId>lutinprocessor</artifactId> - <version>0.18</version> + <groupId>org.nuiton</groupId> + <artifactId>nuitonprocessor</artifactId> + <version>${processor.version}</version> <scope>compile</scope> </dependency> <dependency> - <groupId>org.codelutin</groupId> - <artifactId>lutinpluginutil</artifactId> - <version>0.5</version> + <groupId>org.nuiton</groupId> + <artifactId>maven-helper-plugin</artifactId> + <version>${helper.version}</version> <scope>compile</scope> </dependency> <dependency> + <groupId>org.codehaus.plexus</groupId> + <artifactId>plexus-utils</artifactId> + <version>1.5.5</version> + </dependency> + + <!-- tests dependencies --> + + <dependency> + <groupId>org.nuiton</groupId> + <artifactId>maven-helper-plugin</artifactId> + <version>${helper.version}</version> + <scope>test</scope> + <classifier>tests</classifier> + </dependency> + + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.6</version> + <scope>test</scope> + </dependency> + + <dependency> <groupId>org.apache.maven</groupId> <artifactId>maven-plugin-api</artifactId> <version>${maven.version}</version> @@ -46,19 +74,19 @@ <scope>provided</scope> </dependency> - <dependency> + <!--dependency> <groupId>org.apache.ant</groupId> <artifactId>ant</artifactId> <version>1.7.1</version> <scope>compile</scope> - </dependency> + </dependency--> </dependencies> <!-- ************************************************************* --> <!-- *** Project Information ************************************* --> <!-- ************************************************************* --> - <name>Plugin maven Lutin Processor</name> + <name>Plugin maven Nuiton Processor</name> <inceptionYear>2006</inceptionYear> <!--who the developers are for the project--> @@ -81,11 +109,18 @@ <packaging>maven-plugin</packaging> <properties> - + + <redmine.project>nuitonutil</redmine.project> + <processor.version>1.0.0-SNAPSHOT</processor.version> + + <!-- assuprimer du de l'utilisation de mavenpom --> <labs.id>28</labs.id> <labs.project>lutinprocessor</labs.project> - <maven.version>2.0.10</maven.version> + <helper.version>1.0.0-SNAPSHOT</helper.version> + <helper.licenseName>lgpl_v3</helper.licenseName> + <site.home.url>http://lutinprocessor.labs.libre-entreprise.org</site.home.url> + <repository.home.url>http://lutinbuilder.labs.libre-entreprise.org/maven2</repository.home.url> </properties> <build> @@ -133,7 +168,6 @@ <!--Site--> <reporting> <plugins> - <!--Site report's plugin--> <plugin> <artifactId>maven-plugin-plugin</artifactId> <version>2.5</version> @@ -146,6 +180,7 @@ <!-- ************************************************************* --> <!--Source control management--> + <!-- a supprimer au passage a mavenpom --> <scm> <url>${maven.scm.url}</url> <connection>${maven.scm.connection}</connection> @@ -169,36 +204,4 @@ </repository> </repositories> - <profiles> - <!-- perform only on a release stage when using the maven-release-plugin --> - <profile> - <id>release-profile</id> - <activation> - <property> - <name>performRelease</name> - <value>true</value> - </property> - </activation> - <build> - <plugins> - <!-- always add license and third-party files to classpath --> - <plugin> - <groupId>org.codelutin</groupId> - <artifactId>maven-license-switcher-plugin</artifactId> - <version>0.8</version> - <executions> - <execution> - <id>attach-licenses</id> - <goals> - <goal>license</goal> - <goal>third-party</goal> - </goals> - </execution> - </executions> - </plugin> - </plugins> - </build> - </profile> - </profiles> - </project> Copied: maven-processor-plugin/trunk/src/main/java/org/nuiton/processor/plugin/ProcessorPlugin.java (from rev 204, maven-processor-plugin/trunk/src/main/java/org/codelutin/processor/plugin/ProcessorPlugin.java) =================================================================== --- maven-processor-plugin/trunk/src/main/java/org/nuiton/processor/plugin/ProcessorPlugin.java (rev 0) +++ maven-processor-plugin/trunk/src/main/java/org/nuiton/processor/plugin/ProcessorPlugin.java 2009-05-13 20:09:31 UTC (rev 207) @@ -0,0 +1,274 @@ +/* *##% Plugin maven Lutin Processor + * Copyright (C) 2006 - 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.processor.plugin; + +import java.io.File; +import java.io.FileReader; +import java.io.FileWriter; +import java.util.Map; +import java.util.Map.Entry; +import org.apache.maven.project.MavenProject; +import org.nuiton.AbstractPlugin; +import org.nuiton.processor.Processor; +import org.nuiton.processor.ProcessorUtil; +import org.nuiton.util.MirroredFileUpdater; + +/** + * Maven2 plugin for Nuiton Processor. + * + * Created: 14 avril 2006 + * + * @author ruchaud + * @version $Revision$ + * + * Last update: $Date$ + * by : $Author$ + * + * @goal process + * @requiresProject true + */ +public class ProcessorPlugin extends AbstractPlugin { + + /** + * Dependance du projet. + * + * @parameter default-value="${project}" + * @required + * @since 1.0.0 + */ + protected MavenProject project; + /** + * Répertoire source + * + * @parameter expression="${processor.srcDir}" default-value="${basedir}/src/main/java" + * @since 0.10 + */ + protected File srcDir; + /** + * Répertoire cible + * + * @parameter expression="${processor.destDir}" default-value="${basedir}/target/processed-sources/java" + * @since 0.10 + */ + protected File destDir; + /** + * Fichiers à inclure. + * + * Il s'agit des expressions séparées par des virgules. + * + * Exemple : + * + * *.java,*.xml + * + * @parameter expression="${processor.includes}" + * @since 0.10 + */ + protected String includes; + /** + * Fichiers à exclure. + * + * Il s'agit des expressions spérarées par des virgules. + * + * Exemple : + * + * *.java,*.xml + * + * @parameter expression="${processor.excludes}" + * @since 0.10 + */ + protected String excludes; + /** + * ??? + * @parameter expression="${processor.fileInPattern}" default-value="" + * @since 0.10 + */ + protected String fileInPattern=""; + /** + * @parameter expression="${processor.fileOutPattern}" default-value="" + * @since 0.10 + */ + protected String fileOutPattern=""; + /** + * Les filtres a utiliser par le processor, séparés par des virgules + * + * @parameter expression="${processor.filters}" default-value="org.nuiton.processor.filters.NoActionFilter" + * @since 0.10 + */ + protected String filters; + /** + * Ecrase les fichiers générés + * + * @parameter expression="${processor.overwrite}" default-value="false" + * @since 0.10 + */ + private boolean overwrite; + /** + * Permet d'obtenir plus d'information + * + * @parameter expression="${processor.verbose}" default-value="${maven.verbose}" + * @since 0.10 + */ + private boolean verbose; +// /** +// * Flag pour indiquer si on doit ajouter le repertoire de generation dans les répertoires +// * de compilation du project Maven Nom par défaut du paquetage généré +// * <p/> +// * TODO Ce flag doit disparaitre dans la prochaine release (uniquement utilisée pour compatibilité) +// * +// * @parameter expression="${processor.addCompileDirectory}" default-value="false" +// * @since 0.16 +// */ +// protected boolean addCompileDirectory; + protected Map<String, String> filesToTreate; + + public ProcessorPlugin() { + super("all files are up-to-date."); + } + + @Override + public boolean isVerbose() { + return verbose; + } + + @Override + public void setVerbose(boolean verbose) { + this.verbose = verbose; + } + + @Override + protected boolean ensurePackaging() { + return false; + } + + @Override + public MavenProject getProject() { + return project; + } + + @Override + public void setProject(MavenProject project) { + this.project = project; + } + + @Override + protected boolean init() throws Exception { + + boolean doGenerate = filters.length() > 0; + + if (doGenerate) { + + MirroredFileUpdater updater = overwrite ? null : new MirroredFileUpdater(fileInPattern, fileOutPattern, srcDir, destDir); + + updater.setDestinationDirectory(destDir); + String[] aIncludes = includes.split(","); + String[] aExcludes = excludes == null ? null : excludes.split(","); + + filesToTreate = getFilesToTreate(aIncludes, aExcludes, srcDir, updater); + + doGenerate = !filesToTreate.isEmpty(); + } + + return doGenerate; + } + + @Override + protected void doAction() throws Exception { + + + Processor processor = ProcessorUtil.newProcessor(filters, ","); + + for (Entry<String, String> entry : filesToTreate.entrySet()) { + File srcFile = new File(srcDir, entry.getKey()); + File dstFile = new File(entry.getValue()); + + // creation du repertoire pour le fichier destination + dstFile.getParentFile().mkdirs(); + + processor.process(new FileReader(srcFile), new FileWriter(dstFile)); + } + + removeCompileSourceRoots(srcDir); + addCompileSourceRoots(destDir); + } +// @Override +// public void execute() throws MojoExecutionException { +// getLog().info("Génération des fichiers à partir de lutin processor"); +// +// /* Création d'un projet ant */ +// Project antProject = new Project(); +// +// BuildLogger logger = new NoBannerLogger(); +// logger.setMessageOutputLevel(org.apache.tools.ant.Project.MSG_INFO); +// logger.setOutputPrintStream(System.out); +// logger.setErrorPrintStream(System.err); +// +// antProject.init(); +// antProject.getBaseDir(); +// antProject.addBuildListener(logger); +// +// /* Création de la tâche ant ProcessorTask */ +// ProcessorTask processor = new ProcessorTask(); +// processor.setProject(antProject); +// processor.setTaskName("Processor"); +// +// if (verbose) { +// getLog().info("srcDir is " + srcDir); +// getLog().info("destDir is " + destDir); +// } +// +// /* Configuration */ +// processor.setVerbose(verbose); +// processor.setSrcdir(srcDir); +// destDir.mkdirs(); +// processor.setDestdir(destDir); +// +// processor.setFileInPattern(fileInPattern); +// processor.setFileOutPattern(fileOutPattern); +// +// processor.setIncludes(includes); +// processor.setExcludes(excludes); +// +// processor.setFilters(filters); +// +// processor.setOverwrite(overwrite); +// +// /* Execution */ +// processor.execute(); +// +// if (addCompileDirectory) { +// fixCompileSourceRoots(); +// } +// } +// /** +// * permet d'ajout le répertoire de génération des fichiers java dans les répertoires +// * de compilation du projet Maven. +// */ +// protected void fixCompileSourceRoots() { +// if (project.getCompileSourceRoots().contains(srcDir.getPath())) { +// if (verbose) { +// getLog().info("srcDir found in compileSourceRoots, removing : " + srcDir.getPath()); +// } +// project.getCompileSourceRoots().remove(srcDir.getPath()); +// } +// if (!project.getCompileSourceRoots().contains(destDir.getPath())) { +// if (verbose) { +// getLog().info("destDir not found in compileSourceRoots, adding : " + destDir.getPath()); +// } +// project.addCompileSourceRoot(destDir.getPath()); +// } +// } +} Property changes on: maven-processor-plugin/trunk/src/main/java/org/nuiton/processor/plugin/ProcessorPlugin.java ___________________________________________________________________ Name: svn:keywords + Author Date Id Revision Name: svn:mergeinfo + Name: svn:eol-style + native Modified: maven-processor-plugin/trunk/src/site/site.xml =================================================================== --- maven-processor-plugin/trunk/src/site/site.xml 2009-05-13 20:09:14 UTC (rev 206) +++ maven-processor-plugin/trunk/src/site/site.xml 2009-05-13 20:09:31 UTC (rev 207) @@ -28,6 +28,7 @@ <links> <item name="LutinProcessor" href="http://lutinprocessor.labs.libre-entreprise.org/"/> <item name="Labs" href="http://labs.libre-entreprise.org/"/> + <item name="Nuiton" href="http://www.nuiton.org"/> <item name="Code Lutin" href="http://www.codelutin.com/"/> </links> @@ -40,11 +41,11 @@ </menu> <menu name="Téléchargement"> - <item href="${labs.builder.url}/org/codelutin/${project.artifactId}/${project.version}/${project.build.finalName}.jar" + <item href="${repository.home.url}/org/nuiton/${project.artifactId}/${project.version}/${project.build.finalName}.jar" name="Librairie (jar)"/> - <item href="${labs.builder.url}/org/codelutin/${project.artifactId}/${project.version}/${project.build.finalName}-javadoc.jar" + <item href="${repository.home.url}/org/nuiton/${project.artifactId}/${project.version}/${project.build.finalName}-javadoc.jar" name="Javadoc (jar)"/> - <item href="${labs.builder.url}/org/codelutin/${project.artifactId}/${project.version}/${project.build.finalName}-sources.jar" + <item href="${repository.home.url}/org/nuiton/${project.artifactId}/${project.version}/${project.build.finalName}-sources.jar" name="Sources (jar)"/> </menu>