You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by "Jason Mowat (JIRA)" <ji...@codehaus.org> on 2005/08/05 01:10:57 UTC

[jira] Created: (MPARTIFACT-57) artifact:deploy needs deploy name to be overridable

artifact:deploy needs deploy name to be overridable
---------------------------------------------------

         Key: MPARTIFACT-57
         URL: http://jira.codehaus.org/browse/MPARTIFACT-57
     Project: maven-artifact-plugin
        Type: Improvement
    Versions: 1.4.1    
 Environment: WinXP; Linux
 Reporter: Jason Mowat
    Priority: Minor


When using the artifact:deploy command in my maven.xml, I am unable to control the destination name of my deployed JAR as it is constructed from the POM.  This is problematic when trying to deploy ejb-client JARs.

Brett Porter posted the problem with a fix last year on the maven-ejb JIRA.  I find it a little odd that he is the project lead for artifact when it seems that his proposed fix is for artifact.  Maybe I'm missing something.  Anyways, here it is again:

I have not reviewed this, but just making sure the patch doesn't get lost. Original is MPARTIFACT-35.

from Neil Crow:

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/&lt;/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:neilc@strate.co.za">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;
+ }
+ }
+}
+


-- 
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
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


[jira] Closed: (MPARTIFACT-57) artifact:deploy needs deploy name to be overridable

Posted by "Lukas Theussl (JIRA)" <ji...@codehaus.org>.
     [ http://jira.codehaus.org/browse/MPARTIFACT-57?page=all ]
     
Lukas Theussl closed MPARTIFACT-57:
-----------------------------------

     Resolution: Fixed
    Fix Version: 1.7

> artifact:deploy needs deploy name to be overridable
> ---------------------------------------------------
>
>          Key: MPARTIFACT-57
>          URL: http://jira.codehaus.org/browse/MPARTIFACT-57
>      Project: maven-artifact-plugin
>         Type: Improvement
>     Versions: 1.4.1
>  Environment: WinXP; Linux
>     Reporter: Jason Mowat
>     Priority: Minor
>      Fix For: 1.7

>
> Original Estimate: 2 hours
>         Remaining: 2 hours
>
> When using the artifact:deploy command in my maven.xml, I am unable to control the destination name of my deployed JAR as it is constructed from the POM.  This is problematic when trying to deploy ejb-client JARs.
> Brett Porter posted the problem with a fix last year on the maven-ejb JIRA.  I find it a little odd that he is the project lead for artifact when it seems that his proposed fix is for artifact.  Maybe I'm missing something.  Anyways, here it is again:
> I have not reviewed this, but just making sure the patch doesn't get lost. Original is MPARTIFACT-35.
> from Neil Crow:
> 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/&lt;/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:neilc@strate.co.za">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;
> + }
> + }
> +}
> +

-- 
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
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org