From c0000822c0fd09dc1d9c4aa32bb28aef57c9ac17 Mon Sep 17 00:00:00 2001 From: Michal Maczka Date: Sun, 20 Jun 2004 15:56:57 +0000 Subject: [PATCH] added generic install plugin. I am not sure if this is a right way of implementing this - but I will need similar things for site plugin - so this will serve as an example for disussion how to attain arbitrary goal(s) from plugin git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@162822 13f79535-47bb-0310-9956-ffa450edef68 --- maven-plugins/maven-install-plugin/.cvsignore | 7 ++ maven-plugins/maven-install-plugin/pom.xml | 15 ++++ .../maven/plugin/install/InstallMojo.java | 77 +++++++++++++++++++ 3 files changed, 99 insertions(+) create mode 100644 maven-plugins/maven-install-plugin/.cvsignore create mode 100644 maven-plugins/maven-install-plugin/pom.xml create mode 100644 maven-plugins/maven-install-plugin/src/main/java/org/apache/maven/plugin/install/InstallMojo.java diff --git a/maven-plugins/maven-install-plugin/.cvsignore b/maven-plugins/maven-install-plugin/.cvsignore new file mode 100644 index 0000000000..98970fed73 --- /dev/null +++ b/maven-plugins/maven-install-plugin/.cvsignore @@ -0,0 +1,7 @@ +*~ +*.log +target +.classpath +.project +*.ipr +*.iws diff --git a/maven-plugins/maven-install-plugin/pom.xml b/maven-plugins/maven-install-plugin/pom.xml new file mode 100644 index 0000000000..c1e398bb7c --- /dev/null +++ b/maven-plugins/maven-install-plugin/pom.xml @@ -0,0 +1,15 @@ + + + + + maven + maven-plugin-parent + 2.0-SNAPSHOT + + maven-install-plugin + maven-install-plugin + Maven Install Plugin + 1.0-SNAPSHOT + 2004 + org.apache.maven.plugin.install + diff --git a/maven-plugins/maven-install-plugin/src/main/java/org/apache/maven/plugin/install/InstallMojo.java b/maven-plugins/maven-install-plugin/src/main/java/org/apache/maven/plugin/install/InstallMojo.java new file mode 100644 index 0000000000..a641a39b9b --- /dev/null +++ b/maven-plugins/maven-install-plugin/src/main/java/org/apache/maven/plugin/install/InstallMojo.java @@ -0,0 +1,77 @@ +package org.apache.maven.plugin.clean; + +/* + * Copyright 2001-2004 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +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.MavenCore; + +import java.util.ArrayList; +import java.util.List; + +/** + * @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="mavenCore" + * type="org.apache.maven.MavenCore" + * required="true" + * validator="" + * expression="#component.org.apache.maven.artifact.deployer.ArtifactDeployer" + * description="""" + * + * @author Michal Maczka + * @version $Id$ + */ +public class InstallMojo + extends AbstractPlugin +{ + + public void execute( PluginExecutionRequest request, PluginExecutionResponse response ) + throws Exception + { + + MavenProject project = (MavenProject) request.getParameter( "project" ); + + String type = project.getType(); + + MavenCore mavenCore = ( MavenCore ) request.getParameter( "mavenCore" ); + + String goal = type + ":" + type; + + List goals = new ArrayList( 1 ); + + goals.add( goal ); + + mavenCore.execute( project, goals ); + + } + + +}