You are viewing a plain text version of this content. The canonical link for it is here.
Posted to m2-dev@maven.apache.org by br...@apache.org on 2005/03/22 13:36:36 UTC
cvs commit: maven-components/maven-plugins/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy DeployMojo.java AbstractDeployMojo.java
brett 2005/03/22 04:36:36
Modified: maven-plugins/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy
DeployMojo.java
Removed: maven-plugins/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy
AbstractDeployMojo.java
Log:
convert deploy mojo to new execute()
Revision Changes Path
1.5 +61 -2 maven-components/maven-plugins/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/DeployMojo.java
Index: DeployMojo.java
===================================================================
RCS file: /home/cvs/maven-components/maven-plugins/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/DeployMojo.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- DeployMojo.java 21 Mar 2005 08:18:33 -0000 1.4
+++ DeployMojo.java 22 Mar 2005 12:36:36 -0000 1.5
@@ -16,6 +16,17 @@
* limitations under the License.
*/
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.DefaultArtifact;
+import org.apache.maven.artifact.deployer.ArtifactDeployer;
+import org.apache.maven.artifact.deployer.ArtifactDeploymentException;
+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;
+
/**
* @goal deploy
*
@@ -49,6 +60,54 @@
* @version $Id$
*/
public class DeployMojo
- extends AbstractDeployMojo
+ extends AbstractPlugin
{
+ private MavenProject project;
+
+ private ArtifactDeployer deployer;
+
+ private ArtifactRepository deploymentRepository;
+
+ public void execute()
+ throws PluginExecutionException
+ {
+ if ( deploymentRepository == null )
+ {
+ String msg = "Deployment failed: repository element was not specified in the pom inside"
+ + " distributionManagement element";
+ throw new PluginExecutionException( msg );
+ }
+
+ if ( deploymentRepository.getAuthenticationInfo() == null )
+ {
+ getLog().warn(
+ "Deployment repository {id: \'" + deploymentRepository.getId()
+ + "\'} has no associated authentication info!" );
+ }
+
+ // Deploy the POM
+ Artifact pomArtifact = new DefaultArtifact( project.getGroupId(), project.getArtifactId(),
+ project.getVersion(), "pom" );
+
+ File pom = new File( project.getFile().getParentFile(), "pom.xml" );
+
+ try
+ {
+ deployer.deploy( pom, pomArtifact, deploymentRepository );
+
+ //Deploy artifact
+ if ( !"pom".equals( project.getPackaging() ) )
+ {
+ Artifact artifact = new DefaultArtifact( project.getGroupId(), project.getArtifactId(),
+ project.getVersion(), project.getPackaging() );
+
+ deployer.deploy( project.getBuild().getDirectory(), artifact, deploymentRepository );
+ }
+ }
+ catch ( ArtifactDeploymentException e )
+ {
+ // TODO: deployment exception that does not give a trace
+ throw new PluginExecutionException( "Error deploying artifact", e );
+ }
+ }
}
\ No newline at end of file