From c86ea920b8ff09aa4e5877c5245d3f5e92ab842a Mon Sep 17 00:00:00 2001 From: Jason van Zyl Date: Mon, 23 Aug 2004 00:27:44 +0000 Subject: [PATCH] o adding plugin install this is not the way i want the installing mechanism to work (i.e. copying the same class around ...) but folks want to install plugins so i'll just pop this in for now. git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@162997 13f79535-47bb-0310-9956-ffa450edef68 --- maven-plugins/maven-plugin-plugin/pom.xml | 20 ++++++ .../plugin/plugin/PluginInstallMojo.java | 68 +++++++++++++++++++ 2 files changed, 88 insertions(+) create mode 100644 maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/PluginInstallMojo.java diff --git a/maven-plugins/maven-plugin-plugin/pom.xml b/maven-plugins/maven-plugin-plugin/pom.xml index b8c096c531..82f0d6c5b3 100644 --- a/maven-plugins/maven-plugin-plugin/pom.xml +++ b/maven-plugins/maven-plugin-plugin/pom.xml @@ -20,5 +20,25 @@ maven-plugin-tools 2.0-SNAPSHOT + + maven + maven-model + 2.0-SNAPSHOT + + + maven + maven-core + 2.0-SNAPSHOT + + + maven + maven-artifact + 2.0-SNAPSHOT + + + maven + wagon-api + 1.0-alpha-1-SNAPSHOT + 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..6fe75e1917 --- /dev/null +++ b/maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/PluginInstallMojo.java @@ -0,0 +1,68 @@ +package org.apache.maven.plugin.plugin; + +import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.DefaultArtifact; +import org.apache.maven.artifact.installer.ArtifactInstaller; +import org.apache.maven.artifact.repository.ArtifactRepository; +import org.apache.maven.plugin.AbstractPlugin; +import org.apache.maven.plugin.PluginExecutionRequest; +import org.apache.maven.plugin.PluginExecutionResponse; +import org.apache.maven.project.MavenProject; + +/** + * @goal install + * + * @description installs project's main artifact in local repository + * + * @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="" + * @parameter name="localRepository" + * type="org.apache.maven.artifact.repository.ArtifactRepository" + * required="true" + * validator="" + * expression="#localRepository" + * description="" + * @prereq jar:jar + */ +public class PluginInstallMojo + extends AbstractPlugin +{ + public void execute( PluginExecutionRequest request, PluginExecutionResponse response ) + throws Exception + { + MavenProject project = (MavenProject) request.getParameter( "project" ); + + ArtifactInstaller artifactInstaller = (ArtifactInstaller) request.getParameter( "installer" ); + + ArtifactRepository localRepository = (ArtifactRepository) request.getParameter( "localRepository" ); + + Artifact artifact = new DefaultArtifact( project.getGroupId(), + project.getArtifactId(), + project.getVersion(), + project.getType() ); + + artifactInstaller.install( project.getBuild().getDirectory(), artifact, localRepository ); + + // ---------------------------------------------------------------------- + // This is not the way to do this, but in order to get the integration + // tests working this is what I'm doing. jvz. + // ---------------------------------------------------------------------- + + Artifact pomArtifact = new DefaultArtifact( project.getGroupId(), + project.getArtifactId(), + project.getVersion(), + "pom" ); + + artifactInstaller.install( project.getFile(), pomArtifact, localRepository ); + } +}