Author: tchemit Date: 2008-07-22 23:06:39 +0000 (Tue, 22 Jul 2008) New Revision: 877 Added: trunk/maven-genclean-plugin/ trunk/maven-genclean-plugin/pom.xml trunk/maven-genclean-plugin/src/ trunk/maven-genclean-plugin/src/main/ trunk/maven-genclean-plugin/src/main/java/ trunk/maven-genclean-plugin/src/main/java/org/ trunk/maven-genclean-plugin/src/main/java/org/codelutin/ trunk/maven-genclean-plugin/src/main/java/org/codelutin/maven/ trunk/maven-genclean-plugin/src/main/java/org/codelutin/maven/plugin/ trunk/maven-genclean-plugin/src/main/java/org/codelutin/maven/plugin/GenCleanMojo.java trunk/maven-genclean-plugin/src/main/resources/ trunk/maven-genclean-plugin/src/main/resources/log4j.properties trunk/maven-genclean-plugin/src/test/ trunk/maven-genclean-plugin/src/test/java/ trunk/maven-genclean-plugin/src/test/resources/ Log: first import of maven-genclean-plugin Added: trunk/maven-genclean-plugin/pom.xml =================================================================== --- trunk/maven-genclean-plugin/pom.xml (rev 0) +++ trunk/maven-genclean-plugin/pom.xml 2008-07-22 23:06:39 UTC (rev 877) @@ -0,0 +1,114 @@ +<?xml version="1.0" encoding="ISO-8859-1"?> +<project + xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 +http://maven.apache.org/maven-v4_0_0.xsd"> + + <modelVersion>4.0.0</modelVersion> + + <!-- ************************************************************* --> + <!-- *** POM Relationships *************************************** --> + <!-- ************************************************************* --> + + <parent> + <groupId>lutinlib</groupId> + <artifactId>lutinproject</artifactId> + <version>2.3</version> + </parent> + + <groupId>org.codelutin.maven.plugin</groupId> + <artifactId>maven-genclean-plugin</artifactId> + <name>maven plugin</name> + + <dependencies> + + <!-- maven plugin project dependencies --> + + <dependency> + <groupId>org.apache.maven</groupId> + <artifactId>maven-plugin-api</artifactId> + <version>2.0.4</version> + </dependency> + + <dependency> + <groupId>org.apache.maven</groupId> + <artifactId>maven-model</artifactId> + <version>2.0.4</version> + </dependency> + + <dependency> + <groupId>org.apache.maven</groupId> + <artifactId>maven-project</artifactId> + <version>2.0.4</version> + </dependency> + + <dependency> + <groupId>org.codehaus.plexus</groupId> + <artifactId>plexus-utils</artifactId> + <version>1.0.5</version> + </dependency> + + </dependencies> + + <!-- ************************************************************* --> + <!-- *** Project Information ************************************* --> + <!-- ************************************************************* --> + + <version>0.1-SNAPSHOT</version> + + <description>Maven 2 plugin to clean generate stuff.</description> + + <inceptionYear>2008</inceptionYear> + + <!-- ************************************************************* --> + <!-- *** Build Settings ****************************************** --> + <!-- ************************************************************* --> + + <packaging>maven-plugin</packaging> + + <properties> <!-- id du projet du labs (lutinutil) --> + + <labs.id>41</labs.id> + <!-- nom du projet du labs --> + + <labs.project>lutinutil</labs.project> + + <!-- compile with ? --> + + <maven.compile.source>1.6</maven.compile.source> + + <maven.compile.target>1.6</maven.compile.target> + <!-- compilation encondig --> + + <maven.compile.encoding>ISO-8859-15</maven.compile.encoding> + <!-- Lists URL --> + <labs.lists> + + http://lists.labs.libre-entreprise.org/mailman/listinfo/lutinutil + + </labs.lists> + <!-- maven will suffix with /${pom.artifactId} /--> + <maven.scm.developerConnection>scm:svn:svn+ssh://${username}@${labs.host}/svnroot/lutinutil/trunk + + </maven.scm.developerConnection> + <!--maven will suffix with /${pom.artifactId} /--> + <maven.scm.connection>scm:svn:svn:anonymous@${labs.host}/svnroot/lutinutil/trunk</maven.scm.connection> + </properties> + <prerequisites> + + <maven>2.0.9</maven> + + </prerequisites> + + <!-- ************************************************************* --> + <!-- **** Build Environment ************************************** --> + <!-- ************************************************************* --> + + <!-- the plugin is a module in a labs project (lutinutil), so we have to override + this property (see in the parent pom for more explanation) --> + <scm> + <url>${maven.scm.url}</url> + </scm> + +</project> Added: trunk/maven-genclean-plugin/src/main/java/org/codelutin/maven/plugin/GenCleanMojo.java =================================================================== --- trunk/maven-genclean-plugin/src/main/java/org/codelutin/maven/plugin/GenCleanMojo.java (rev 0) +++ trunk/maven-genclean-plugin/src/main/java/org/codelutin/maven/plugin/GenCleanMojo.java 2008-07-22 23:06:39 UTC (rev 877) @@ -0,0 +1,101 @@ +/** + * # #% Copyright (C) 2008 Code Lutin, Tony Chemit + * This program is free software; you + * can redistribute it and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; either version 2 + * 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 Public License for more details. You + * should have received a copy of the GNU General Public License along with this + * program; if not, write to the Free Software Foundation, Inc., 59 Temple Place + * - Suite 330, Boston, MA 02111-1307, USA. + * # #% + */ +package org.codelutin.maven.plugin; + +import org.apache.maven.plugin.AbstractMojo; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.MojoFailureException; +import org.apache.maven.project.MavenProject; +import static org.codelutin.i18n.I18n._; + +import java.io.File; + + +/** + * Classe permettant de nettoyer les fichiers g�n�r�s. + * + * @author chemit + * @goal clean + * @phase clean + */ +public abstract class GenCleanMojo extends AbstractMojo { + + /** + * @description D�pendance du projet. + * @parameter default-value="${project}" + * @readonly + */ + protected MavenProject project; + + /** + * @description R�pertoire de destination des fichiers java � g�n�rer. + * @parameter expression="${genclean.genDirectory}" default-value="${basedir}/gen/java" + */ + protected File genDirectory; + + /** + * @description verbose + * @parameter expression="${genclean.verbose}" default-value="${maven.verbose}" + */ + protected boolean verbose; + + + protected abstract void doExecute() throws Exception; + + public void execute() throws MojoExecutionException, MojoFailureException { + + try { + + if (genDirectory.exists()) { + if (verbose) { + getLog().info("delete gen directory " + genDirectory); + } + genDirectory.delete(); + } else { + if (verbose) { + getLog().info("could not find gen directory " + genDirectory); + } + } + + } catch (Exception e) { + getLog().error(e); + Throwable e2 = e; + while (e2.getCause() != null) { + e2 = e.getCause(); + } + getLog().error(e2); + + throw new MojoExecutionException(e.getMessage(), e); + } + + } + + + public File getGenDirectory() { + return genDirectory; + } + + public void setGenDirectory(File genDirectory) { + this.genDirectory = genDirectory; + } + + public boolean isVerbose() { + return verbose; + } + + public void setVerbose(boolean verbose) { + this.verbose = verbose; + } +} \ No newline at end of file Added: trunk/maven-genclean-plugin/src/main/resources/log4j.properties =================================================================== --- trunk/maven-genclean-plugin/src/main/resources/log4j.properties (rev 0) +++ trunk/maven-genclean-plugin/src/main/resources/log4j.properties 2008-07-22 23:06:39 UTC (rev 877) @@ -0,0 +1,9 @@ +# Global logging configuration +log4j.rootLogger=INFO, stdout +# Console output... +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) %M - %m%n + +#log4j.logger.org.codelutin.jaxx=DEBUG +#log4j.logger.jaxx=DEBUG