[jboss-svn-commits] JBL Code SVN: r14214 - in labs/jbossbuild/maven-plugins/tags: maven-jboss-retro-plugin-1.0-beta-1 and 1 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Tue Aug 14 12:40:34 EDT 2007


Author: pgier
Date: 2007-08-14 12:40:33 -0400 (Tue, 14 Aug 2007)
New Revision: 14214

Added:
   labs/jbossbuild/maven-plugins/tags/maven-jboss-retro-plugin-1.0-beta-1/
   labs/jbossbuild/maven-plugins/tags/maven-jboss-retro-plugin-1.0-beta-1/pom.xml
   labs/jbossbuild/maven-plugins/tags/maven-jboss-retro-plugin-1.0-beta-1/src/
   labs/jbossbuild/maven-plugins/tags/maven-jboss-retro-plugin-1.0-beta-1/src/main/java/org/jboss/maven/plugins/retro/AbstractWeaveMojo.java
   labs/jbossbuild/maven-plugins/tags/maven-jboss-retro-plugin-1.0-beta-1/src/main/java/org/jboss/maven/plugins/retro/WeaveDependenciesMojo.java
   labs/jbossbuild/maven-plugins/tags/maven-jboss-retro-plugin-1.0-beta-1/src/main/java/org/jboss/maven/plugins/retro/WeaveMojo.java
   labs/jbossbuild/maven-plugins/tags/maven-jboss-retro-plugin-1.0-beta-1/src/main/java/org/jboss/maven/plugins/retro/WeaveTestsMojo.java
Removed:
   labs/jbossbuild/maven-plugins/tags/maven-jboss-retro-plugin-1.0-beta-1/pom.xml
   labs/jbossbuild/maven-plugins/tags/maven-jboss-retro-plugin-1.0-beta-1/src/
   labs/jbossbuild/maven-plugins/tags/maven-jboss-retro-plugin-1.0-beta-1/src/main/java/org/jboss/maven/plugins/retro/WeaveDependenciesMojo.java
   labs/jbossbuild/maven-plugins/tags/maven-jboss-retro-plugin-1.0-beta-1/src/main/java/org/jboss/maven/plugins/retro/WeaveMojo.java
   labs/jbossbuild/maven-plugins/tags/maven-jboss-retro-plugin-1.0-beta-1/src/main/java/org/jboss/maven/plugins/retro/WeaveTestsMojo.java
Log:
[maven-release-plugin]  copy for tag maven-jboss-retro-plugin-1.0-beta-1

Copied: labs/jbossbuild/maven-plugins/tags/maven-jboss-retro-plugin-1.0-beta-1 (from rev 14171, labs/jbossbuild/maven-plugins/trunk/maven-jboss-retro-plugin)

Deleted: labs/jbossbuild/maven-plugins/tags/maven-jboss-retro-plugin-1.0-beta-1/pom.xml
===================================================================
--- labs/jbossbuild/maven-plugins/trunk/maven-jboss-retro-plugin/pom.xml	2007-08-13 15:03:51 UTC (rev 14171)
+++ labs/jbossbuild/maven-plugins/tags/maven-jboss-retro-plugin-1.0-beta-1/pom.xml	2007-08-14 16:40:33 UTC (rev 14214)
@@ -1,157 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-  
-  <modelVersion>4.0.0</modelVersion>
-  
-  <groupId>org.jboss.maven.plugins</groupId>
-  <artifactId>maven-jboss-retro-plugin</artifactId>
-  <packaging>maven-plugin</packaging>
-  <name>Maven JBoss Retro Plugin</name>
-  <version>1.0-beta-2-SNAPSHOT</version>
-  <url>http://labs.jboss.com/maven-jboss-retro-plugin</url>
-  <description>Maven plugin for jboss retro</description>
-  <inceptionYear>2007</inceptionYear>
-  
-  <scm>
-    <connection>scm:svn:http://anonsvn.labs.jboss.org/labs/jbossbuild/maven-plugins/trunk/jboss-retro-maven-plugin</connection>
-    <developerConnection>scm:svn:https://svn.labs.jboss.org/labs/jbossbuild/maven-plugins/trunk/jboss-retro-maven-plugin</developerConnection>
-  </scm>
-  
-  <issueManagement>
-    <system>jira</system>
-    <url>http://jira.jboss.com/jira/browse/JBBUILD</url>
-  </issueManagement>
-  
-  <licenses>
-    <license>
-      <name>GNU Lesser General Public License</name>
-      <url>http://www.gnu.org/copyleft/lesser.html</url>
-      <distribution>repo</distribution>
-    </license>
-  </licenses>
-
-  <developers>
-    <developer>
-      <id>pgier</id>
-      <name>Paul Gier</name>
-      <organization>JBoss, a division of Red Hat, Inc</organization>
-      <organizationUrl>http://www.jboss.org</organizationUrl>
-      <timezone>-5</timezone>
-    </developer>
-  </developers>
-  
-  <organization>
-    <name>JBoss, a division of Red Hat, Inc</name>
-    <url>http://www.jboss.org</url>
-  </organization>
-  
-  <build>
-    <extensions>
-      <extension>
-	      <groupId>org.apache.maven.wagon</groupId>
-	      <artifactId>wagon-webdav</artifactId>
-	      <version>1.0-beta-2</version>
-      </extension>
-    </extensions>
-    <plugins>
-      <plugin>
-        <artifactId>maven-compiler-plugin</artifactId>
-        <configuration>
-          <optimize>true</optimize>
-          <source>1.5</source>
-          <target>1.5</target>
-        </configuration>
-      </plugin>
-      <plugin>
-        <artifactId>maven-release-plugin</artifactId>
-        <configuration>
-          <tagBase>https://svn.labs.jboss.org/labs/jbossbuild/maven-plugins/tags</tagBase>
-        </configuration>
-      </plugin>
-    </plugins>
-  </build>
-  
-  <reporting>
-    <plugins>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-javadoc-plugin</artifactId>
-        <configuration>
-          <minmemory>128m</minmemory>
-          <maxmemory>512</maxmemory>
-        </configuration>
-      </plugin>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-jxr-plugin</artifactId>
-      </plugin>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-plugin-plugin</artifactId>
-      </plugin>
-    </plugins>
-  </reporting>
-
-  <dependencies>
-    <dependency>
-      <groupId>org.jboss</groupId>
-      <artifactId>jboss-retro</artifactId>
-      <version>1.1.3-SNAPSHOT</version>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.maven</groupId>
-      <artifactId>maven-plugin-api</artifactId>
-      <version>2.0</version>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.maven</groupId>
-      <artifactId>maven-model</artifactId>
-      <version>2.0</version>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.maven</groupId>
-      <artifactId>maven-artifact</artifactId>
-      <version>2.0</version>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.maven</groupId>
-      <artifactId>maven-project</artifactId>
-      <version>2.0.4</version>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.maven</groupId>
-      <artifactId>maven-archiver</artifactId>
-      <version>2.2</version>
-    </dependency>
-    <dependency>
-      <groupId>commons-io</groupId>
-      <artifactId>commons-io</artifactId>
-      <version>1.2</version>
-    </dependency>
-    <dependency>
-      <groupId>org.codehaus.plexus</groupId>
-      <artifactId>plexus-utils</artifactId>
-      <version>1.4.1</version>
-    </dependency>
-  </dependencies>
-  
-  <distributionManagement>
-    <repository>
-      <!-- Copy the distribution jar file to a local checkout of the maven repository 
-        -  This variable can be set in $MAVEN_HOME/conf/settings.xml -->
-      <id>repository.jboss.org</id>
-      <url>file://${maven.repository.root}</url>
-    </repository>
-    <snapshotRepository>
-      <id>snapshots.jboss.org</id>
-      <name>JBoss Snapshot Repository</name>
-      <url>dav:https://snapshots.jboss.org/maven2</url>
-    </snapshotRepository>
-    <site>
-      <id>www.jboss.org</id>
-      <name>www.jboss.org</name>
-      <!-- This should be set to a local checkout of the jboss.org/jbossretro freezone. -->
-      <url>file://${maven.jboss.retro.plugin.site.root}</url>
-    </site>
-  </distributionManagement>
-  
-</project>
\ No newline at end of file

Copied: labs/jbossbuild/maven-plugins/tags/maven-jboss-retro-plugin-1.0-beta-1/pom.xml (from rev 14213, labs/jbossbuild/maven-plugins/trunk/maven-jboss-retro-plugin/pom.xml)
===================================================================
--- labs/jbossbuild/maven-plugins/tags/maven-jboss-retro-plugin-1.0-beta-1/pom.xml	                        (rev 0)
+++ labs/jbossbuild/maven-plugins/tags/maven-jboss-retro-plugin-1.0-beta-1/pom.xml	2007-08-14 16:40:33 UTC (rev 14214)
@@ -0,0 +1,157 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  
+  <modelVersion>4.0.0</modelVersion>
+  
+  <groupId>org.jboss.maven.plugins</groupId>
+  <artifactId>maven-jboss-retro-plugin</artifactId>
+  <packaging>maven-plugin</packaging>
+  <name>Maven JBoss Retro Plugin</name>
+  <version>1.0-beta-1</version>
+  <url>http://labs.jboss.com/maven-jboss-retro-plugin</url>
+  <description>Maven plugin for jboss retro</description>
+  <inceptionYear>2007</inceptionYear>
+  
+  <scm>
+    <connection>scm:svn:http://anonsvn.labs.jboss.org/labs/jbossbuild/maven-plugins/tags/maven-jboss-retro-plugin-1.0-beta-1</connection>
+    <developerConnection>scm:svn:https://svn.labs.jboss.org/labs/jbossbuild/maven-plugins/tags/maven-jboss-retro-plugin-1.0-beta-1</developerConnection>
+  </scm>
+  
+  <issueManagement>
+    <system>jira</system>
+    <url>http://jira.jboss.com/jira/browse/JBBUILD</url>
+  </issueManagement>
+  
+  <licenses>
+    <license>
+      <name>GNU Lesser General Public License</name>
+      <url>http://www.gnu.org/copyleft/lesser.html</url>
+      <distribution>repo</distribution>
+    </license>
+  </licenses>
+
+  <developers>
+    <developer>
+      <id>pgier</id>
+      <name>Paul Gier</name>
+      <organization>JBoss, a division of Red Hat, Inc</organization>
+      <organizationUrl>http://www.jboss.org</organizationUrl>
+      <timezone>-5</timezone>
+    </developer>
+  </developers>
+  
+  <organization>
+    <name>JBoss, a division of Red Hat, Inc</name>
+    <url>http://www.jboss.org</url>
+  </organization>
+  
+  <build>
+    <extensions>
+      <extension>
+	      <groupId>org.apache.maven.wagon</groupId>
+	      <artifactId>wagon-webdav</artifactId>
+	      <version>1.0-beta-2</version>
+      </extension>
+    </extensions>
+    <plugins>
+      <plugin>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <configuration>
+          <optimize>true</optimize>
+          <source>1.5</source>
+          <target>1.5</target>
+        </configuration>
+      </plugin>
+      <plugin>
+        <artifactId>maven-release-plugin</artifactId>
+        <configuration>
+          <tagBase>https://svn.labs.jboss.org/labs/jbossbuild/maven-plugins/tags</tagBase>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+  
+  <reporting>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-javadoc-plugin</artifactId>
+        <configuration>
+          <minmemory>128m</minmemory>
+          <maxmemory>512</maxmemory>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-jxr-plugin</artifactId>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-plugin-plugin</artifactId>
+      </plugin>
+    </plugins>
+  </reporting>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.jboss</groupId>
+      <artifactId>jboss-retro</artifactId>
+      <version>1.1.2</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-plugin-api</artifactId>
+      <version>2.0</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-model</artifactId>
+      <version>2.0</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-artifact</artifactId>
+      <version>2.0</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-project</artifactId>
+      <version>2.0.4</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-archiver</artifactId>
+      <version>2.2</version>
+    </dependency>
+    <dependency>
+      <groupId>commons-io</groupId>
+      <artifactId>commons-io</artifactId>
+      <version>1.2</version>
+    </dependency>
+    <dependency>
+      <groupId>org.codehaus.plexus</groupId>
+      <artifactId>plexus-utils</artifactId>
+      <version>1.4.1</version>
+    </dependency>
+  </dependencies>
+  
+  <distributionManagement>
+    <repository>
+      <!-- Copy the distribution jar file to a local checkout of the maven repository 
+        -  This variable can be set in $MAVEN_HOME/conf/settings.xml -->
+      <id>repository.jboss.org</id>
+      <url>file://${maven.repository.root}</url>
+    </repository>
+    <snapshotRepository>
+      <id>snapshots.jboss.org</id>
+      <name>JBoss Snapshot Repository</name>
+      <url>dav:https://snapshots.jboss.org/maven2</url>
+    </snapshotRepository>
+    <site>
+      <id>www.jboss.org</id>
+      <name>www.jboss.org</name>
+      <!-- This should be set to a local checkout of the jboss.org/jbossretro freezone. -->
+      <url>file://${maven.jboss.retro.plugin.site.root}</url>
+    </site>
+  </distributionManagement>
+  
+</project>
\ No newline at end of file

Copied: labs/jbossbuild/maven-plugins/tags/maven-jboss-retro-plugin-1.0-beta-1/src (from rev 14170, labs/jbossbuild/maven-plugins/trunk/maven-jboss-retro-plugin/src)

Copied: labs/jbossbuild/maven-plugins/tags/maven-jboss-retro-plugin-1.0-beta-1/src/main/java/org/jboss/maven/plugins/retro/AbstractWeaveMojo.java (from rev 14171, labs/jbossbuild/maven-plugins/trunk/maven-jboss-retro-plugin/src/main/java/org/jboss/maven/plugins/retro/AbstractWeaveMojo.java)
===================================================================
--- labs/jbossbuild/maven-plugins/tags/maven-jboss-retro-plugin-1.0-beta-1/src/main/java/org/jboss/maven/plugins/retro/AbstractWeaveMojo.java	                        (rev 0)
+++ labs/jbossbuild/maven-plugins/tags/maven-jboss-retro-plugin-1.0-beta-1/src/main/java/org/jboss/maven/plugins/retro/AbstractWeaveMojo.java	2007-08-14 16:40:33 UTC (rev 14214)
@@ -0,0 +1,177 @@
+package org.jboss.maven.plugins.retro;
+
+import java.io.File;
+import java.util.List;
+
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.project.MavenProject;
+import org.codehaus.plexus.util.cli.CommandLineException;
+import org.codehaus.plexus.util.cli.CommandLineUtils;
+import org.codehaus.plexus.util.cli.Commandline;
+import org.codehaus.plexus.util.cli.StreamConsumer;
+import org.jboss.weaver.Main;
+
+/**
+ * Abstract parent of weaver mojos.
+ * @author pgier
+ *
+ */
+public abstract class AbstractWeaveMojo extends AbstractMojo
+{
+   public static final String JBOSS_RETRO_ARTIFACTID = "jboss-retro";
+   
+   protected final String fileSep = File.separator;
+
+   protected final String pathSep = File.pathSeparator;
+
+   /**
+    * The Maven Project Object
+    *
+    * @parameter expression="${project}"
+    * @required
+    * @readonly
+    */
+   protected MavenProject project;
+
+   /**
+    * The Maven Project Helper Object
+    *
+    * @component
+    * @required
+    * @readonly
+    */
+   protected org.apache.maven.project.MavenProjectHelper projectHelper;
+
+   /**
+    * The plugin dependencies.
+    *
+    * @parameter expression="${plugin.artifacts}"
+    * @required
+    * @readonly
+    */
+   protected List pluginArtifacts;
+
+   /**
+    * Include verbose output.
+    * @parameter default-value="false"
+    */
+   protected boolean verbose = false;
+
+   /**
+    * Use the system classpath.
+    * @parameter default-value="false"
+    */
+   protected boolean useSystemClasspath = false;
+   
+   /**
+    * Suppress output information.
+    * @parameter default-value="false"
+    */
+   protected boolean suppress = false;
+   
+   /**
+    * The Weaver class to use for weaving the classes.
+    * Defaults to org.jboss.weaver.Weaver
+    * Any subclass of org.jboss.weaver.Weaver can be used.
+    * To compile from jdk1.5 to jdk1.4, set this to "org.jboss.weaver.retro.WeaverRetroJdk14".
+    * 
+    * @parameter default-value="org.jboss.weaver.Weaver"
+    */
+   protected String weaverClass = "org.jboss.weaver.Weaver";
+
+   /**
+    * Classifier to append to the weaved output file (artifact).
+    * Defaults to null.  If the classifier is null, then the jar
+    * of the weaved classes will replace the main artifact.
+    * 
+    * @parameter
+    */
+   protected String classifier;
+   
+   /**
+    * Returns the path to which weaved files should be written.
+    * @return The output path.
+    */
+   protected abstract String getOutputPath();
+      
+   /**
+    * Fork the process to a separate jvm
+    * @parameter
+    */
+   protected boolean fork = true;
+   
+   /**
+    * Path to Java virtual machine to use when forking
+    * @parameter
+    */
+   protected String jvm;
+   
+   
+   protected String getJarClassifier() 
+   {
+      return this.classifier;
+   }
+
+   /**
+    * Consume and log command output from the retro process
+    * @author pgier
+    */
+   public class MojoLogStreamConsumer implements StreamConsumer
+   {
+      public void consumeLine(String line)
+      {
+         getLog().info(line);
+      }
+   }
+   
+   public void doWeave(String classpath, String [] args) throws Exception
+   {
+      if (fork)
+      {
+         Commandline cli = new Commandline();
+         
+         if ( jvm == null || jvm.equals( "" ) )
+         {
+             // use the same JVM as the one used to run Maven (the "java.home" one)
+             jvm = System.getProperty( "java.home" ) + File.separator + "bin" + File.separator + "java";
+             getLog().debug( "Using JVM: " + jvm );
+         }
+
+         cli.setExecutable( jvm );
+         String [] jvmArgs = new String[3];
+         jvmArgs[0] = "-cp";
+         jvmArgs[1] = classpath;
+         jvmArgs[2] = Main.class.getName();
+         cli.addArguments(jvmArgs);
+         
+         cli.addArguments(args);
+         
+         StreamConsumer out = new MojoLogStreamConsumer();
+         StreamConsumer err = new MojoLogStreamConsumer();
+
+         getLog().debug("Forking Command Line: ");
+         getLog().debug(cli.toString());
+         getLog().debug("");
+         
+         try
+         {
+            int returnCode = CommandLineUtils.executeCommandLine( cli, out, err );
+            if ( returnCode != 0)
+            {
+               throw new MojoExecutionException("There were errors during the weave");
+            }
+         }
+         catch ( CommandLineException e )
+         {
+            throw new MojoExecutionException( "Error while executing forked tests.", e );
+         }
+         
+      }
+      else
+      {
+         Main.main(args);
+      }
+      
+   }     
+}

Deleted: labs/jbossbuild/maven-plugins/tags/maven-jboss-retro-plugin-1.0-beta-1/src/main/java/org/jboss/maven/plugins/retro/WeaveDependenciesMojo.java
===================================================================
--- labs/jbossbuild/maven-plugins/trunk/maven-jboss-retro-plugin/src/main/java/org/jboss/maven/plugins/retro/WeaveDependenciesMojo.java	2007-08-13 13:47:56 UTC (rev 14170)
+++ labs/jbossbuild/maven-plugins/tags/maven-jboss-retro-plugin-1.0-beta-1/src/main/java/org/jboss/maven/plugins/retro/WeaveDependenciesMojo.java	2007-08-14 16:40:33 UTC (rev 14214)
@@ -1,520 +0,0 @@
-package org.jboss.maven.plugins.retro;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-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.installer.ArtifactInstallationException;
-import org.apache.maven.artifact.installer.ArtifactInstaller;
-import org.apache.maven.artifact.metadata.ArtifactMetadata;
-import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
-import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
-import org.apache.maven.artifact.metadata.ResolutionGroup;
-import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
-import org.apache.maven.artifact.repository.DefaultArtifactRepository;
-import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
-import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
-import org.apache.maven.artifact.resolver.ArtifactResolutionException;
-import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
-import org.apache.maven.artifact.resolver.ArtifactResolver;
-import org.apache.maven.plugin.AbstractMojo;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.project.MavenProject;
-import org.apache.maven.project.artifact.ProjectArtifactMetadata;
-import org.codehaus.plexus.util.FileUtils;
-import org.codehaus.plexus.util.StringUtils;
-import org.jboss.weaver.WeaveRunner;
-import org.jboss.weaver.Weaver;
-
-/**
- * This Mojo can be used to weave project dependencies.
- * WARNING: Implementation of this mojo is not complete!
- * 
- * @goal weave-dependencies
- * @requiresDependencyResolution
- */
-public class WeaveDependenciesMojo extends AbstractMojo
-{
-   public static final String JBOSS_RETRO_ARTIFACTID = "jboss-retro";
-   
-   protected final String fileSep = File.separator;
-
-   protected final String pathSep = File.pathSeparator;
-
-   /**
-    * The Maven Project Object
-    *
-    * @parameter expression="${project}"
-    * @required
-    * @readonly
-    */
-   protected MavenProject project;
-
-   /**
-    * The Maven Project Helper Object
-    *
-    * @component
-    * @required
-    * @readonly
-    */
-   protected org.apache.maven.project.MavenProjectHelper projectHelper;
-
-   /**
-    * INTERNAL : Artifact resolver, needed to download dependencies
-    *
-    * @component role="org.apache.maven.artifact.resolver.ArtifactResolver"
-    * @required
-    * @readonly
-    */
-   protected ArtifactResolver artifactResolver;
-
-   /**
-    * INTERNAL : Artifact resolver, needed to download dependencies
-    *
-    * @component role="org.apache.maven.artifact.metadata.ArtifactMetadataSource"
-    * @required
-    * @readonly
-    */
-   protected ArtifactMetadataSource artifactMetadataSource;
-   
-   /**
-    * INTERNAL : Local maven repository.
-    *
-    * @parameter expression="${localRepository}"
-    * @required
-    * @readonly
-    */
-   protected ArtifactRepository localRepository;
-   
-   /**
-    * The path for a specific local repository directory. It will wrap into an <code>ArtifactRepository</code>
-    * with <code>localRepoId</code> as <code>id</code> and with default <code>repositoryLayout</code>
-    *
-    * @parameter expression="${localRepositoryPath}"
-    */
-   private File localRepositoryPath;
-
-   /**
-    * The <code>id</code> for the <code>localRepo</code>
-    *
-    * @parameter expression="${localRepositoryId}"
-    */
-   private String localRepositoryId;
-
-   /**
-    * Map that contains the layouts
-    *
-    * @component role="org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout"
-    */
-   private Map repositoryLayouts;
-
-   /**
-    * A maven component to install artifacts to a local repository.
-    * @parameter expression="${component.org.apache.maven.artifact.installer.ArtifactInstaller}"
-    * @required
-    * @readonly
-    */
-   protected ArtifactInstaller installer;
-
-   /**
-    * Maven component to deploy artifacts to remote repository.
-    * @parameter expression="${component.org.apache.maven.artifact.deployer.ArtifactDeployer}"
-    * @required
-    * @readonly
-    */
-   private ArtifactDeployer deployer;
-
-   /**
-    * The plugin dependencies.
-    *
-    * @parameter expression="${plugin.artifacts}"
-    * @required
-    * @readonly
-    */
-   protected List pluginArtifacts;
-
-   /**
-    * Include verbose output.
-    * @parameter default-value="false"
-    */
-   protected boolean verbose;
-   
-   /**
-    * URL where the artifact will be deployed. <br/>
-    * ie ( file://C:\m2-repo or scp://host.com/path/to/repo )
-    * Note: this parameter is required if deployDependencies is set 
-    * to true.
-    * 
-    * @parameter
-    * 
-    */
-   private String deployUrl;
-
-   /**
-    * Suppress output information.
-    * @parameter default-value="true"
-    */
-   protected boolean suppress;
-
-   /**
-    * The type of remote repository layout to deploy to. Try <i>legacy</i> for 
-    * a Maven 1.x-style repository layout.
-    * 
-    * @parameter expression="${repositoryLayout}" default-value="default"
-    * @required
-    */
-   private String repositoryLayout;
-
-   /**
-    * The Weaver class to use for weaving the classes.
-    * Defaults to org.jboss.weaver.Weaver
-    * Any subclass of org.jboss.weaver.Weaver can be used
-    * 
-    * @parameter default-value="org.jboss.weaver.Weaver"
-    */
-   protected String weaverClass;
-
-   /**
-    * The jar file or directory where the weaved classes
-    * should be written.
-    *
-    * @parameter expression="${project.build.directory}/weaved-dependencies"
-    */
-   protected String dependencyOutputDirectory;
-
-   /**
-    * Component used to create a repository
-    *
-    * @component
-    */
-   private ArtifactRepositoryFactory repositoryFactory;
-
-   /**
-    * Server Id to map on the &lt;id&gt; under &lt;server&gt; section of settings.xml
-    * In most cases, this parameter will be required for authentication.
-    *
-    * @parameter expression="${repositoryId}" default-value="remote-repository"
-    * @required
-    */
-   private String repositoryId;
-   
-   /**
-    * Whether to deploy snapshots with a unique version or not.
-    *
-    * @parameter expression="${uniqueVersion}" default-value="true"
-    */
-   private boolean uniqueVersion;
-
-   /**
-    * Deploy weaved dependencies to a repository.
-    * @parameter default-value="false"
-    */
-   private boolean deployDependencies;
-   
-   /**
-    * Install weaved dependencies to a local repository.
-    * @parameter default-value="false"
-    * 
-    */
-   private boolean installDependencies;
-   
-   /**
-    * Main plugin execution method
-    */   
-   public void execute() throws MojoFailureException, MojoExecutionException
-   {
-      // Override the default local repository
-      if ( StringUtils.isNotEmpty( localRepositoryId ) && ( localRepositoryPath != null ) )
-      {
-          try
-          {
-              ArtifactRepositoryLayout layout;
-
-              layout = ( ArtifactRepositoryLayout ) repositoryLayouts.get( repositoryLayout );
-              
-              getLog().info("Layout: " + layout.getClass());
-              localRepository = new DefaultArtifactRepository( localRepositoryId, localRepositoryPath.toURL()
-                  .toString(), layout );
-          }
-          catch ( MalformedURLException e )
-          {
-              throw new MojoExecutionException( "MalformedURLException: " + e.getMessage(), e );
-          }
-      }
-      
-      this.getLog().info("Weaving dependencies");
-      
-      long start = System.currentTimeMillis();
-      
-      weaveDependencies();
-      
-      long end = System.currentTimeMillis();
-      this.getLog().info("Weaving complete: " + (end - start) + "ms");
-   }
-   
-   protected void weaveDependencies() throws MojoFailureException, MojoExecutionException 
-   {      
-      Set dependencyArtifacts = project.getDependencyArtifacts();
-      Map weavedDependencies = new HashMap();
-      
-      try 
-      {
-         ArtifactResolutionResult result = artifactResolver.resolveTransitively(dependencyArtifacts, 
-               project.getArtifact(), project.getRemoteArtifactRepositories(), localRepository, artifactMetadataSource);
-         Set artifacts = result.getArtifacts();
-         
-         File parentDir = new File(dependencyOutputDirectory);
-         if ( ! parentDir.exists()) {
-            parentDir.mkdirs();
-         }
-         
-         for (Object artifactObj : artifacts) 
-         {
-            Artifact artifact = (Artifact)artifactObj;
-            
-            WeaveRunner weaveRunner = this.createWeaveRunner(artifacts);
-            File outputFile = new File(dependencyOutputDirectory + File.separator + artifact.getFile().getName());
-            weaveRunner.setOutputPath(outputFile.getAbsolutePath());
-            
-            try
-            {
-               getLog().info("Weaving " + artifact);
-               weaveRunner.addSourcePath(artifact.getFile().getAbsolutePath());
-               weaveRunner.weave();
-            }
-            catch (Exception e)
-            {
-               e.printStackTrace();
-            }
-            weavedDependencies.put(artifact, outputFile);
-         }
-
-         if (this.installDependencies)
-         {
-            this.installDependencies(weavedDependencies);
-         }
-         
-         if (this.deployDependencies)
-         {
-            deployDependencies(weavedDependencies);
-         }
-      }
-      catch (ArtifactResolutionException e) 
-      {
-         throw new MojoExecutionException(e.getMessage(), e);
-      }
-      catch (ArtifactNotFoundException e) 
-      {
-         throw new MojoExecutionException(e.getMessage(), e);
-      }
-      catch (ArtifactInstallationException e) 
-      {
-         throw new MojoExecutionException(e.getMessage(), e);
-      }
-      
-   }
-   
-   public WeaveRunner createWeaveRunner(Set artifacts) throws MojoFailureException
-   {
-      
-      Weaver weaver = this.instantiateWeaver();
-      String classpath = this.buildClasspath(artifacts);
-      weaver.setClasspath(classpath);
-      weaver.init();
-      
-      WeaveRunner weaveRunner = new WeaveRunner(weaver);
-      weaveRunner.setVerbose(verbose);
-      weaveRunner.setSuppress(suppress);
-      weaveRunner.setUsingSystemClasspath(false);
-      weaveRunner.setOutputToJar(true);
-      
-      return weaveRunner;
-   }
-      
-   /**
-    * Generates a classpath string based on the resolved dependencies.
-    * @return The classpath string
-    */
-   protected String buildClasspath(Set artifacts) {
-      StringBuilder classpath = new StringBuilder();
-
-
-      for (Object artifactObj : artifacts)
-      {
-         Artifact artifact = (Artifact)artifactObj;
-         classpath.append(artifact.getFile().getAbsolutePath());
-         classpath.append(pathSep);
-      }
-      
-      for (Object artifactObj : pluginArtifacts)
-      {
-         try
-         {
-            Artifact artifact = (Artifact) artifactObj;
-            if (artifact.getFile() != null)
-            {
-               classpath.append(artifact.getFile().getCanonicalPath());
-               classpath.append(pathSep);
-            }
-         }
-         catch (IOException ioe)
-         {
-            this.getLog().warn("Could not get filename");
-         }
-      }
-      return classpath.toString();
-   }
-      
-   /**
-    * This method creates the weaver instance.  Subclass mojos
-    * can use this class to override the default weaver configuration.
-    * @return The weaver instance
-    */
-   protected Weaver instantiateWeaver() throws MojoFailureException {
-      // We have to set the classpath first because the initialization
-      // may require access to the classpath.
-      Weaver weaver = null;
-
-      try {
-         weaver = (Weaver)Class.forName(weaverClass).newInstance();
-      } catch (Exception e) {
-         getLog().error("Unable to instantiate weaver class: " + this.weaverClass);
-         getLog().error(e.getMessage());
-         throw new MojoFailureException(e.getMessage());
-      }
-      
-      return weaver;
-   }
-   
-   protected File getPomFile(Artifact artifact) throws MojoExecutionException
-   {
-      Artifact pomArtifact = null;
-      try
-      {
-         ResolutionGroup resGroup = artifactMetadataSource.retrieve(artifact, localRepository, project
-               .getRemoteArtifactRepositories());
-         pomArtifact = resGroup.getPomArtifact();
-         artifactResolver.resolve(pomArtifact, project.getRemoteArtifactRepositories(), localRepository);
-      }
-      catch (ArtifactMetadataRetrievalException e)
-      {
-         throw new MojoExecutionException( e.getMessage(), e);
-      }
-      catch (ArtifactResolutionException e)
-      {
-         throw new MojoExecutionException( e.getMessage(), e);
-      }
-      catch (ArtifactNotFoundException e)
-      {
-         throw new MojoExecutionException( e.getMessage(), e);
-      }
-      
-      if (pomArtifact == null)
-      {
-         return null;
-      }
-      else
-      {
-         return pomArtifact.getFile();
-      }
-   }
-   
-   private void installDependencies(Map artifacts) throws MojoExecutionException, ArtifactInstallationException
-   {
-      for (Object artifactObj : artifacts.keySet())
-      {
-         Artifact artifact = (Artifact)artifactObj;
-         File weavedArtifactFile = (File)artifacts.get(artifact);
-         
-         attachPomMetadata(artifact);
-         
-         installer.install(weavedArtifactFile, artifact, localRepository);
-      }
-   }
-
-   private void deployDependencies(Map artifacts) throws MojoExecutionException
-   {
-      getLog().info("Deploying dependencies");
-      ArtifactRepositoryLayout layout = ( ArtifactRepositoryLayout ) repositoryLayouts.get( repositoryLayout );
-      if (deployUrl == null) 
-      {
-         throw new MojoExecutionException("Parameter deployUrl must be set to a valid URL when deploying artifacts");
-      }
-      ArtifactRepository deploymentRepository =
-          repositoryFactory.createDeploymentArtifactRepository( repositoryId, deployUrl, layout, uniqueVersion );
-
-      String protocol = deploymentRepository.getProtocol();
-
-      if ( protocol.equals( "" ) || protocol == null )
-      {
-         throw new MojoExecutionException( "No transfer protocol found." );
-      }
-      
-      for (Object artifactObj : artifacts.keySet())
-      {
-         Artifact artifact = (Artifact)artifactObj;
-         File weavedArtifactFile = (File)artifacts.get(artifact);
-         
-         attachPomMetadata(artifact);
-         
-         try
-         {
-            //getLog().info("Deploying " + artifact);
-            getDeployer().deploy( weavedArtifactFile, artifact, deploymentRepository, getLocalRepository() );
-         }
-         catch ( ArtifactDeploymentException e )
-         {
-            throw new MojoExecutionException( e.getMessage(), e );
-         }
-      }
-   }
-   
-   private void attachPomMetadata(Artifact artifact) throws MojoExecutionException
-   {
-      
-      File pomFile = getPomFile(artifact);
-      File retroPomFile = new File(this.dependencyOutputDirectory + File.separator + artifact.getArtifactId() + "-" + artifact.getVersion() + ".pom");
-      
-      try 
-      {
-         FileUtils.copyFile(pomFile, retroPomFile);
-      }
-      catch (IOException ioe) 
-      {
-         throw new MojoExecutionException( ioe.getMessage(), ioe );
-      }
-      
-      ArtifactMetadata metadata = new ProjectArtifactMetadata( artifact, retroPomFile );
-      artifact.addMetadata( metadata );
-   }
-
-   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;
-   }
-         
-}

Copied: labs/jbossbuild/maven-plugins/tags/maven-jboss-retro-plugin-1.0-beta-1/src/main/java/org/jboss/maven/plugins/retro/WeaveDependenciesMojo.java (from rev 14171, labs/jbossbuild/maven-plugins/trunk/maven-jboss-retro-plugin/src/main/java/org/jboss/maven/plugins/retro/WeaveDependenciesMojo.java)
===================================================================
--- labs/jbossbuild/maven-plugins/tags/maven-jboss-retro-plugin-1.0-beta-1/src/main/java/org/jboss/maven/plugins/retro/WeaveDependenciesMojo.java	                        (rev 0)
+++ labs/jbossbuild/maven-plugins/tags/maven-jboss-retro-plugin-1.0-beta-1/src/main/java/org/jboss/maven/plugins/retro/WeaveDependenciesMojo.java	2007-08-14 16:40:33 UTC (rev 14214)
@@ -0,0 +1,466 @@
+package org.jboss.maven.plugins.retro;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+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.installer.ArtifactInstallationException;
+import org.apache.maven.artifact.installer.ArtifactInstaller;
+import org.apache.maven.artifact.metadata.ArtifactMetadata;
+import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
+import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
+import org.apache.maven.artifact.metadata.ResolutionGroup;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
+import org.apache.maven.artifact.repository.DefaultArtifactRepository;
+import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
+import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
+import org.apache.maven.artifact.resolver.ArtifactResolutionException;
+import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
+import org.apache.maven.artifact.resolver.ArtifactResolver;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.project.artifact.ProjectArtifactMetadata;
+import org.codehaus.plexus.util.FileUtils;
+import org.codehaus.plexus.util.StringUtils;
+
+/**
+ * This Mojo can be used to weave project dependencies.
+ * 
+ * @goal weave-dependencies
+ * @requiresDependencyResolution
+ */
+public class WeaveDependenciesMojo extends AbstractWeaveMojo
+{
+
+   /**
+    * INTERNAL : Artifact resolver, needed to download dependencies
+    *
+    * @component role="org.apache.maven.artifact.resolver.ArtifactResolver"
+    * @required
+    * @readonly
+    */
+   protected ArtifactResolver artifactResolver;
+
+   /**
+    * INTERNAL : Artifact resolver, needed to download dependencies
+    *
+    * @component role="org.apache.maven.artifact.metadata.ArtifactMetadataSource"
+    * @required
+    * @readonly
+    */
+   protected ArtifactMetadataSource artifactMetadataSource;
+   
+   /**
+    * INTERNAL : Local maven repository.
+    *
+    * @parameter expression="${localRepository}"
+    * @required
+    * @readonly
+    */
+   protected ArtifactRepository localRepository;
+   
+   /**
+    * The path for a specific local repository directory. It will wrap into an <code>ArtifactRepository</code>
+    * with <code>localRepoId</code> as <code>id</code> and with default <code>repositoryLayout</code>
+    *
+    * @parameter expression="${localRepositoryPath}"
+    */
+   private File localRepositoryPath;
+
+   /**
+    * The <code>id</code> for the <code>localRepo</code>
+    *
+    * @parameter expression="${localRepositoryId}"
+    */
+   private String localRepositoryId;
+
+   /**
+    * Map that contains the layouts
+    *
+    * @component role="org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout"
+    */
+   private Map repositoryLayouts;
+
+   /**
+    * A maven component to install artifacts to a local repository.
+    * @parameter expression="${component.org.apache.maven.artifact.installer.ArtifactInstaller}"
+    * @required
+    * @readonly
+    */
+   protected ArtifactInstaller installer;
+
+   /**
+    * Maven component to deploy artifacts to remote repository.
+    * @parameter expression="${component.org.apache.maven.artifact.deployer.ArtifactDeployer}"
+    * @required
+    * @readonly
+    */
+   private ArtifactDeployer deployer;
+
+   /**
+    * The plugin dependencies.
+    *
+    * @parameter expression="${plugin.artifacts}"
+    * @required
+    * @readonly
+    */
+   protected List pluginArtifacts;
+
+   /**
+    * URL where the artifact will be deployed. <br/>
+    * ie ( file://C:\m2-repo or scp://host.com/path/to/repo )
+    * Note: this parameter is required if deployDependencies is set 
+    * to true.
+    * 
+    * @parameter
+    * 
+    */
+   private String deployUrl;
+
+   /**
+    * The type of remote repository layout to deploy to. Try <i>legacy</i> for 
+    * a Maven 1.x-style repository layout.
+    * 
+    * @parameter expression="${repositoryLayout}" default-value="default"
+    * @required
+    */
+   private String repositoryLayout;
+
+   /**
+    * The directory where the weaved jar files should be written.
+    * should be written.
+    *
+    * @parameter expression="${project.build.directory}/weaved-dependencies"
+    */
+   protected String outputDirectory;
+
+   /**
+    * Component used to create a repository
+    *
+    * @component
+    */
+   private ArtifactRepositoryFactory repositoryFactory;
+
+   /**
+    * Server Id to map on the &lt;id&gt; under &lt;server&gt; section of settings.xml
+    * In most cases, this parameter will be required for authentication.
+    *
+    * @parameter expression="${repositoryId}" default-value="remote-repository"
+    * @required
+    */
+   private String repositoryId;
+   
+   /**
+    * Whether to deploy snapshots with a unique version or not.
+    *
+    * @parameter expression="${uniqueVersion}" default-value="true"
+    */
+   private boolean uniqueVersion;
+
+   /**
+    * Deploy weaved dependencies to a repository.
+    * @parameter default-value="false"
+    */
+   private boolean deployDependencies;
+   
+   /**
+    * Install weaved dependencies to a local repository.
+    * @parameter default-value="false"
+    * 
+    */
+   private boolean installDependencies;
+   
+   /**
+    * Main plugin execution method
+    */   
+   public void execute() throws MojoFailureException, MojoExecutionException
+   {
+      // Override the default local repository
+      if ( StringUtils.isNotEmpty( localRepositoryId ) && ( localRepositoryPath != null ) )
+      {
+          try
+          {
+              ArtifactRepositoryLayout layout;
+
+              layout = ( ArtifactRepositoryLayout ) repositoryLayouts.get( repositoryLayout );
+              
+              getLog().info("Layout: " + layout.getClass());
+              localRepository = new DefaultArtifactRepository( localRepositoryId, localRepositoryPath.toURL()
+                  .toString(), layout );
+          }
+          catch ( MalformedURLException e )
+          {
+              throw new MojoExecutionException( "MalformedURLException: " + e.getMessage(), e );
+          }
+      }
+      
+      this.getLog().info("Weaving dependencies");
+      
+      weaveDependencies();
+      
+      this.getLog().info("Weaving complete.");
+   }
+   
+   protected void weaveDependencies() throws MojoFailureException, MojoExecutionException 
+   {      
+      Set dependencyArtifacts = project.getDependencyArtifacts();
+      Map weavedDependencies = new HashMap();
+      
+      try 
+      {
+         ArtifactResolutionResult result = artifactResolver.resolveTransitively(dependencyArtifacts, 
+               project.getArtifact(), project.getRemoteArtifactRepositories(), localRepository, artifactMetadataSource);
+         Set artifacts = result.getArtifacts();
+         
+         File parentDir = new File(this.getOutputPath());
+         if ( ! parentDir.exists()) {
+            parentDir.mkdirs();
+         }
+         
+         for (Object artifactObj : artifacts) 
+         {
+            Artifact artifact = (Artifact)artifactObj;
+            
+            getLog().info("Weaving " + artifact);
+            String srcJar = artifact.getFile().getAbsolutePath();
+            File outputJarFile = new File(this.getOutputPath() + File.separator + artifact.getFile().getName());
+            String destJar = outputJarFile.getAbsolutePath();
+            String classpath = buildClasspath(artifacts);
+            String [] args = this.generateWeaverArgs(classpath, srcJar, destJar);
+            
+            try 
+            {
+               doWeave(classpath, args);
+            }
+            catch (Exception e)
+            {
+               getLog().warn("Exception while weaving " + artifact.getArtifactId() + "\n" +
+                     e.getMessage());
+            }
+                        
+            weavedDependencies.put(artifact, outputJarFile);
+         }
+
+         if (this.installDependencies)
+         {
+            this.installDependencies(weavedDependencies);
+         }
+         
+         if (this.deployDependencies)
+         {
+            deployDependencies(weavedDependencies);
+         }
+      }
+      catch (ArtifactResolutionException e) 
+      {
+         throw new MojoExecutionException(e.getMessage(), e);
+      }
+      catch (ArtifactNotFoundException e) 
+      {
+         throw new MojoExecutionException(e.getMessage(), e);
+      }
+      catch (ArtifactInstallationException e) 
+      {
+         throw new MojoExecutionException(e.getMessage(), e);
+      }
+   }
+   
+   protected String [] generateWeaverArgs(String classpath, String srcJar, String destJar) 
+   {
+      ArrayList<String> argsList = new ArrayList<String> ();
+      if (this.verbose)
+      {
+         argsList.add("-verbose");
+      }
+      if (this.suppress)
+      {
+         argsList.add("-suppress");
+      }
+      argsList.add("-cp");
+      argsList.add(classpath);
+      argsList.add("-useSystemClasspath");
+      argsList.add("false");
+      if (this.weaverClass !=null)
+      {
+         argsList.add("-weaverClass");
+         argsList.add(this.weaverClass);
+      }
+      argsList.add("-outputJar");
+      argsList.add(destJar);
+      argsList.add(srcJar);
+      
+      String [] args = new String[argsList.size()];
+      return argsList.toArray(args);
+   }
+   
+      
+   /**
+    * Generates a classpath string based on the resolved dependencies.
+    * @return The classpath string
+    */
+   protected String buildClasspath(Set artifacts) {
+      StringBuilder classpath = new StringBuilder();
+
+
+      for (Object artifactObj : artifacts)
+      {
+         Artifact artifact = (Artifact)artifactObj;
+         classpath.append(artifact.getFile().getAbsolutePath());
+         classpath.append(pathSep);
+      }
+      
+      for (Object artifactObj : pluginArtifacts)
+      {
+         try
+         {
+            Artifact artifact = (Artifact) artifactObj;
+            if (artifact.getFile() != null)
+            {
+               classpath.append(artifact.getFile().getCanonicalPath());
+               classpath.append(pathSep);
+            }
+         }
+         catch (IOException ioe)
+         {
+            this.getLog().warn("Could not get filename");
+         }
+      }
+      return classpath.toString();
+   }
+      
+   protected File getPomFile(Artifact artifact) throws MojoExecutionException
+   {
+      Artifact pomArtifact = null;
+      try
+      {
+         ResolutionGroup resGroup = artifactMetadataSource.retrieve(artifact, localRepository, project
+               .getRemoteArtifactRepositories());
+         pomArtifact = resGroup.getPomArtifact();
+         artifactResolver.resolve(pomArtifact, project.getRemoteArtifactRepositories(), localRepository);
+      }
+      catch (ArtifactMetadataRetrievalException e)
+      {
+         throw new MojoExecutionException( e.getMessage(), e);
+      }
+      catch (ArtifactResolutionException e)
+      {
+         throw new MojoExecutionException( e.getMessage(), e);
+      }
+      catch (ArtifactNotFoundException e)
+      {
+         throw new MojoExecutionException( e.getMessage(), e);
+      }
+      
+      if (pomArtifact == null)
+      {
+         return null;
+      }
+      else
+      {
+         return pomArtifact.getFile();
+      }
+   }
+   
+   private void installDependencies(Map artifacts) throws MojoExecutionException, ArtifactInstallationException
+   {
+      for (Object artifactObj : artifacts.keySet())
+      {
+         Artifact artifact = (Artifact)artifactObj;
+         File weavedArtifactFile = (File)artifacts.get(artifact);
+         
+         attachPomMetadata(artifact);
+         
+         installer.install(weavedArtifactFile, artifact, localRepository);
+      }
+   }
+
+   private void deployDependencies(Map artifacts) throws MojoExecutionException
+   {
+      getLog().info("Deploying dependencies");
+      ArtifactRepositoryLayout layout = ( ArtifactRepositoryLayout ) repositoryLayouts.get( repositoryLayout );
+      if (deployUrl == null) 
+      {
+         throw new MojoExecutionException("Parameter deployUrl must be set to a valid URL when deploying artifacts");
+      }
+      ArtifactRepository deploymentRepository =
+          repositoryFactory.createDeploymentArtifactRepository( repositoryId, deployUrl, layout, uniqueVersion );
+
+      String protocol = deploymentRepository.getProtocol();
+
+      if ( protocol.equals( "" ) || protocol == null )
+      {
+         throw new MojoExecutionException( "No transfer protocol found." );
+      }
+      
+      for (Object artifactObj : artifacts.keySet())
+      {
+         Artifact artifact = (Artifact)artifactObj;
+         File weavedArtifactFile = (File)artifacts.get(artifact);
+         
+         attachPomMetadata(artifact);
+         
+         try
+         {
+            getDeployer().deploy( weavedArtifactFile, artifact, deploymentRepository, getLocalRepository() );
+         }
+         catch ( ArtifactDeploymentException e )
+         {
+            throw new MojoExecutionException( e.getMessage(), e );
+         }
+      }
+   }
+   
+   private void attachPomMetadata(Artifact artifact) throws MojoExecutionException
+   {
+      
+      File pomFile = getPomFile(artifact);
+      File retroPomFile = new File(this.getOutputPath() + File.separator + artifact.getArtifactId() + "-" + artifact.getVersion() + ".pom");
+      
+      try 
+      {
+         FileUtils.copyFile(pomFile, retroPomFile);
+      }
+      catch (IOException ioe) 
+      {
+         throw new MojoExecutionException( ioe.getMessage(), ioe );
+      }
+      
+      ArtifactMetadata metadata = new ProjectArtifactMetadata( artifact, retroPomFile );
+      artifact.addMetadata( metadata );
+   }
+
+   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;
+   }
+   
+   public String getOutputPath()
+   {
+      return this.outputDirectory;
+   }
+         
+}

Deleted: labs/jbossbuild/maven-plugins/tags/maven-jboss-retro-plugin-1.0-beta-1/src/main/java/org/jboss/maven/plugins/retro/WeaveMojo.java
===================================================================
--- labs/jbossbuild/maven-plugins/trunk/maven-jboss-retro-plugin/src/main/java/org/jboss/maven/plugins/retro/WeaveMojo.java	2007-08-13 13:47:56 UTC (rev 14170)
+++ labs/jbossbuild/maven-plugins/tags/maven-jboss-retro-plugin-1.0-beta-1/src/main/java/org/jboss/maven/plugins/retro/WeaveMojo.java	2007-08-14 16:40:33 UTC (rev 14214)
@@ -1,276 +0,0 @@
-package org.jboss.maven.plugins.retro;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Collection;
-import java.util.List;
-
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.io.filefilter.NameFileFilter;
-import org.apache.commons.io.filefilter.TrueFileFilter;
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.plugin.AbstractMojo;
-import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.project.MavenProject;
-import org.jboss.maven.plugins.retro.util.JarUtil;
-import org.jboss.weaver.WeaveRunner;
-import org.jboss.weaver.Weaver;
-
-/**
- * Maven plugin for JBoss Retro Weaver.  This can be used to 
- * do byte code weaving on classes in jars and directories.
- * By default the weaver will weave the main classes
- * and output the result to a jar with the specified classifier.
- * 
- * @phase process-classes
- * @goal weave
- * 
- */
-public class WeaveMojo extends AbstractMojo
-{
-   public static final String JBOSS_RETRO_ARTIFACTID = "jboss-retro";
-   
-   protected final String fileSep = File.separator;
-
-   protected final String pathSep = File.pathSeparator;
-
-   /**
-    * List of the jar file entries
-    */
-   //private ArrayList<JarFileEntry> fileEntries = new ArrayList<JarFileEntry>();
-
-   /**
-    * The Maven Project Object
-    *
-    * @parameter expression="${project}"
-    * @required
-    * @readonly
-    */
-   protected MavenProject project;
-
-   /**
-    * The Maven Project Helper Object
-    *
-    * @component
-    * @required
-    * @readonly
-    */
-   protected org.apache.maven.project.MavenProjectHelper projectHelper;
-
-   /**
-    * The plugin dependencies.
-    *
-    * @parameter expression="${plugin.artifacts}"
-    * @required
-    * @readonly
-    */
-   protected List pluginArtifacts;
-
-   /**
-    * Project classpath.
-    *
-    * @parameter expression="${project.compileClasspathElements}"
-    * @required
-    * @readonly
-    */
-   protected List classpathElements;
-   
-   /**
-    * The directory for compiled classes.
-    *
-    * @parameter expression="${project.build.outputDirectory}"
-    * @required
-    */
-   protected File classesDirectory;
-
-   /**
-    * Include verbose output.
-    * @parameter
-    */
-   protected boolean verbose = false;
-
-   /**
-    * The Weaver class to use for weaving the classes.
-    * Defaults to org.jboss.weaver.Weaver
-    * Any subclass of org.jboss.weaver.Weaver can be used
-    * 
-    * @parameter
-    */
-   protected String weaverClass = "org.jboss.weaver.Weaver";
-
-   /**
-    * The directory where the weaved classes
-    * should be written.
-    * @parameter expression="${project.build.directory}/classes-weaved"
-    */
-   protected File outputDirectory;
-   
-   /**
-    * Attach a jar of the weaved classes to the build lifecycle.  This will
-    * allow the weaved jar to be deployed with the other build artifacts.
-    * @parameter
-    */
-   protected boolean attachJar = false;
-   
-   /**
-    * Classifier to append to the weaved output file (artifact).
-    * Defaults to null.  If the classifier is null, then the jar
-    * of the weaved classes will replace the main artifact.
-    * 
-    * @parameter
-    */
-   protected String classifier;
-   
-   /**
-    * Suppress output information.
-    * @parameter
-    */
-   protected boolean suppress = true;
-
-   /**
-    * Main plugin execution method
-    */   
-   public void execute() throws MojoFailureException
-   {
-      if ( ( ! this.getClassesDirecotry().exists()) 
-            || ( ! this.getClassesDirecotry().isDirectory()))
-      {
-         getLog().info("No classes found to weave.");
-         return;
-      }
-      
-      this.getLog().info("Weaving classes in: " + this.getClassesDirecotry());
-      long start = System.currentTimeMillis();
-      
-      weaveClasses();
-      if (this.attachJar) 
-      {
-         String jarFilePath = project.getBuild().getDirectory()
-            + File.separator + project.getArtifactId() + "-" + this.getJarClassifier() + ".jar";
-         try 
-         {
-            File jarFile = JarUtil.createJarFile(this.getOutputPath(), jarFilePath);
-            projectHelper.attachArtifact(project, jarFile, this.getJarClassifier());
-         }
-         catch (IOException ioe) 
-         {
-            getLog().warn("Unable to create Jar file: " + ioe);
-         }
-      }
-      
-      long end = System.currentTimeMillis();
-      this.getLog().info("Weaving complete: " + (end - start) + "ms");
-   }
-   
-   protected void weaveClasses() throws MojoFailureException {
-      // Initialize the WeaveRunner using plugin params
-      Weaver weaver = instantiateWeaver();
-      weaver.setClasspath(this.buildClasspath());
-      weaver.init();
-      WeaveRunner weaveRunner = new WeaveRunner(weaver);
-
-      weaveRunner.setVerbose(verbose);
-      weaveRunner.setSuppress(suppress);
-      weaveRunner.setUsingSystemClasspath(false);
-      
-      weaveRunner.setOutputPath(getOutputPath()); 
-      
-      try
-      {
-         weaveRunner.addSourcePath(this.getClassesDirecotry().getAbsolutePath());
-         weaveRunner.weave();
-      }
-      catch (Exception e)
-      {
-         this.getLog().error(e);
-         e.printStackTrace();
-      }
-   }
-   
-   /**
-    * Generates a classpath string based on the compile class path
-    * and the plugin dependencies.
-    * @return
-    */
-   protected String buildClasspath() {
-      StringBuilder classpath = new StringBuilder();
-
-      List cpElements = this.getClasspathElements();
-      for (Object element : cpElements)
-      {
-         classpath.append(element);
-         classpath.append(pathSep);
-      }
-      
-      // If the weaver classes can be found in the source directory 
-      // (i.e. we are weaving jboss retro), then we don't want the 
-      // retro jar from the plugin dependency to be pulled in from the repo.
-      boolean useRetroDep = true;
-      NameFileFilter nameFilter = new NameFileFilter("Weaver.class");
-      Collection weaverClassFiles = FileUtils.listFiles(this.getClassesDirecotry(), nameFilter, TrueFileFilter.INSTANCE);
-      if (weaverClassFiles.size() > 0)
-      {
-         useRetroDep = false;
-      }
-      
-      for (Object artifactObj : pluginArtifacts)
-      {
-         try
-         {
-            Artifact artifact = (Artifact) artifactObj;
-            if (artifact.getFile() != null)
-            {
-               if ( useRetroDep || ( ! artifact.getArtifactId().equals(JBOSS_RETRO_ARTIFACTID)))
-               {
-                  classpath.append(artifact.getFile().getCanonicalPath());
-                  classpath.append(pathSep);
-               }
-            }
-         }
-         catch (IOException ioe)
-         {
-            this.getLog().warn("Could not get filename");
-         }
-      }
-      return classpath.toString();
-   }
-      
-   /**
-    * This method creates the weaver instance.  Subclass mojos
-    * can use this class to override the default weaver configuration.
-    * @return The weaver instance
-    */
-   protected Weaver instantiateWeaver() throws MojoFailureException {
-      // We have to set the classpath first because the initialization
-      // may require access to the classpath.
-      Weaver weaver = null;
-
-      try {
-         weaver = (Weaver)Class.forName(weaverClass).newInstance();
-      } catch (Exception e) {
-         getLog().error("Unable to instantiate weaver class: " + this.weaverClass);
-         getLog().error(e.getMessage());
-         throw new MojoFailureException(e.getMessage());
-      }
-      
-      return weaver;
-   }
-   
-   protected String getOutputPath() 
-   {
-      return this.outputDirectory.getAbsolutePath();
-   }
-   
-   public List getClasspathElements() {
-      return this.classpathElements;
-   }
-   
-   public File getClassesDirecotry() {
-      return this.classesDirectory;
-   }
-   
-   protected String getJarClassifier() {
-      return this.classifier;
-   }
-   
-}

Copied: labs/jbossbuild/maven-plugins/tags/maven-jboss-retro-plugin-1.0-beta-1/src/main/java/org/jboss/maven/plugins/retro/WeaveMojo.java (from rev 14171, labs/jbossbuild/maven-plugins/trunk/maven-jboss-retro-plugin/src/main/java/org/jboss/maven/plugins/retro/WeaveMojo.java)
===================================================================
--- labs/jbossbuild/maven-plugins/tags/maven-jboss-retro-plugin-1.0-beta-1/src/main/java/org/jboss/maven/plugins/retro/WeaveMojo.java	                        (rev 0)
+++ labs/jbossbuild/maven-plugins/tags/maven-jboss-retro-plugin-1.0-beta-1/src/main/java/org/jboss/maven/plugins/retro/WeaveMojo.java	2007-08-14 16:40:33 UTC (rev 14214)
@@ -0,0 +1,208 @@
+package org.jboss.maven.plugins.retro;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.filefilter.NameFileFilter;
+import org.apache.commons.io.filefilter.TrueFileFilter;
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.jboss.maven.plugins.retro.util.JarUtil;
+
+/**
+ * Maven plugin for JBoss Retro Weaver.  This can be used to 
+ * do byte code weaving on classes in jars and directories.
+ * By default the weaver will weave the main classes
+ * and output the result to a jar with the specified classifier.
+ * 
+ * @phase process-classes
+ * @goal weave
+ * 
+ */
+public class WeaveMojo extends AbstractWeaveMojo
+{
+
+   /**
+    * The plugin dependencies.
+    *
+    * @parameter expression="${plugin.artifacts}"
+    * @required
+    * @readonly
+    */
+   protected List pluginArtifacts;
+
+   /**
+    * The directory for compiled classes.
+    *
+    * @parameter expression="${project.build.outputDirectory}"
+    * @required
+    */
+   protected File classesDirectory;
+
+
+   /**
+    * The directory where the weaved classes
+    * should be written.
+    * @parameter expression="${project.build.directory}/classes-weaved"
+    */
+   protected File outputDirectory;
+   
+   /**
+    * Attach a jar of the weaved classes to the build lifecycle.  This will
+    * allow the weaved jar to be deployed with the other build artifacts.
+    * @parameter
+    */
+   protected boolean attachJar = false;
+   
+   /**
+    * Project classpath.
+    *
+    * @parameter expression="${project.compileClasspathElements}"
+    * @required
+    */
+   protected List classpathElements;
+   
+   /**
+    * Main plugin execution method
+    */   
+   public void execute() throws MojoFailureException, MojoExecutionException
+   {
+      if ( ( ! this.getClassesDirecotry().exists()) 
+            || ( ! this.getClassesDirecotry().isDirectory()))
+      {
+         getLog().info("No classes found to weave.");
+         return;
+      }
+      
+      this.getLog().info("Weaving classes in: " + this.getClassesDirecotry());
+      
+      try 
+      {
+         doWeave(this.buildWeaveClasspath(), this.generateWeaverArgs());
+      }
+      catch (Exception e)
+      {
+         throw new MojoExecutionException("Error during weave: " + e);
+      }
+      this.getLog().info("Weaving complete.");
+      if (this.attachJar) 
+      {
+         String jarFilePath = project.getBuild().getDirectory()
+            + File.separator + project.getArtifactId() + "-" + this.getJarClassifier() + ".jar";
+         try 
+         {
+            File jarFile = JarUtil.createJarFile(this.getOutputPath(), jarFilePath);
+            projectHelper.attachArtifact(project, jarFile, this.getJarClassifier());
+            getLog().info("Weaved jar file created: " + jarFile.getAbsolutePath());
+         }
+         catch (IOException ioe) 
+         {
+            getLog().warn("Unable to create Jar file: " + ioe);
+         }
+      }
+   }
+      
+   protected String [] generateWeaverArgs() 
+   {
+      ArrayList<String> argsList = new ArrayList<String> ();
+      if (this.verbose)
+      {
+         argsList.add("-verbose");
+      }
+      if (this.suppress)
+      {
+         argsList.add("-suppress");
+      }
+      if (this.useSystemClasspath)
+      {
+         argsList.add("-useSystemClasspath");
+         argsList.add(Boolean.toString(useSystemClasspath));
+      }
+      argsList.add("-cp");
+      argsList.add(buildWeaveClasspath());
+      if (this.weaverClass !=null)
+      {
+         argsList.add("-weaverClass");
+         argsList.add(this.weaverClass);
+      }
+      argsList.add("-outputDir");
+      argsList.add(this.getOutputPath());
+      argsList.add(this.getClassesDirecotry().getAbsolutePath());
+      
+      String [] args = new String[argsList.size()];
+      return argsList.toArray(args);
+   }
+   
+   /**
+    * Generates a classpath string based on the compile class path
+    * and the plugin dependencies.
+    * @return
+    */
+   protected String buildWeaveClasspath() {
+      StringBuilder classpath = new StringBuilder();
+
+      List cpElements = this.getClasspathElements();
+      for (Object element : cpElements)
+      {
+         classpath.append(element);
+         classpath.append(pathSep);
+      }
+      
+      // If the weaver classes can be found in the source directory 
+      // (i.e. we are weaving jboss retro), then we don't want the 
+      // retro jar from the plugin dependency to be pulled in from the repo.
+      boolean useRetroDep = true;
+      NameFileFilter nameFilter = new NameFileFilter("Weaver.class");
+      Collection weaverClassFiles = FileUtils.listFiles(this.getClassesDirecotry(), nameFilter, TrueFileFilter.INSTANCE);
+      if (weaverClassFiles.size() > 0)
+      {
+         useRetroDep = false;
+      }
+      
+      for (Object artifactObj : pluginArtifacts)
+      {
+         try
+         {
+            Artifact artifact = (Artifact) artifactObj;
+            if (artifact.getFile() != null)
+            {
+               if ( useRetroDep || ( ! artifact.getArtifactId().equals(JBOSS_RETRO_ARTIFACTID)))
+               {
+                  classpath.append(artifact.getFile().getCanonicalPath());
+                  classpath.append(pathSep);
+               }
+            }
+         }
+         catch (IOException ioe)
+         {
+            this.getLog().warn("Could not get filename");
+         }
+      }
+      return classpath.toString();
+   }
+         
+   protected String getOutputPath() 
+   {
+      return this.outputDirectory.getAbsolutePath();
+   }
+   
+   public File getClassesDirecotry() 
+   {
+      return this.classesDirectory;
+   }
+   
+   /**
+    * Get the list of classpath elements to use for weaving.
+    * @return
+    */
+   public List getClasspathElements() 
+   {
+      return this.classpathElements;
+   }
+      
+}

Deleted: labs/jbossbuild/maven-plugins/tags/maven-jboss-retro-plugin-1.0-beta-1/src/main/java/org/jboss/maven/plugins/retro/WeaveTestsMojo.java
===================================================================
--- labs/jbossbuild/maven-plugins/trunk/maven-jboss-retro-plugin/src/main/java/org/jboss/maven/plugins/retro/WeaveTestsMojo.java	2007-08-13 13:47:56 UTC (rev 14170)
+++ labs/jbossbuild/maven-plugins/tags/maven-jboss-retro-plugin-1.0-beta-1/src/main/java/org/jboss/maven/plugins/retro/WeaveTestsMojo.java	2007-08-14 16:40:33 UTC (rev 14214)
@@ -1,74 +0,0 @@
-package org.jboss.maven.plugins.retro;
-
-import java.io.File;
-import java.util.List;
-
-/**
- * Maven plugin for JBoss Retro Weaver.  This mojo is set up
- * to weave the test classes and optionally generate a jar of
- * the weaved classes. 
- * 
- * @phase process-test-classes
- * @goal weave-tests
- * 
- */
-public class WeaveTestsMojo extends WeaveMojo
-{
-
-   /**
-    * Project classpath.
-    *
-    * @parameter expression="${project.testClasspathElements}"
-    * @required
-    * @readonly
-    */
-   protected List classpathElements;
-      
-   /**
-    * The directory containing the classes to be weaved.
-    *
-    * @parameter expression="${project.build.testOutputDirectory}"
-    * @required
-    * @readonly
-    */
-   protected File classesDirectory;
-
-   /**
-    * The jar file or directory where the weaved classes
-    * should be written. Defaults to "target/test-classes-weaved"
-    * 
-    * @parameter expression="${project.build.directory}/test-classes-weaved"
-    */
-   protected File outputDirectory;
-      
-   /**
-    * Suppress output information.
-    * @parameter
-    */
-   protected boolean suppress = true;
-   
-   public List getClasspathElements() 
-   {
-      return this.classpathElements;
-   }
-   
-   public File getClassesDirecotry() 
-   {
-      return this.classesDirectory;
-   }
-   
-   protected String getOutputPath() 
-   {
-      return this.outputDirectory.getAbsolutePath();
-   }
-   
-   protected String getJarClassifier() {
-      if (this.classifier == null) {
-         return "tests";
-      }
-      else {
-         return "tests-" + this.classifier;
-      }
-   }
-   
-}

Copied: labs/jbossbuild/maven-plugins/tags/maven-jboss-retro-plugin-1.0-beta-1/src/main/java/org/jboss/maven/plugins/retro/WeaveTestsMojo.java (from rev 14171, labs/jbossbuild/maven-plugins/trunk/maven-jboss-retro-plugin/src/main/java/org/jboss/maven/plugins/retro/WeaveTestsMojo.java)
===================================================================
--- labs/jbossbuild/maven-plugins/tags/maven-jboss-retro-plugin-1.0-beta-1/src/main/java/org/jboss/maven/plugins/retro/WeaveTestsMojo.java	                        (rev 0)
+++ labs/jbossbuild/maven-plugins/tags/maven-jboss-retro-plugin-1.0-beta-1/src/main/java/org/jboss/maven/plugins/retro/WeaveTestsMojo.java	2007-08-14 16:40:33 UTC (rev 14214)
@@ -0,0 +1,68 @@
+package org.jboss.maven.plugins.retro;
+
+import java.io.File;
+import java.util.List;
+
+/**
+ * Maven plugin for JBoss Retro Weaver.  This mojo is set up
+ * to weave the test classes and optionally generate a jar of
+ * the weaved classes. 
+ * 
+ * @phase process-test-classes
+ * @goal weave-tests
+ * 
+ */
+public class WeaveTestsMojo extends WeaveMojo
+{
+
+   /**
+    * Project classpath.
+    *
+    * @parameter expression="${project.testClasspathElements}"
+    * @required
+    * 
+    */
+   protected List classpathElements;
+      
+   /**
+    * The directory containing the classes to be weaved.
+    *
+    * @parameter expression="${project.build.testOutputDirectory}"
+    * @required
+    * 
+    */
+   protected File classesDirectory;
+
+   /**
+    * The jar file or directory where the weaved classes
+    * should be written. Defaults to "target/test-classes-weaved"
+    * 
+    * @parameter expression="${project.build.directory}/test-classes-weaved"
+    */
+   protected File outputDirectory;
+      
+   public List getClasspathElements() 
+   {
+      return this.classpathElements;
+   }
+   
+   public File getClassesDirecotry() 
+   {
+      return this.classesDirectory;
+   }
+   
+   protected String getOutputPath() 
+   {
+      return this.outputDirectory.getAbsolutePath();
+   }
+   
+   protected String getJarClassifier() {
+      if (this.classifier == null) {
+         return "tests";
+      }
+      else {
+         return "tests-" + this.classifier;
+      }
+   }
+   
+}




More information about the jboss-svn-commits mailing list