maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arami...@apache.org
Subject svn commit: r351856 - in /maven/plugins/trunk/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy: AbstractDeployMojo.java DeployFileMojo.java DeployMojo.java
Date Sat, 03 Dec 2005 00:10:04 GMT
Author: aramirez
Date: Fri Dec  2 16:09:47 2005
New Revision: 351856

URL: http://svn.apache.org/viewcvs?rev=351856&view=rev
Log:
PR:MNG-1551
Added deploy-file goal which will enable users to install artifacts in their remote repository

Added:
    maven/plugins/trunk/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/AbstractDeployMojo.java
    maven/plugins/trunk/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/DeployFileMojo.java
Modified:
    maven/plugins/trunk/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/DeployMojo.java

Added: maven/plugins/trunk/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/AbstractDeployMojo.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/AbstractDeployMojo.java?rev=351856&view=auto
==============================================================================
--- maven/plugins/trunk/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/AbstractDeployMojo.java
(added)
+++ maven/plugins/trunk/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/AbstractDeployMojo.java
Fri Dec  2 16:09:47 2005
@@ -0,0 +1,65 @@
+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.artifact.deployer.ArtifactDeployer;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+
+public abstract class AbstractDeployMojo
+	extends AbstractMojo
+{
+    /**
+     * @parameter expression="${component.org.apache.maven.artifact.deployer.ArtifactDeployer}"
+     * @required
+     * @readonly
+     */
+    private ArtifactDeployer deployer;
+
+    /**
+     * @parameter expression="${localRepository}"
+     * @required
+     * @readonly
+     */
+    private ArtifactRepository localRepository;
+	
+	public abstract void execute() 
+		throws MojoExecutionException;
+	
+	/* Setters and Getters */
+
+	public ArtifactDeployer getDeployer()
+	{
+		return deployer;
+	}
+
+	public void setDeployer(ArtifactDeployer deployer)
+	{
+		this.deployer = deployer;
+	}
+
+	public ArtifactRepository getLocalRepository()
+	{
+		return localRepository;
+	}
+
+	public void setLocalRepository(ArtifactRepository localRepository)
+	{
+		this.localRepository = localRepository;
+	}
+}

Added: maven/plugins/trunk/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/DeployFileMojo.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/DeployFileMojo.java?rev=351856&view=auto
==============================================================================
--- maven/plugins/trunk/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/DeployFileMojo.java
(added)
+++ maven/plugins/trunk/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/DeployFileMojo.java
Fri Dec  2 16:09:47 2005
@@ -0,0 +1,143 @@
+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 java.io.File;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.deployer.ArtifactDeploymentException;
+import org.apache.maven.artifact.factory.ArtifactFactory;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
+import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
+import org.apache.maven.plugin.MojoExecutionException;
+
+/**
+ * Installs the artifact in the remote repository.
+ * 
+ * @goal deploy-file
+ * @requiresProject false 
+ * @author <a href="mailto:aramirez@apache.org">Allan Ramirez</a>
+ */
+public class DeployFileMojo
+	extends AbstractDeployMojo
+{
+    /**
+     * GroupId of the artifact to be deployed.
+     * 
+     * @parameter expression="${groupId}"
+     * @required
+     */
+    private String groupId;
+
+    /**
+     * ArtifactId of the artifact to be deployed.
+     * 
+     * @parameter expression="${artifactId}"
+     * @required
+     */
+    private String artifactId;
+
+    /**
+     * Version of the artifact to be deployed.
+     * 
+     * @parameter expression="${version}"
+     * @required
+     */
+    private String version;
+
+    /**
+     * Type of the artifact to be deployed.
+     * 
+     * @parameter expression="${packaging}"
+     * @required
+     */
+    private String packaging;	
+	
+	/**
+	 * File to be deployed.
+	 * 
+	 * @parameter expression="${file}"
+	 * @required
+	 */
+	private File deployFile;
+	
+	/**
+	 * Server Id to map on the <id> under <server> section of settings.xml
+	 * 
+	 * @parameter expression="${serverId}" default-value="my-repo"
+	 */
+	private String repositoryId;
+	
+	/**
+	 * URL where the artifact will be deployed. <br>
+	 * ie ( file://C:\m2-repo )
+	 * 
+	 * @parameter expression="${url}"
+	 * @required
+	 */
+	private String url;
+	
+    /**
+     * @parameter expression="${component.org.apache.maven.artifact.factory.ArtifactFactory}"
+     * @required
+     * @readonly
+     */
+    private ArtifactFactory artifactFactory;	
+    
+    /**
+     * @parameter expression="${component.org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout}"
+     * @required
+     * @readonly
+     */
+    private ArtifactRepositoryLayout layout;    
+    
+    /**
+     * @parameter expression="${component.org.apache.maven.artifact.repository.ArtifactRepositoryFactory}"
+     * @required
+     * @readonly
+     */
+    private ArtifactRepositoryFactory repositoryFactory;
+	
+	public void execute() throws MojoExecutionException
+	{
+		try
+		{	
+			Artifact artifact = artifactFactory.createArtifact( groupId, artifactId, version, null,
packaging );
+			
+			ArtifactRepository deploymentRepository = 
+				repositoryFactory.createDeploymentArtifactRepository( repositoryId, url, layout, false
);
+			
+	        if ( deployFile == null )
+	        {
+	            throw new MojoExecutionException(
+	                "The packaging for this project did not assign a file to the build artifact"
);
+	        }
+	        else
+	        {
+	        	if( deployFile.exists() )
+	        	{
+	        		getDeployer().deploy( deployFile, artifact, deploymentRepository, getLocalRepository()
);	
+	        	}
+	        }
+		}
+		catch( ArtifactDeploymentException e )
+		{
+            throw new MojoExecutionException( e.getMessage(), e );
+		}
+	}
+}

Modified: maven/plugins/trunk/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/DeployMojo.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/DeployMojo.java?rev=351856&r1=351855&r2=351856&view=diff
==============================================================================
--- maven/plugins/trunk/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/DeployMojo.java
(original)
+++ maven/plugins/trunk/maven-deploy-plugin/src/main/java/org/apache/maven/plugin/deploy/DeployMojo.java
Fri Dec  2 16:09:47 2005
@@ -17,11 +17,9 @@
  */
 
 import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.deployer.ArtifactDeployer;
 import org.apache.maven.artifact.deployer.ArtifactDeploymentException;
 import org.apache.maven.artifact.metadata.ArtifactMetadata;
 import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.project.artifact.ProjectArtifactMetadata;
 
@@ -39,7 +37,7 @@
  * @phase deploy
  */
 public class DeployMojo
-    extends AbstractMojo
+    extends AbstractDeployMojo
 {
 
     /**
@@ -64,26 +62,12 @@
     private File pomFile;
 
     /**
-     * @parameter expression="${component.org.apache.maven.artifact.deployer.ArtifactDeployer}"
-     * @required
-     * @readonly
-     */
-    private ArtifactDeployer deployer;
-
-    /**
      * @parameter expression="${project.distributionManagementArtifactRepository}"
      * @readonly
      */
     private ArtifactRepository deploymentRepository;
 
     /**
-     * @parameter expression="${localRepository}"
-     * @required
-     * @readonly
-     */
-    private ArtifactRepository localRepository;
-
-    /**
      * @parameter expression="${project.attachedArtifacts}
      * @required
      * @readonly
@@ -134,7 +118,7 @@
         {
             if ( isPomArtifact )
             {
-                deployer.deploy( pomFile, artifact, deploymentRepository, localRepository
);
+                getDeployer().deploy( pomFile, artifact, deploymentRepository, getLocalRepository()
);
             }
             else
             {
@@ -144,13 +128,14 @@
                     throw new MojoExecutionException(
                         "The packaging for this project did not assign a file to the build
artifact" );
                 }
-                deployer.deploy( file, artifact, deploymentRepository, localRepository );
+                getDeployer().deploy( file, artifact, deploymentRepository, getLocalRepository()
);
             }
-
+            
             for ( Iterator i = attachedArtifacts.iterator(); i.hasNext(); )
-            {
+            {	
                 Artifact attached = (Artifact) i.next();
-                deployer.deploy( attached.getFile(), attached, deploymentRepository, localRepository
);
+                
+                getDeployer().deploy( attached.getFile(), attached, deploymentRepository,
getLocalRepository() );
             }
         }
         catch ( ArtifactDeploymentException e )



Mime
View raw message