From 039c3c0c9c1b393a78c4708071b477564995c0a6 Mon Sep 17 00:00:00 2001 From: Emmanuel Venisse Date: Fri, 18 Feb 2005 14:32:27 +0000 Subject: [PATCH] Add a little deploy plugin git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@163364 13f79535-47bb-0310-9956-ffa450edef68 --- maven-mboot2/src/main/java/MBoot.java | 1 + maven-plugins/maven-deploy-plugin/.cvsignore | 8 ++ maven-plugins/maven-deploy-plugin/pom.xml | 39 ++++++++ .../plugin/deploy/AbstractDeployMojo.java | 95 +++++++++++++++++++ .../maven/plugin/deploy/DeployMojo.java | 46 +++++++++ .../maven/plugin/deploy/DeployPomMojo.java | 50 ++++++++++ 6 files changed, 239 insertions(+) create mode 100644 maven-plugins/maven-deploy-plugin/.cvsignore create mode 100644 maven-plugins/maven-deploy-plugin/pom.xml create mode 100644 maven-plugins/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/AbstractDeployMojo.java create mode 100644 maven-plugins/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/DeployMojo.java create mode 100644 maven-plugins/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/DeployPomMojo.java diff --git a/maven-mboot2/src/main/java/MBoot.java b/maven-mboot2/src/main/java/MBoot.java index 5e53db1b33..1f3bf43117 100644 --- a/maven-mboot2/src/main/java/MBoot.java +++ b/maven-mboot2/src/main/java/MBoot.java @@ -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", diff --git a/maven-plugins/maven-deploy-plugin/.cvsignore b/maven-plugins/maven-deploy-plugin/.cvsignore new file mode 100644 index 0000000000..cce9515ca7 --- /dev/null +++ b/maven-plugins/maven-deploy-plugin/.cvsignore @@ -0,0 +1,8 @@ +target +*~ +*.log +.classpath +.project +*.ipr +*.iws +*.iml diff --git a/maven-plugins/maven-deploy-plugin/pom.xml b/maven-plugins/maven-deploy-plugin/pom.xml new file mode 100644 index 0000000000..b4f527b7ca --- /dev/null +++ b/maven-plugins/maven-deploy-plugin/pom.xml @@ -0,0 +1,39 @@ + + + + 4.0.0 + + maven + maven-plugin-parent + 2.0-SNAPSHOT + + maven + maven-deploy-plugin + plugin + Maven Deploy Plugin + 1.0-SNAPSHOT + 2004 + org.apache.maven.plugin.deploy + + + maven + maven-core + 2.0-SNAPSHOT + + + maven + maven-model + 2.0-SNAPSHOT + + + maven + maven-artifact + 2.0-SNAPSHOT + + + maven + wagon-api + 1.0-alpha-1-SNAPSHOT + + + diff --git a/maven-plugins/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/AbstractDeployMojo.java b/maven-plugins/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/AbstractDeployMojo.java new file mode 100644 index 0000000000..e838ce78fd --- /dev/null +++ b/maven-plugins/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/AbstractDeployMojo.java @@ -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 Emmanuel Venisse + * @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 ); + } + } +} diff --git a/maven-plugins/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/DeployMojo.java b/maven-plugins/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/DeployMojo.java new file mode 100644 index 0000000000..f72d777bc8 --- /dev/null +++ b/maven-plugins/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/DeployMojo.java @@ -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 Emmanuel Venisse + * @version $Id$ + */ +public class DeployMojo + extends AbstractDeployMojo +{ +} diff --git a/maven-plugins/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/DeployPomMojo.java b/maven-plugins/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/DeployPomMojo.java new file mode 100644 index 0000000000..122d556eed --- /dev/null +++ b/maven-plugins/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/DeployPomMojo.java @@ -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 Emmanuel Venisse + * @version $Id$ + */ +public class DeployPomMojo + extends AbstractDeployMojo +{ + protected boolean isPom() + { + return true; + } +}