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

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Thu Feb 22 16:08:16 EST 2007


Author: pgier
Date: 2007-02-22 16:08:16 -0500 (Thu, 22 Feb 2007)
New Revision: 9710

Modified:
   labs/jbossbuild/trunk/projects/maven-plugins/jboss-deploy-maven-plugin/pom.xml
   labs/jbossbuild/trunk/projects/maven-plugins/jboss-deploy-maven-plugin/src/main/java/org/jboss/maven/plugins/deploy/JBossDeployMojo.java
   labs/jbossbuild/trunk/projects/maven-plugins/jboss-deploy-maven-plugin/src/main/resources/org/jboss/maven/plugins/deploy/component-info-template.xml
Log:
JBBUILD-340; Fixed a few things.  Added artifact list and includes list.


Modified: labs/jbossbuild/trunk/projects/maven-plugins/jboss-deploy-maven-plugin/pom.xml
===================================================================
--- labs/jbossbuild/trunk/projects/maven-plugins/jboss-deploy-maven-plugin/pom.xml	2007-02-22 20:18:15 UTC (rev 9709)
+++ labs/jbossbuild/trunk/projects/maven-plugins/jboss-deploy-maven-plugin/pom.xml	2007-02-22 21:08:16 UTC (rev 9710)
@@ -7,6 +7,7 @@
     <version>1</version>
   </parent>
   <modelVersion>4.0.0</modelVersion>
+  <groupId>jboss.maven-plugins</groupId>
   <artifactId>jboss-deploy-maven-plugin</artifactId>
   <packaging>maven-plugin</packaging>
   <name>JBoss Deploy Maven Plugin</name>
@@ -37,7 +38,7 @@
     <dependency>
       <groupId>org.apache.maven</groupId>
       <artifactId>maven-core</artifactId>
-      <version>2.0.4</version>
+      <version>2.0</version>
     </dependency>
     <dependency>
       <groupId>org.apache.maven</groupId>
@@ -47,12 +48,17 @@
     <dependency>
       <groupId>org.apache.maven</groupId>
       <artifactId>maven-project</artifactId>
-      <version>2.0.4</version>
+      <version>2.0</version>
     </dependency>
     <dependency>
       <groupId>org.apache.maven</groupId>
       <artifactId>maven-artifact</artifactId>
-      <version>2.0.4</version>
+      <version>2.0</version>
     </dependency>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-model</artifactId>
+      <version>2.0</version>
+    </dependency>
   </dependencies>
 </project>

Modified: labs/jbossbuild/trunk/projects/maven-plugins/jboss-deploy-maven-plugin/src/main/java/org/jboss/maven/plugins/deploy/JBossDeployMojo.java
===================================================================
--- labs/jbossbuild/trunk/projects/maven-plugins/jboss-deploy-maven-plugin/src/main/java/org/jboss/maven/plugins/deploy/JBossDeployMojo.java	2007-02-22 20:18:15 UTC (rev 9709)
+++ labs/jbossbuild/trunk/projects/maven-plugins/jboss-deploy-maven-plugin/src/main/java/org/jboss/maven/plugins/deploy/JBossDeployMojo.java	2007-02-22 21:08:16 UTC (rev 9710)
@@ -9,11 +9,11 @@
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.nio.channels.FileChannel;
-import java.util.Enumeration;
 import java.util.List;
 import java.util.Properties;
 
 import org.apache.maven.artifact.Artifact;
+import org.apache.maven.model.License;
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.project.MavenProject;
@@ -42,6 +42,24 @@
    protected MavenProject project;
 
    /**
+    * Source control information.
+    * @parameter expression="${project.scm}"
+    * @required
+    * @readonly
+    */
+   private org.apache.maven.model.Scm scm;
+
+   /**
+    * License information.
+    * @parameter expression="${project.licenses}"
+    * @required
+    * @readonly
+    */
+   private List licenses;
+
+   //private org.apache.maven.model.License license;
+
+   /**
     * The Maven Plugin Object
     *
     * @parameter expression="${plugin.components}"
@@ -128,7 +146,7 @@
    private String jbossDeployRoot;
 
    /**
-    * Main execution path of the plugin.
+    * Main execution path of the plugin.  Generates component-info.xml, and copies jar files to repository location.
     */
    public void execute() throws MojoExecutionException
    {
@@ -137,12 +155,14 @@
       // Initialize local variables
       String artifactFileName = project.getArtifactId() + "." + project.getPackaging();
       String artifactFilePath = targetDirectory.toString() + fileSep + artifactFileName;
-      String artifactSourcesFilePath = targetDirectory.toString() + fileSep + project.getArtifactId() + "-sources" + "." + project.getPackaging();
-      String artifactJavadocFilePath = targetDirectory.toString() + fileSep + project.getArtifactId() + "-javadoc" + "." + project.getPackaging();
-      String artifactTestsFilePath = targetDirectory.toString() + fileSep + project.getArtifactId() + "-tests" + "." + project.getPackaging();
+      String artifactSourcesFilePath = targetDirectory.toString() + fileSep + project.getArtifactId() + "-sources"
+            + "." + project.getPackaging();
+      String artifactJavadocFilePath = targetDirectory.toString() + fileSep + project.getArtifactId() + "-javadoc"
+            + "." + project.getPackaging();
+      String artifactTestsFilePath = targetDirectory.toString() + fileSep + project.getArtifactId() + "-tests" + "."
+            + project.getPackaging();
       String deployToPath = jbossDeployRoot + fileSep + project.getGroupId() + fileSep + project.getArtifactId()
             + fileSep + project.getVersion() + fileSep;
-      //String deployToArtifact = deployToPath + "lib" + fileSep + artifactFileName;
 
       // Load template file
       InputStream templateInputStream = this.getClass().getResourceAsStream("component-info-template.xml");
@@ -176,18 +196,54 @@
       evaluateVariable(compInfoTemplate, "project.name", componentId + "-component-info");
       evaluateVariable(compInfoTemplate, "component.id", componentId);
       evaluateVariable(compInfoTemplate, "project.version", project.getVersion());
-      evaluateVariable(compInfoTemplate, "project.license", "lgpl");
+      if (licenses.size() == 0)
+      {
+         getLog().warn("No license specified in pom.xml.  Default lgpl license will be used.");
+         evaluateVariable(compInfoTemplate, "project.license", "lgpl");
+      }
+      else
+      {
+         License firstLicense = (License) licenses.get(0);
+         evaluateVariable(compInfoTemplate, "project.license", firstLicense.getName());
+      }
       if (project.getDescription() == null || project.getDescription().equals(""))
       {
          project.setDescription(project.getId());
       }
       evaluateVariable(compInfoTemplate, "project.description", project.getDescription());
 
+      // Create and set list of artifacts
+      StringBuffer artifacts = new StringBuffer();
+      artifacts.append("    <artifact id=\"" + artifactFileName + "\"/>\n");
+      if (new File(artifactTestsFilePath).exists())
+      {
+         artifacts.append("    <artifact id=\"" + project.getArtifactId() + "-tests." + project.getPackaging()
+               + "\"/>\n");
+      }
+      if (new File(artifactSourcesFilePath).exists())
+      {
+         artifacts.append("    <artifact id=\"" + project.getArtifactId() + "-sources." + project.getPackaging()
+               + "\"/>\n");
+      }
+      if (new File(artifactJavadocFilePath).exists())
+      {
+         artifacts.append("    <artifact id=\"" + project.getArtifactId() + "-javadoc." + project.getPackaging()
+               + "\"/>\n");
+      }
+      evaluateVariable(compInfoTemplate, "artifacts", artifacts.toString());
+
+      // Create and set list of includes
+      StringBuffer includes = new StringBuffer();
+      includes.append("      <include input=\"" + artifactFileName + "\"/>");
+      evaluateVariable(compInfoTemplate, "includes", includes.toString());
+      //TODO: List dependencies = project.getDependencies();
+
       // Write the component info file
       try
       {
          File deployToDir = new File(deployToPath);
-         if (!deployToDir.exists()) {
+         if (!deployToDir.exists())
+         {
             deployToDir.mkdirs();
          }
          File compInfoFile = new File(deployToPath + "component-info.xml");
@@ -200,24 +256,19 @@
          ioe.printStackTrace();
       }
 
-      Enumeration keys = projectProperties.keys();
-      while (keys.hasMoreElements())
-      {
-         String key = (String) keys.nextElement();
-         getLog().info(key + ": " + projectProperties.getProperty(key));
-      }
-      getLog().info(projectProperties.size() + "");
-
       // Deploy lib directory.
       getLog().debug("Copying from: " + artifactFilePath);
       getLog().info("Deploying to: " + deployToPath);
       String deployToPathLib = deployToPath + "lib" + fileSep;
-      try {
+      try
+      {
          copyFileToDir(artifactFilePath, deployToPathLib);
          copyFileToDir(artifactTestsFilePath, deployToPathLib);
          copyFileToDir(artifactSourcesFilePath, deployToPathLib);
          copyFileToDir(artifactJavadocFilePath, deployToPathLib);
-      } catch (IOException ioe) {
+      }
+      catch (IOException ioe)
+      {
          throw new MojoExecutionException("Problem copying artifacts: " + ioe.getMessage());
       }
    }
@@ -232,7 +283,8 @@
    public void copyFileToDir(String src, String dest) throws IOException
    {
       File srcFile = new File(src);
-      if (!srcFile.exists()) {
+      if (!srcFile.exists())
+      {
          return;
       }
       File destDir = new File(dest);

Modified: labs/jbossbuild/trunk/projects/maven-plugins/jboss-deploy-maven-plugin/src/main/resources/org/jboss/maven/plugins/deploy/component-info-template.xml
===================================================================
--- labs/jbossbuild/trunk/projects/maven-plugins/jboss-deploy-maven-plugin/src/main/resources/org/jboss/maven/plugins/deploy/component-info-template.xml	2007-02-22 20:18:15 UTC (rev 9709)
+++ labs/jbossbuild/trunk/projects/maven-plugins/jboss-deploy-maven-plugin/src/main/resources/org/jboss/maven/plugins/deploy/component-info-template.xml	2007-02-22 21:08:16 UTC (rev 9710)
@@ -1,17 +1,14 @@
-
+<?xml version="1.0" encoding="UTF-8"?>
 <project name="${project.name}">
   <component id="${component.id}"
              licenseType="${project.license}"
              version="${project.version}"
              description="${project.description}"
-             >
-  
-    <artifact id="jboss-common-core.jar"/>
-    <artifact id="jboss-common-core-sources.jar"/>
-
+             > 
+              
+${artifacts}
     <export>
-      <include input="jboss-common-core.jar"/>
+${includes}
     </export>
-
   </component>
 </project>
\ No newline at end of file




More information about the jboss-svn-commits mailing list