The following comment has been added to this issue:

     Author: Neil Crow
    Created: Fri, 3 Dec 2004 11:06 AM
       Body:
I have created a NamedArtifactTypeHandler and added an artifactIdOveride 
property to the DeployBean which allows the different names to be used for the 
artifacts beiong installed.

I have tested this against an ejb build which installs and deploys an 
ejb-1.x.jar and a ejb-client-1.x.jar.

Other build types are not affected and still work,
The overide property is optional.

The overide is invoked as per the example below:
  <!--========================================================-->
  <!-- Install the ejb client in the local repository         -->
  <!--========================================================-->    
  <goal name="ejb:install-client"
        prereqs="ejb:ejb-client"
        description="Install the ejb client in the local repository">
     
     <artifact:install
        artifact="${maven.ejb.build.dir}/${maven.ejb.client.final.name}.jar"
        artifactIdOveride="${maven.ejb.client.artifact.id}"
        type="jar"
        project="${pom}"/> 
  
  </goal>


Below I have pasted a patch in eclipse unified format.
I dont have access to work on this issue in Jira, and therefore cannot find the 
file upload button (or I am being dumb.)
I can email the patch to any comitter that can apply it.

Regards,
Neil.

Index: project.xml
===================================================================
RCS file: /home/cvspublic/maven-plugins/artifact/project.xml,v
retrieving revision 1.36
diff -u -r1.36 project.xml
--- project.xml 23 Oct 2004 12:11:50 -0000      1.36
+++ project.xml 3 Dec 2004 15:37:19 -0000
@@ -25,7 +25,7 @@
   <name>Maven Artifact Plugin</name>
   <!-- WARNING: some dependency checks will break if we get to 1.10, need to 
go to 2.0 from there -->
 
-  <currentVersion>1.4.1</currentVersion>
+  <currentVersion>1.4.2</currentVersion>
   <description>Tools to manage artifacts and deployment.</description>
   <shortDescription>Tools to manage artifacts and deployment</shortDescription>
   <url>http://maven.apache.org/reference/plugins/artifact/</url>
@@ -61,6 +61,11 @@
       <id>1.4.1</id>
       <name>1.4.1</name>
       <tag>MAVEN_ARTIFACT_1_4_1</tag>
+    </version>
+    <version>
+      <id>1.4.2</id>
+      <name>1.4.2</name>
+      <tag>MAVEN_ARTIFACT_1_4_2</tag>
     </version>
   </versions>
   <developers/>
Index: src/main/org/apache/maven/artifact/deployer/DeployBean.java
===================================================================
RCS file: 
/home/cvspublic/maven-plugins/artifact/src/main/org/apache/maven/artifact/deployer/DeployBean.java,v
retrieving revision 1.6
diff -u -r1.6 DeployBean.java
--- src/main/org/apache/maven/artifact/deployer/DeployBean.java 23 Jun 2004 
13:04:28 -0000      1.6
+++ src/main/org/apache/maven/artifact/deployer/DeployBean.java 3 Dec 2004 
15:37:19 -0000
@@ -22,7 +22,6 @@
 import org.apache.maven.artifact.deployer.DefaultArtifactDeployer;
 import org.apache.maven.project.Project;
 import org.apache.maven.repository.ArtifactTypeHandler;
-import org.apache.maven.repository.DefaultArtifactTypeHandler;
 
 /**
  * 
@@ -40,6 +39,7 @@
     private String artifact = null;
     private String type = null;
     private ArtifactTypeHandler typeHandler = null;
+    private String artifactIdOveride = null;
 
     public DeployBean()
     {  
@@ -79,6 +79,22 @@
     }
 
     /**
+     * @return String
+     */
+    public String getArtifactIdOveride()
+    {
+        return artifactIdOveride;
+    }
+
+    /**
+     * @param artifact
+     */
+    public void setArtifactIdOveride(String artifactIdOveride)
+    {
+        this.artifactIdOveride = artifactIdOveride;
+    }
+
+    /**
      * @return
      */
     public Project getProject()
@@ -131,7 +147,14 @@
         }
         if (typeHandler == null)
         {
-            typeHandler = new DefaultArtifactTypeHandler();
+            //TODO NC - remove debug
+            System.out.println("artifactIdOveride = " + artifactIdOveride);
+
+            NamedArtifactTypeHandler namedHandler = new 
NamedArtifactTypeHandler();
+            if (artifactIdOveride != null) {
+                namedHandler.setArtifactId(artifactIdOveride);
+            }
+            typeHandler = namedHandler;
         }
     }
 
Index: src/main/org/apache/maven/artifact/deployer/NamedArtifactTypeHandler.java
===================================================================
RCS file: 
src/main/org/apache/maven/artifact/deployer/NamedArtifactTypeHandler.java
diff -N 
src/main/org/apache/maven/artifact/deployer/NamedArtifactTypeHandler.java
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ src/main/org/apache/maven/artifact/deployer/NamedArtifactTypeHandler.java   
1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,81 @@
+package org.apache.maven.artifact.deployer;
+
+/* ====================================================================
+ *   Copyright 2001-2004 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.project.Project;
+import org.apache.maven.repository.DefaultArtifactTypeHandler;
+
+/**
+ *  This handler allows the default artifactId to be overridden.
+ * 
+ * @author <a href="mailto:[EMAIL PROTECTED]">Neil Crow</a> 
+ */
+public class NamedArtifactTypeHandler extends DefaultArtifactTypeHandler
+{
+    private String artifactId = null;
+
+    /**
+     * @return String
+     */
+    public String getArtifactId()
+    {
+        return artifactId;
+    }
+
+    /**
+     * @param artifactId - The artifactId which overides the pom default.
+     */
+    public void setArtifactId(String artifactId)
+    {
+        this.artifactId = artifactId;
+    }
+
+
+    /**
+     * Map an artifact to a repository path.
+     * 
+     * @param project the project for the artifact
+     * @param type  The type of the artifact 
+     * @param version  The version of the artifact (may be a snapshot)
+     * @return the path
+     */
+    public String constructRepositoryFullPath(String type, Project project, 
String version)
+    {
+        if (artifactId == null) {
+            artifactId = project.getArtifactId();
+        }
+        StringBuffer path = new 
StringBuffer(constructRepositoryDirectoryPath(type, project));
+        path.append(artifactId);
+        path.append("-");
+        path.append(version);
+        path.append(extensionForType(type));
+        return path.toString();
+    }
+
+    /** @deprecated plugin, ejb and uberjar should provide their own 
implementation. */
+    private String extensionForType(String type)
+    {
+        if (type.equals("uberjar") || type.equals("ejb") || 
type.equals("plugin")) {
+            return ".jar";
+        }
+        else {
+            return "." + type;
+        }
+    }
+}
+



---------------------------------------------------------------------
View this comment:
  http://jira.codehaus.org/browse/MPARTIFACT-35?page=comments#action_27405

---------------------------------------------------------------------
View the issue:
  http://jira.codehaus.org/browse/MPARTIFACT-35

Here is an overview of the issue:
---------------------------------------------------------------------
        Key: MPARTIFACT-35
    Summary: artifact goals should allow different names
       Type: Improvement

     Status: Closed
   Priority: Major
 Resolution: WON'T FIX

 Original Estimate: 3 hours
 Time Spent: Unknown
  Remaining: 3 hours

    Project: maven-artifact-plugin
   Versions:
             1.5

   Assignee: 
   Reporter: Felipe Leme

    Created: Sun, 1 Aug 2004 9:22 PM
    Updated: Fri, 3 Dec 2004 11:06 AM

Description:
It would be nice it <artifact> tags allows us to change the name of the 
artifact being installed/deployed. That wuold be really helpful when your 
project has 'secondary artifacts', like javadoc, zip files or a simple war with 
documents.

For instance, when you call javadoc:install, a jar file is created at target 
(PROJECT-version_javadoc.jar) but that file is installed as a .javadoc, even 
though the call to <artifact:install> uses the same name as the existing 
article on target:


<artifact:install
        artifact="${maven.javadoc.final.name}"
        type="javadoc"
        project="${pom}"/> 

In other, it would be nice if artifact:install (and deploy, deploysnaspshot, 
etc...) used the name passed on the artifact attribute (instead of always using 
${pom.artifactId}-version.${type}.

Felipe



---------------------------------------------------------------------
JIRA INFORMATION:
This message is automatically generated by JIRA.

If you think it was sent incorrectly contact one of the administrators:
   http://jira.codehaus.org/secure/Administrators.jspa

If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to