mirror of https://github.com/apache/maven.git
Add a little deploy plugin
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@163364 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
7b7f7659d8
commit
039c3c0c9c
|
@ -89,6 +89,7 @@ public class MBoot
|
|||
{
|
||||
"maven-plugins/maven-clean-plugin",
|
||||
"maven-plugins/maven-compiler-plugin",
|
||||
"maven-plugins/maven-deploy-plugin",
|
||||
"maven-plugins/maven-install-plugin",
|
||||
"maven-plugins/maven-jar-plugin",
|
||||
"maven-plugins/maven-plugin-plugin",
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
target
|
||||
*~
|
||||
*.log
|
||||
.classpath
|
||||
.project
|
||||
*.ipr
|
||||
*.iws
|
||||
*.iml
|
|
@ -0,0 +1,39 @@
|
|||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
|
||||
<project>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>maven</groupId>
|
||||
<artifactId>maven-plugin-parent</artifactId>
|
||||
<version>2.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<groupId>maven</groupId>
|
||||
<artifactId>maven-deploy-plugin</artifactId>
|
||||
<type>plugin</type>
|
||||
<name>Maven Deploy Plugin</name>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<inceptionYear>2004</inceptionYear>
|
||||
<package>org.apache.maven.plugin.deploy</package>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>maven</groupId>
|
||||
<artifactId>maven-core</artifactId>
|
||||
<version>2.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>maven</groupId>
|
||||
<artifactId>maven-model</artifactId>
|
||||
<version>2.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>maven</groupId>
|
||||
<artifactId>maven-artifact</artifactId>
|
||||
<version>2.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>maven</groupId>
|
||||
<artifactId>wagon-api</artifactId>
|
||||
<version>1.0-alpha-1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -0,0 +1,95 @@
|
|||
package org.apache.maven.plugin.deploy;
|
||||
|
||||
/*
|
||||
* 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.deployer.ArtifactDeployer;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.artifact.DefaultArtifact;
|
||||
import org.apache.maven.model.Repository;
|
||||
import org.apache.maven.model.DistributionManagement;
|
||||
import org.apache.maven.repository.RepositoryUtils;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public abstract class AbstractDeployMojo
|
||||
extends AbstractPlugin
|
||||
{
|
||||
|
||||
protected boolean isPom()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public void execute( PluginExecutionRequest request, PluginExecutionResponse response )
|
||||
throws Exception
|
||||
{
|
||||
MavenProject project = (MavenProject) request.getParameter( "project" );
|
||||
|
||||
ArtifactDeployer artifactDeployer = (ArtifactDeployer) request.getParameter( "deployer" );
|
||||
|
||||
DistributionManagement distributionManagement = project.getDistributionManagement();
|
||||
|
||||
if ( distributionManagement == null )
|
||||
{
|
||||
String msg = "Deployment failed: distributionManagement element" +
|
||||
" was not specified in the pom";
|
||||
throw new Exception( msg );
|
||||
}
|
||||
|
||||
Repository repository = distributionManagement.getRepository();
|
||||
|
||||
if ( repository == null )
|
||||
{
|
||||
String msg = "Deployment failed: repository element" +
|
||||
" was not specified in the pom inside" +
|
||||
" distributionManagement element";
|
||||
throw new Exception( msg );
|
||||
}
|
||||
|
||||
ArtifactRepository deploymentRepository = RepositoryUtils.mavenRepositoryToWagonRepository( repository );
|
||||
|
||||
if ( isPom() )
|
||||
{
|
||||
Artifact artifact = new DefaultArtifact( project.getGroupId(),
|
||||
project.getArtifactId(),
|
||||
project.getVersion(),
|
||||
"pom" );
|
||||
|
||||
File pom = new File( project.getFile().getParentFile(), "pom.xml" );
|
||||
|
||||
artifactDeployer.deploy( pom, artifact, deploymentRepository );
|
||||
}
|
||||
else
|
||||
{
|
||||
Artifact artifact = new DefaultArtifact( project.getGroupId(),
|
||||
project.getArtifactId(),
|
||||
project.getVersion(),
|
||||
project.getType() );
|
||||
|
||||
artifactDeployer.deploy( project.getBuild().getDirectory(), artifact, deploymentRepository );
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
package org.apache.maven.plugin.deploy;
|
||||
|
||||
/*
|
||||
* 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 deploy
|
||||
*
|
||||
* @description deploys an artifact to remote repository
|
||||
*
|
||||
* @parameter
|
||||
* name="project"
|
||||
* type="org.apache.maven.project.MavenProject"
|
||||
* required="true"
|
||||
* validator=""
|
||||
* expression="#project"
|
||||
* description=""
|
||||
*
|
||||
* @parameter
|
||||
* name="deployer"
|
||||
* type="org.apache.maven.artifact.deployer.ArtifactDeployer"
|
||||
* required="true"
|
||||
* validator=""
|
||||
* expression="#component.org.apache.maven.artifact.deployer.ArtifactDeployer"
|
||||
* description=""
|
||||
*
|
||||
* @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class DeployMojo
|
||||
extends AbstractDeployMojo
|
||||
{
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
package org.apache.maven.plugin.deploy;
|
||||
|
||||
/*
|
||||
* 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 deploys an artifact to remote repository
|
||||
*
|
||||
* @parameter
|
||||
* name="project"
|
||||
* type="org.apache.maven.project.MavenProject"
|
||||
* required="true"
|
||||
* validator=""
|
||||
* expression="#project"
|
||||
* description=""
|
||||
*
|
||||
* @parameter
|
||||
* name="deployer"
|
||||
* type="org.apache.maven.artifact.deployer.ArtifactDeployer"
|
||||
* required="true"
|
||||
* validator=""
|
||||
* expression="#component.org.apache.maven.artifact.deployer.ArtifactDeployer"
|
||||
* description=""
|
||||
*
|
||||
* @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class DeployPomMojo
|
||||
extends AbstractDeployMojo
|
||||
{
|
||||
protected boolean isPom()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue