From b2d8f801a2a8465f7825d3a5d26be7106e4d35cf Mon Sep 17 00:00:00 2001 From: Jason van Zyl Date: Thu, 17 Mar 2005 03:43:27 +0000 Subject: [PATCH] Initial revision git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@163592 13f79535-47bb-0310-9956-ffa450edef68 --- .../maven-archetype-mojo/.cvsignore | 9 +++ maven-archetypes/maven-archetype-mojo/pom.xml | 12 +++ .../src/main/resources/META-INF/archetype.xml | 6 ++ .../resources/archetype-resources/pom.xml | 16 ++++ .../src/main/java/MyMojo.java | 78 +++++++++++++++++++ 5 files changed, 121 insertions(+) create mode 100644 maven-archetypes/maven-archetype-mojo/.cvsignore create mode 100644 maven-archetypes/maven-archetype-mojo/pom.xml create mode 100644 maven-archetypes/maven-archetype-mojo/src/main/resources/META-INF/archetype.xml create mode 100644 maven-archetypes/maven-archetype-mojo/src/main/resources/archetype-resources/pom.xml create mode 100644 maven-archetypes/maven-archetype-mojo/src/main/resources/archetype-resources/src/main/java/MyMojo.java diff --git a/maven-archetypes/maven-archetype-mojo/.cvsignore b/maven-archetypes/maven-archetype-mojo/.cvsignore new file mode 100644 index 0000000000..14201c4fd2 --- /dev/null +++ b/maven-archetypes/maven-archetype-mojo/.cvsignore @@ -0,0 +1,9 @@ +target +*~ +*.ipr +*.iws +*.iml +*.log +.classpath +.project + diff --git a/maven-archetypes/maven-archetype-mojo/pom.xml b/maven-archetypes/maven-archetype-mojo/pom.xml new file mode 100644 index 0000000000..85cc68bbb0 --- /dev/null +++ b/maven-archetypes/maven-archetype-mojo/pom.xml @@ -0,0 +1,12 @@ + + + maven-archetypes + maven + 1.0-alpha-1-SNAPSHOT + + 4.0.0 + maven + maven-archetype-mojo + jar + 1.0-alpha-1-SNAPSHOT + diff --git a/maven-archetypes/maven-archetype-mojo/src/main/resources/META-INF/archetype.xml b/maven-archetypes/maven-archetype-mojo/src/main/resources/META-INF/archetype.xml new file mode 100644 index 0000000000..29b98b2428 --- /dev/null +++ b/maven-archetypes/maven-archetype-mojo/src/main/resources/META-INF/archetype.xml @@ -0,0 +1,6 @@ + + plugin + + src/main/java/MyMojo.java + + diff --git a/maven-archetypes/maven-archetype-mojo/src/main/resources/archetype-resources/pom.xml b/maven-archetypes/maven-archetype-mojo/src/main/resources/archetype-resources/pom.xml new file mode 100644 index 0000000000..66fc9a8937 --- /dev/null +++ b/maven-archetypes/maven-archetype-mojo/src/main/resources/archetype-resources/pom.xml @@ -0,0 +1,16 @@ + + 4.0.0 + ${groupId} + ${artifactId} + jar + ${version} + + + junit + junit + 3.8.1 + jar + compile + + + diff --git a/maven-archetypes/maven-archetype-mojo/src/main/resources/archetype-resources/src/main/java/MyMojo.java b/maven-archetypes/maven-archetype-mojo/src/main/resources/archetype-resources/src/main/java/MyMojo.java new file mode 100644 index 0000000000..1bc102f323 --- /dev/null +++ b/maven-archetypes/maven-archetype-mojo/src/main/resources/archetype-resources/src/main/java/MyMojo.java @@ -0,0 +1,78 @@ +package $package; + +import org.apache.maven.plugin.AbstractPlugin; +import org.apache.maven.plugin.PluginExecutionRequest; +import org.apache.maven.plugin.PluginExecutionResponse; + +import java.io.File; +import java.io.FileWriter; + +/** + * @goal touch + * + * @phase process-sources + * + * @description Goal which cleans the build + * + * @parameter + * name="outputDirectory" + * type="String" + * required="true" + * validator="" + * expression="#project.build.directory" + * description="" + * + * @parameter + * name="basedirAlignmentDirectory" + * type="java.io.File" + * required="true" + * validator="" + * expression="target/test-basedir-alignment" + * description="" + */ +public class MyMojo + extends AbstractPlugin +{ + private static final int DELETE_RETRY_SLEEP_MILLIS = 10; + + public void execute( PluginExecutionRequest request, PluginExecutionResponse response ) + throws Exception + { + String outputDirectory = (String) request.getParameter( "outputDirectory" ); + + File f = new File( outputDirectory ); + + if ( !f.exists() ) + { + f.mkdirs(); + } + + File touch = new File( f, "touch.txt" ); + + FileWriter w = new FileWriter( touch ); + + w.write( "touch.txt" ); + + w.close(); + + // This parameter should be aligned to the basedir as the parameter type is specified + // as java.io.File + + String basedirAlignmentDirectory = (String) request.getParameter( "basedirAlignmentDirectory" ); + + f = new File( basedirAlignmentDirectory ); + + if ( !f.exists() ) + { + f.mkdirs(); + } + + touch = new File( f, "touch.txt" ); + + w = new FileWriter( touch ); + + w.write( "touch.txt" ); + + w.close(); + } +}