[jboss-svn-commits] JBL Code SVN: r11076 - in labs/jbossbuild/maven-plugins/trunk/jboss-deploy-maven-plugin: src/main/java/org/jboss/maven/plugins/deploy and 1 other directory.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Tue Apr 17 14:42:48 EDT 2007


Author: pgier
Date: 2007-04-17 14:42:48 -0400 (Tue, 17 Apr 2007)
New Revision: 11076

Modified:
   labs/jbossbuild/maven-plugins/trunk/jboss-deploy-maven-plugin/pom.xml
   labs/jbossbuild/maven-plugins/trunk/jboss-deploy-maven-plugin/src/main/java/org/jboss/maven/plugins/deploy/JBossDeployMojo.java
Log:
JBBUILD-358; Changes so that null classifiers are better handled for attached artifacts.

Modified: labs/jbossbuild/maven-plugins/trunk/jboss-deploy-maven-plugin/pom.xml
===================================================================
--- labs/jbossbuild/maven-plugins/trunk/jboss-deploy-maven-plugin/pom.xml	2007-04-17 18:27:36 UTC (rev 11075)
+++ labs/jbossbuild/maven-plugins/trunk/jboss-deploy-maven-plugin/pom.xml	2007-04-17 18:42:48 UTC (rev 11076)
@@ -2,7 +2,7 @@
   <parent>
     <groupId>jboss</groupId>
     <artifactId>jboss-parent</artifactId>
-    <version>1</version>
+    <version>2</version>
   </parent>
   <modelVersion>4.0.0</modelVersion>
   <groupId>jboss.maven-plugins</groupId>
@@ -58,5 +58,11 @@
       <artifactId>commons-io</artifactId>
       <version>1.3.1</version>
     </dependency>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>3.8.1</version>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
 </project>
\ No newline at end of file

Modified: labs/jbossbuild/maven-plugins/trunk/jboss-deploy-maven-plugin/src/main/java/org/jboss/maven/plugins/deploy/JBossDeployMojo.java
===================================================================
--- labs/jbossbuild/maven-plugins/trunk/jboss-deploy-maven-plugin/src/main/java/org/jboss/maven/plugins/deploy/JBossDeployMojo.java	2007-04-17 18:27:36 UTC (rev 11075)
+++ labs/jbossbuild/maven-plugins/trunk/jboss-deploy-maven-plugin/src/main/java/org/jboss/maven/plugins/deploy/JBossDeployMojo.java	2007-04-17 18:42:48 UTC (rev 11076)
@@ -109,10 +109,19 @@
    private Map imports;
 
    /**
-    * This is the list of artifacts to be added to the classpath.
+    * This is the list of artifacts exported from this project.
+    * By default the project artifact will be included in this list.
+    * If there is no project artifact, this plugin will look for an attached
+    * artifact that matches the project name, and attempt to attach it.
+    * The list of exports can manually be set with the following configuration.
+    * <exports>
+    *   <param>file1.jar</param>
+    *   <param>file2.jar</param>
+    * </exports>
+    * 
     * @parameter
     */
-   private List exports;
+   private Set<String> exports;
 
    /**
     * Main execution path of the plugin.  Generates component-info.xml, and copies jar files to repository location.
@@ -129,6 +138,10 @@
          return;
       }
 
+      if (exports == null) {
+         exports = new HashSet<String>();
+      }
+      
       // Initialize some local variables
       File deployToDir = new File(jbossDeployRoot + fileSep + project.getGroupId().replace('.', '/') + fileSep
             + project.getArtifactId() + fileSep + project.getVersion() + fileSep);
@@ -210,12 +223,25 @@
       {
          Artifact artifact = (Artifact) obj;
          this.getLog().debug(artifact.getArtifactId());
-         String artifactLine = "    <artifact id=\"" + artifact.getArtifactId() + "-" + artifact.getClassifier()
+         String classifierStr = artifact.getClassifier();
+         if (classifierStr == null) {
+            classifierStr = "";
+            if (artifact.getArtifactId().equals(project.getArtifactId())) {
+               exports.add(artifact.getArtifactId() + "." + artifact.getType());
+            }
+            if (project.getArtifact() != null) {
+               getLog().warn("Attached artifact with same name as default artifact.");
+               getLog().warn("This could be caused by an assembly descriptor with no id.");
+            }
+         } else {
+            classifierStr = "-" + classifierStr;
+         }
+         String artifactLine = "    <artifact id=\"" + artifact.getArtifactId() + classifierStr
                + ".jar" + "\"/>\n";
          if (artifactSet.contains(artifactLine))
          {
             this.getLog().warn(
-                  "Duplicate attached artifact found: " + artifact.getArtifactId() + "-" + artifact.getClassifier()
+                  "Duplicate attached artifact found: " + artifact.getArtifactId() + classifierStr
                         + ".jar");
          }
          artifactSet.add(artifactLine);
@@ -237,48 +263,20 @@
       }
       evaluateVariable(compInfoTemplate, "artifacts", artifacts.toString());
 
-      // Create and set list of includes
+      // Create and set list of includes for export
       StringBuffer exportsString = new StringBuffer();
       if (project.getArtifact().getFile() != null)
       {
-         exportsString.append("      <include input=\"" + project.getArtifact().getFile().getName() + "\"/>\n");
+         exports.add(project.getArtifact().getFile().getName());
       }
-      if (exports != null)
+      for (Object export : exports)
       {
-         for (Object export : exports)
-         {
-            exportsString.append("      <include input=\"" + export + "\"/>\n");
-         }
+         exportsString.append("      <include input=\"" + export + "\"/>\n");
       }
       evaluateVariable(compInfoTemplate, "includes", exportsString.toString());
 
-      // Generate list of imports
-      StringBuffer importsString = new StringBuffer();
-      if (imports != null)
-      {
-         Set componentNames = imports.keySet();
-         for (Object component : componentNames)
-         {
-            importsString.append("    <import componentref=\"" + component.toString().replace('.', '/') + "\">\n");
-            importsString.append("      <compatible version=\"" + imports.get(component) + "\"/>\n");
-            importsString.append("    </import>\n");
-         }
-      }
-      if (this.generateImports)
-      {
-         List dependencies = project.getDependencies();
-         for (Object obj : dependencies)
-         {
-            Dependency dep = (Dependency) obj;
-            if (dep.getScope() == null || !dep.getScope().equals("test")) {
-               importsString.append("    <import componentref=\"" + dep.getGroupId().replace('.', '/') + "/"
-                     + dep.getArtifactId() + "\">\n");
-               importsString.append("      <compatible version=\"" + dep.getVersion() + "\"/>\n");
-               importsString.append("    </import>\n");
-            }
-         }
-      }
-      evaluateVariable(compInfoTemplate, "imports", importsString.toString());
+      // Generate the list of imports
+      evaluateVariable(compInfoTemplate, "imports", generateImportsString());
 
       // Write the component info file
       File compInfoFile = new File(deployToDir + fileSep + "component-info.xml");
@@ -313,6 +311,41 @@
       }
    }
 
+   /** 
+    * Creates the list of imports to include in the component-info.xml
+    */
+   private String generateImportsString()
+   {
+      StringBuffer importsString = new StringBuffer();
+      if (imports != null)
+      {
+         Set componentNames = imports.keySet();
+         for (Object component : componentNames)
+         {
+            importsString.append("    <import componentref=\"" + component.toString().replace('.', '/') + "\">\n");
+            importsString.append("      <compatible version=\"" + imports.get(component) + "\"/>\n");
+            importsString.append("    </import>\n");
+         }
+      }
+      if (this.generateImports)
+      {
+         List dependencies = project.getDependencies();
+         for (Object obj : dependencies)
+         {
+            Dependency dep = (Dependency) obj;
+            if (dep.getScope() == null || !dep.getScope().equals("test")) {
+               importsString.append("    <import componentref=\"" + dep.getGroupId().replace('.', '/') + "/"
+                     + dep.getArtifactId() + "\">\n");
+               importsString.append("      <compatible version=\"" + dep.getVersion() + "\"/>\n");
+               importsString.append("    </import>\n");
+            }
+         }
+      }
+      return importsString.toString();
+   }
+
+   
+   
    /**
     * Replace all instances of var with value in the given buffer.
     * For example if var is "project.name", this method will search




More information about the jboss-svn-commits mailing list