Initial revision

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@163607 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jason van Zyl 2005-03-18 06:41:16 +00:00
parent df6e78a104
commit a53bf28c86
5 changed files with 121 additions and 0 deletions

View File

@ -0,0 +1,9 @@
target
*~
*.ipr
*.iws
*.iml
*.log
.classpath
.project

View File

@ -0,0 +1,12 @@
<model>
<parent>
<artifactId>maven-archetypes</artifactId>
<groupId>maven</groupId>
<version>1.0-alpha-1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>maven</groupId>
<artifactId>maven-archetype-mojo</artifactId>
<packaging>jar</packaging>
<version>1.0-alpha-1-SNAPSHOT</version>
</model>

View File

@ -0,0 +1,6 @@
<archetype>
<id>plugin</id>
<sources>
<source>src/main/java/MyMojo.java</source>
</sources>
</archetype>

View File

@ -0,0 +1,16 @@
<model>
<modelVersion>4.0.0</modelVersion>
<groupId>${groupId}</groupId>
<artifactId>${artifactId}</artifactId>
<packaging>jar</packaging>
<version>${version}</version>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
</dependencies>
</model>

View File

@ -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();
}
}