- Make install mojo to the same model like deploy mojo

- Install and deploy always pom.


git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@163366 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Emmanuel Venisse 2005-02-19 13:39:59 +00:00
parent 039c3c0c9c
commit b44af08db6
4 changed files with 140 additions and 37 deletions

View File

@ -71,18 +71,18 @@ public abstract class AbstractDeployMojo
ArtifactRepository deploymentRepository = RepositoryUtils.mavenRepositoryToWagonRepository( repository );
if ( isPom() )
{
Artifact artifact = new DefaultArtifact( project.getGroupId(),
project.getArtifactId(),
project.getVersion(),
"pom" );
// Deplou the POM
Artifact pomArtifact = new DefaultArtifact( project.getGroupId(),
project.getArtifactId(),
project.getVersion(),
"pom" );
File pom = new File( project.getFile().getParentFile(), "pom.xml" );
File pom = new File( project.getFile().getParentFile(), "pom.xml" );
artifactDeployer.deploy( pom, artifact, deploymentRepository );
}
else
artifactDeployer.deploy( pom, pomArtifact, deploymentRepository );
//Deploy artifact
if ( ! isPom() )
{
Artifact artifact = new DefaultArtifact( project.getGroupId(),
project.getArtifactId(),

View File

@ -0,0 +1,73 @@
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.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.repository.ArtifactRepository;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.DefaultArtifact;
import java.io.File;
/**
* @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
* @version $Id$
*/
public abstract class AbstractInstallMojo
extends AbstractPlugin
{
protected boolean isPom()
{
return false;
}
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 ( ! isPom() )
{
Artifact artifact = new DefaultArtifact( project.getGroupId(),
project.getArtifactId(),
project.getVersion(),
project.getType() );
artifactInstaller.install( project.getBuild().getDirectory(), artifact, localRepository );
}
}
}

View File

@ -1,7 +1,7 @@
package org.apache.maven.plugin.install;
/*
* Copyright 2001-2004 The Apache Software Foundation.
* 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.
@ -16,15 +16,6 @@ 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.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
*
@ -55,22 +46,6 @@ import org.apache.maven.project.MavenProject;
*
*/
public class InstallMojo
extends AbstractPlugin
extends AbstractInstallMojo
{
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 );
}
}

View File

@ -0,0 +1,55 @@
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.
*/
/**
* @goal pom
*
* @description installs pom 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 build
*
*/
public class InstallPomMojo
extends AbstractInstallMojo
{
protected boolean isPom()
{
return true;
}
}