diff --git a/maven-archetype/maven-archetypes/maven-archetype-mojo/.cvsignore b/maven-archetype/maven-archetypes/maven-archetype-mojo/.cvsignore new file mode 100644 index 0000000000..14201c4fd2 --- /dev/null +++ b/maven-archetype/maven-archetypes/maven-archetype-mojo/.cvsignore @@ -0,0 +1,9 @@ +target +*~ +*.ipr +*.iws +*.iml +*.log +.classpath +.project + diff --git a/maven-archetype/maven-archetypes/maven-archetype-mojo/pom.xml b/maven-archetype/maven-archetypes/maven-archetype-mojo/pom.xml new file mode 100644 index 0000000000..85cc68bbb0 --- /dev/null +++ b/maven-archetype/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-archetype/maven-archetypes/maven-archetype-mojo/src/main/resources/META-INF/archetype.xml b/maven-archetype/maven-archetypes/maven-archetype-mojo/src/main/resources/META-INF/archetype.xml new file mode 100644 index 0000000000..29b98b2428 --- /dev/null +++ b/maven-archetype/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-archetype/maven-archetypes/maven-archetype-mojo/src/main/resources/archetype-resources/pom.xml b/maven-archetype/maven-archetypes/maven-archetype-mojo/src/main/resources/archetype-resources/pom.xml new file mode 100644 index 0000000000..66fc9a8937 --- /dev/null +++ b/maven-archetype/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-archetype/maven-archetypes/maven-archetype-mojo/src/main/resources/archetype-resources/src/main/java/MyMojo.java b/maven-archetype/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-archetype/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(); + } +}