o Extended IT plugin to support installation/deployment of POM projects

git-svn-id: https://svn.apache.org/repos/asf/maven/core-integration-testing/trunk@775699 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Benjamin Bentmann 2009-05-17 16:31:47 +00:00
parent 73be4bf672
commit d0b192dbfe
3 changed files with 107 additions and 67 deletions

View File

@ -0,0 +1,89 @@
package org.apache.maven.plugin.coreit;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.repository.ArtifactRepository;
import org.apache.maven.plugin.AbstractMojo;
import java.io.File;
import java.util.Collection;
/**
* Provides common code for the install and deploy mojos.
*
* @author Benjamin Bentmann
* @version $Id$
*/
public abstract class AbstractRepoMojo
extends AbstractMojo
{
/**
* The project's main artifact.
*
* @parameter default-value="${project.artifact}"
* @readonly
* @required
*/
protected Artifact mainArtifact;
/**
* The project's attached artifact.
*
* @parameter default-value="${project.attachedArtifacts}"
* @readonly
* @required
*/
protected Collection attachedArtifacts;
/**
* The packaging of the project.
*
* @parameter default-value="${project.packaging}"
* @required
* @readonly
*/
protected String packaging;
/**
* The POM file of the project.
*
* @parameter default-value="${project.file}"
* @required
* @readonly
*/
protected File pomFile;
/**
* The local repository.
*
* @parameter default-value="${localRepository}"
* @readonly
* @required
*/
protected ArtifactRepository localRepository;
protected boolean isPomArtifact()
{
return "pom".equals( packaging );
}
}

View File

@ -22,17 +22,13 @@
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.deployer.ArtifactDeployer;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import java.util.Collection;
import java.util.Iterator;
/**
* Deploys the project artifacts to the distribution repository. This is the essence of the Maven Deploy Plugin.
* <strong>Note:</strong> Unlike the production plugin, this plugin does not handle projects with "pom" packaging for
* the sake of simplicity.
*
* @goal deploy
* @phase deploy
@ -41,36 +37,9 @@
* @version $Id$
*/
public class DeployMojo
extends AbstractMojo
extends AbstractRepoMojo
{
/**
* The project's main artifact.
*
* @parameter default-value="${project.artifact}"
* @readonly
* @required
*/
private Artifact mainArtifact;
/**
* The project's attached artifact.
*
* @parameter default-value="${project.attachedArtifacts}"
* @readonly
* @required
*/
private Collection attachedArtifacts;
/**
* The local repository.
*
* @parameter default-value="${localRepository}"
* @readonly
* @required
*/
private ArtifactRepository localRepository;
/**
* The distribution repository.
*
@ -99,7 +68,14 @@ public void execute()
try
{
deployer.deploy( mainArtifact.getFile(), mainArtifact, deploymentRepository, localRepository );
if ( isPomArtifact() )
{
deployer.deploy( pomFile, mainArtifact, deploymentRepository, localRepository );
}
else
{
deployer.deploy( mainArtifact.getFile(), mainArtifact, deploymentRepository, localRepository );
}
if ( attachedArtifacts != null )
{

View File

@ -21,18 +21,13 @@
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.installer.ArtifactInstaller;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import java.util.Collection;
import java.util.Iterator;
/**
* Installs the project artifacts into the local repository. This is the essence of the Maven Install Plugin.
* <strong>Note:</strong> Unlike the production plugin, this plugin does not handle projects with "pom" packaging for
* the sake of simplicity.
*
* @goal install
* @phase install
@ -41,36 +36,9 @@
* @version $Id$
*/
public class InstallMojo
extends AbstractMojo
extends AbstractRepoMojo
{
/**
* The project's main artifact.
*
* @parameter default-value="${project.artifact}"
* @readonly
* @required
*/
private Artifact mainArtifact;
/**
* The project's attached artifact.
*
* @parameter default-value="${project.attachedArtifacts}"
* @readonly
* @required
*/
private Collection attachedArtifacts;
/**
* The local repository.
*
* @parameter default-value="${localRepository}"
* @readonly
* @required
*/
private ArtifactRepository localRepository;
/**
* The artifact installer.
*
@ -90,7 +58,14 @@ public void execute()
try
{
installer.install( mainArtifact.getFile(), mainArtifact, localRepository );
if ( isPomArtifact() )
{
installer.install( pomFile, mainArtifact, localRepository );
}
else
{
installer.install( mainArtifact.getFile(), mainArtifact, localRepository );
}
if ( attachedArtifacts != null )
{