diff --git a/maven-plugins/maven-install-plugin/src/main/java/org/apache/maven/plugin/install/AbstractInstallMojo.java b/maven-plugins/maven-install-plugin/src/main/java/org/apache/maven/plugin/install/AbstractInstallMojo.java deleted file mode 100644 index d853f76c54..0000000000 --- a/maven-plugins/maven-install-plugin/src/main/java/org/apache/maven/plugin/install/AbstractInstallMojo.java +++ /dev/null @@ -1,64 +0,0 @@ -package org.apache.maven.plugin.install; - -/* - * Copyright 2001-2005 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.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; - -import java.io.File; - -/** - * @author Emmanuel Venisse - * @version $Id$ - */ -public abstract class AbstractInstallMojo - 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" ); - - // Install the POM - Artifact pomArtifact = new DefaultArtifact( project.getGroupId(), project.getArtifactId(), - project.getVersion(), "pom" ); - - File pom = new File( project.getFile().getParentFile(), "pom.xml" ); - - artifactInstaller.install( pom, pomArtifact, localRepository ); - - //Install artifact - if ( !"pom".equals( project.getPackaging() ) ) - { - Artifact artifact = new DefaultArtifact( project.getGroupId(), project.getArtifactId(), - project.getVersion(), project.getPackaging() ); - - artifactInstaller.install( project.getBuild().getDirectory(), artifact, localRepository ); - } - } -} 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 index 852fa7b905..dbbfdf2563 100644 --- 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 @@ -16,34 +16,76 @@ package org.apache.maven.plugin.install; * limitations under the License. */ +import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.DefaultArtifact; +import org.apache.maven.artifact.installer.ArtifactInstallationException; +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.PluginExecutionException; +import org.apache.maven.project.MavenProject; + +import java.io.File; + /** + * @author Emmanuel Venisse + * @version $Id$ * @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="" - * */ public class InstallMojo - extends AbstractInstallMojo + extends AbstractPlugin { + private MavenProject project; + + private ArtifactInstaller installer; + + private ArtifactRepository localRepository; + + public void execute() + throws PluginExecutionException + { + // Install the POM + Artifact pomArtifact = new DefaultArtifact( project.getGroupId(), project.getArtifactId(), + project.getVersion(), "pom" ); + + File pom = new File( project.getFile().getParentFile(), "pom.xml" ); + + try + { + installer.install( pom, pomArtifact, localRepository ); + + //Install artifact + if ( !"pom".equals( project.getPackaging() ) ) + { + Artifact artifact = new DefaultArtifact( project.getGroupId(), project.getArtifactId(), + project.getVersion(), project.getPackaging() ); + + installer.install( project.getBuild().getDirectory(), artifact, localRepository ); + } + } + catch ( ArtifactInstallationException e ) + { + // TODO: install exception that does not give a trace + throw new PluginExecutionException( "Error installing artifact", e ); + } + } }