diff --git a/maven-plugins/maven-plugin-plugin/pom.xml b/maven-plugins/maven-plugin-plugin/pom.xml index 942c1ed413..4bc8cd66de 100644 --- a/maven-plugins/maven-plugin-plugin/pom.xml +++ b/maven-plugins/maven-plugin-plugin/pom.xml @@ -8,8 +8,18 @@ maven-plugin-plugin maven-plugin-plugin + plugin Maven 1.0-SNAPSHOT 2001 - org.apache.maven + org.apache.maven.plugin.plugin + + + + maven + maven-core + 2.0-SNAPSHOT + + + diff --git a/maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/AbstractGeneratorMojo.java b/maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/AbstractGeneratorMojo.java new file mode 100644 index 0000000000..e7f610bd4e --- /dev/null +++ b/maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/AbstractGeneratorMojo.java @@ -0,0 +1,36 @@ +package org.apache.maven.plugin.plugin; + +import org.apache.maven.plugin.AbstractPlugin; +import org.apache.maven.plugin.PluginExecutionRequest; +import org.apache.maven.plugin.PluginExecutionResponse; + +/** + * @author Jason van Zyl + * @version $Id$ + */ +public abstract class AbstractGeneratorMojo + extends AbstractPlugin +{ + protected abstract void generate( String sourceDirectory, String outputDirectory, String pom ) + throws Exception; + + public void execute( PluginExecutionRequest request, PluginExecutionResponse response ) + throws Exception + { + // ---------------------------------------------------------------------- + // + // ---------------------------------------------------------------------- + + String sourceDirectory = (String) request.getParameter( "sourceDirectory" ); + + String outputDirectory = (String) request.getParameter( "outputDirectory" ); + + String pom = (String) request.getParameter( "pom" ); + + // ---------------------------------------------------------------------- + // + // ---------------------------------------------------------------------- + + generate( sourceDirectory, outputDirectory, pom ); + } +} diff --git a/maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/AbstractPluginMojo.java b/maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/AbstractPluginMojo.java index 815fd96891..422e0532fa 100644 --- a/maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/AbstractPluginMojo.java +++ b/maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/AbstractPluginMojo.java @@ -4,6 +4,8 @@ import org.apache.maven.plugin.AbstractPlugin; import org.apache.maven.plugin.PluginExecutionRequest; import org.apache.maven.plugin.PluginExecutionResponse; +import java.io.File; + /** * @author Jason van Zyl * @version $Id$ @@ -11,26 +13,27 @@ import org.apache.maven.plugin.PluginExecutionResponse; public abstract class AbstractPluginMojo extends AbstractPlugin { - protected abstract void generate( String sourceDirectory, String outputDirectory, String pom ) - throws Exception; - public void execute( PluginExecutionRequest request, PluginExecutionResponse response ) - throws Exception + protected File getJarFile( PluginExecutionRequest request ) { // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- - String sourceDirectory = (String) request.getParameter( "sourceDirectory" ); - String outputDirectory = (String) request.getParameter( "outputDirectory" ); - String pom = (String) request.getParameter( "pom" ); + String jarName = (String) request.getParameter( "jarName" ); // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- - generate( sourceDirectory, outputDirectory, pom ); + File jarFile = new File( new File( outputDirectory ), jarName + ".jar" ); + + return jarFile; } + + + + } diff --git a/maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/BeanGeneratorMojo.java b/maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/BeanGeneratorMojo.java index 7fcf6b97f5..7dcd461047 100644 --- a/maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/BeanGeneratorMojo.java +++ b/maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/BeanGeneratorMojo.java @@ -33,7 +33,7 @@ import org.apache.maven.plugin.generator.BeanGenerator; * @version $Id$ */ public class BeanGeneratorMojo - extends AbstractPluginMojo + extends AbstractGeneratorMojo { protected void generate( String sourceDirectory, String outputDirectory, String pom ) throws Exception diff --git a/maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/DescriptorGenerator.java b/maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/DescriptorGenerator.java index 96a745edea..3de2479b6d 100644 --- a/maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/DescriptorGenerator.java +++ b/maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/DescriptorGenerator.java @@ -33,7 +33,7 @@ import org.apache.maven.plugin.generator.PluginDescriptorGenerator; * @version $Id$ */ public class DescriptorGenerator - extends AbstractPluginMojo + extends AbstractGeneratorMojo { protected void generate( String sourceDirectory, String outputDirectory, String pom ) throws Exception diff --git a/maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/InstallMojo.java b/maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/InstallMojo.java index 79bc7f3483..98c110960b 100644 --- a/maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/InstallMojo.java +++ b/maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/InstallMojo.java @@ -18,6 +18,7 @@ import org.codehaus.plexus.util.FileUtils; * @description Installs a plugin into the maven installation. * * @prereq plugin:descriptor + * * @prereq jar:jar * * @parameter diff --git a/maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/JellyGeneratorMojo.java b/maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/JellyGeneratorMojo.java index 3fa8b6b01b..44b51b73d4 100644 --- a/maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/JellyGeneratorMojo.java +++ b/maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/JellyGeneratorMojo.java @@ -33,7 +33,7 @@ import org.apache.maven.plugin.generator.jelly.JellyHarnessGenerator; * @version $Id$ */ public class JellyGeneratorMojo - extends AbstractPluginMojo + extends AbstractGeneratorMojo { protected void generate( String sourceDirectory, String outputDirectory, String pom ) throws Exception diff --git a/maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/PluginDeployMojo.java b/maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/PluginDeployMojo.java new file mode 100644 index 0000000000..a85efe60be --- /dev/null +++ b/maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/PluginDeployMojo.java @@ -0,0 +1,79 @@ +package org.apache.maven.plugin.plugin; + +import java.io.File; + +import org.apache.maven.plugin.AbstractPlugin; +import org.apache.maven.plugin.PluginExecutionRequest; +import org.apache.maven.plugin.PluginExecutionResponse; +import org.apache.maven.project.MavenProject; +import org.apache.maven.artifact.installer.ArtifactInstaller; +import org.apache.maven.artifact.deployer.ArtifactDeployer; + +import org.codehaus.plexus.util.FileUtils; + +/* + * LICENSE + */ + +/** + * @goal deploy + * + * @description Installs a plugin into local repository + * + * @prereq plugin:plugin + * + * @parameter + * name="outputDirectory" + * type="String" + * required="true" + * validator="" + * expression="#project.build.directory" + * description="" + * + * @parameter + * name="jarName" + * type="String" + * required="true" + * validator="" + * expression="#maven.final.name" + * description="" + * + * @parameter + * name="project" + * type="org.apache.maven.project.MavenProject" + * required="true" + * validator="" + * expression="#project" + * description="" + * + * @parameter + * name="deployer" + * type="org.apache.maven.artifact.deployer.ArtifactDeployer" + * required="true" + * validator="" + * expression="#component.org.apache.maven.artifact.deployer.ArtifactDeployer" + * description="" + * + * @author Trygve Laugstøl + * @author Michal Maczka + * @version $Id$ + */ +public class PluginDeployMojo + extends AbstractPluginMojo +{ + public void execute( PluginExecutionRequest request, PluginExecutionResponse response ) + throws Exception + { + + File jarFile = getJarFile( request ); + + MavenProject project = (MavenProject) request.getParameter( "project" ); + + ArtifactDeployer artifactDeployer = ( ArtifactDeployer ) request.getParameter( "deployer" ); + + artifactDeployer.deploy( jarFile, "plugin", project ); + + } + + +} diff --git a/maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/PluginInstallMojo.java b/maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/PluginInstallMojo.java new file mode 100644 index 0000000000..64a52d0ac0 --- /dev/null +++ b/maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/PluginInstallMojo.java @@ -0,0 +1,81 @@ +package org.apache.maven.plugin.plugin; + +import java.io.File; + +import org.apache.maven.plugin.AbstractPlugin; +import org.apache.maven.plugin.PluginExecutionRequest; +import org.apache.maven.plugin.PluginExecutionResponse; +import org.apache.maven.project.MavenProject; +import org.apache.maven.artifact.installer.ArtifactInstaller; + +import org.codehaus.plexus.util.FileUtils; + +/* + * LICENSE + */ + +/** + * @goal install + * + * @description Installs a plugin into local repository + * + * @prereq plugin:plugin + * + * @parameter + * name="outputDirectory" + * type="String" + * required="true" + * validator="" + * expression="#project.build.directory" + * description="" + * + * @parameter + * name="jarName" + * type="String" + * required="true" + * validator="" + * expression="#maven.final.name" + * description="" + * + * @parameter + * name="project" + * type="org.apache.maven.project.MavenProject" + * required="true" + * validator="" + * expression="#project" + * description="" + * + * @parameter + * name="installer" + * type="org.apache.maven.artifact.installer.ArtifactInstaller" + * required="true" + * validator="" + * expression="#component.org.apache.maven.artifact.installer.ArtifactInstaller" + * description="" + * + * @author Trygve Laugstøl + * @author Michal Maczka + * @version $Id$ + */ +public class PluginInstallMojo + extends AbstractPluginMojo +{ + public void execute( PluginExecutionRequest request, PluginExecutionResponse response ) + throws Exception + { + + File jarFile = getJarFile( request ); + + MavenProject project = (MavenProject) request.getParameter( "project" ); + + ArtifactInstaller artifactInstaller = (ArtifactInstaller) request.getParameter( "installer" ); + + System.out.println( "artifactInstaller: " + artifactInstaller ); + + artifactInstaller.install( jarFile, "plugin", project ); + + + } + + +} diff --git a/maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/PluginMojo.java b/maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/PluginMojo.java new file mode 100644 index 0000000000..908cdb175f --- /dev/null +++ b/maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/PluginMojo.java @@ -0,0 +1,27 @@ +package org.apache.maven.plugin.plugin; + +import org.apache.maven.plugin.AbstractPlugin; +import org.apache.maven.plugin.PluginExecutionRequest; +import org.apache.maven.plugin.PluginExecutionResponse; + +/** + * @goal plugin + * + * @description Creates a plugin jar + * + * @prereq plugin:descriptor + * + * @prereq jar:jar + * + * + * @author Michal Maczka + * @version $Id$ + */ +public class PluginMojo extends AbstractPlugin +{ + + public void execute( PluginExecutionRequest request, PluginExecutionResponse response ) throws Exception + { + + } +} diff --git a/maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/PluginSetupMojo.java b/maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/PluginSetupMojo.java new file mode 100644 index 0000000000..61799bac66 --- /dev/null +++ b/maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/PluginSetupMojo.java @@ -0,0 +1,121 @@ +package org.apache.maven.plugin.plugin; + +import java.io.File; + +import org.apache.maven.plugin.AbstractPlugin; +import org.apache.maven.plugin.PluginExecutionRequest; +import org.apache.maven.plugin.PluginExecutionResponse; + +import org.codehaus.plexus.util.FileUtils; + +/* + * LICENSE + */ + +/** + * @goal setup + * + * @description Installs a plugin into the maven installation. + * + * @prereq plugin:plugin + * + * @parameter + * name="outputDirectory" + * type="String" + * required="true" + * validator="" + * expression="#project.build.directory" + * description="" + * + * @parameter + * name="jarName" + * type="String" + * required="true" + * validator="" + * expression="#maven.final.name" + * description="" + * + * @parameter + * name="pluginHome" + * type="String" + * required="true" + * validator="" + * expression="#maven.plugin.home" + * description="" + * + * @author Trygve Laugstøl + * @author Michal Maczka + * @version $Id$ + */ +public class PluginSetupMojo + extends AbstractPluginMojo +{ + public void execute( PluginExecutionRequest request, PluginExecutionResponse response ) + throws Exception + { + + + String pluginHomeName = (String) request.getParameter( "pluginHome" ); + + // ---------------------------------------------------------------------- + // + // ---------------------------------------------------------------------- + + File jarFile = getJarFile( request ); + + File pluginHome = getPluginHome( pluginHomeName ); + + System.out.println( "Installing " + jarFile + " in " + pluginHome ); + + FileUtils.copyFileToDirectory( jarFile, pluginHome ); + } + + private File getPluginHome( String pluginHomeName ) + throws Exception + { + File pluginHome; + + if ( pluginHomeName == null || + pluginHomeName.trim().length() == 0 || + pluginHomeName.equals( "maven.plugin.home" ) ) + { + String mavenHomeName = System.getProperty( "maven.home" ); + + if ( mavenHomeName == null ) + { + String userHomeName = System.getProperty( "user.home" ); + + System.out.println( "userHomeName: " + userHomeName ); + + File mavenHome = new File( userHomeName, ".m2" ); + + if ( !mavenHome.exists() ) + { + mavenHome = new File( userHomeName, "m2" ); + + if ( !mavenHome.exists() ) + { + pluginHome = new File( mavenHome, "plugins" ); + } + else + { + throw new Exception( "Cannot find the maven plugins directory." ); + } + } + else + { + pluginHome = new File( mavenHome, "plugins" ); + } + } + else + { + pluginHome = new File( mavenHomeName, "plugins" ); + } + } + else + { + pluginHome = new File( pluginHomeName ); + } + return pluginHome; + } +}