[jboss-svn-commits] JBL Code SVN: r10658 - in labs/jbossbuild/maven-plugins/tags: jboss-retro-maven-plugin-0.5-beta2 and 1 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Fri Mar 30 14:35:45 EDT 2007
Author: pgier
Date: 2007-03-30 14:35:45 -0400 (Fri, 30 Mar 2007)
New Revision: 10658
Added:
labs/jbossbuild/maven-plugins/tags/jboss-retro-maven-plugin-0.5-beta2/
labs/jbossbuild/maven-plugins/tags/jboss-retro-maven-plugin-0.5-beta2/pom.xml
labs/jbossbuild/maven-plugins/tags/jboss-retro-maven-plugin-0.5-beta2/src/main/java/org/jboss/maven/plugins/retro/RetroCheckMojo.java
labs/jbossbuild/maven-plugins/tags/jboss-retro-maven-plugin-0.5-beta2/src/main/java/org/jboss/maven/plugins/retro/RetroMojo.java
Removed:
labs/jbossbuild/maven-plugins/tags/jboss-retro-maven-plugin-0.5-beta2/pom.xml
labs/jbossbuild/maven-plugins/tags/jboss-retro-maven-plugin-0.5-beta2/src/main/java/org/jboss/maven/plugins/retro/RetroMojo.java
Log:
[maven-scm] copy for tag jboss-retro-maven-plugin-0.5-beta2
Copied: labs/jbossbuild/maven-plugins/tags/jboss-retro-maven-plugin-0.5-beta2 (from rev 10612, labs/jbossbuild/maven-plugins/trunk/jboss-retro-maven-plugin)
Deleted: labs/jbossbuild/maven-plugins/tags/jboss-retro-maven-plugin-0.5-beta2/pom.xml
===================================================================
--- labs/jbossbuild/maven-plugins/trunk/jboss-retro-maven-plugin/pom.xml 2007-03-29 12:45:49 UTC (rev 10612)
+++ labs/jbossbuild/maven-plugins/tags/jboss-retro-maven-plugin-0.5-beta2/pom.xml 2007-03-30 18:35:45 UTC (rev 10658)
@@ -1,87 +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">
- <parent>
- <artifactId>jboss-parent</artifactId>
- <groupId>jboss</groupId>
- <version>1</version>
- </parent>
- <modelVersion>4.0.0</modelVersion>
- <groupId>jboss.maven-plugins</groupId>
- <artifactId>jboss-retro-maven-plugin</artifactId>
- <packaging>maven-plugin</packaging>
- <name>JBoss Retro Maven Plugin</name>
- <version>0.5-SNAPSHOT</version>
- <url>http://www.jboss.org</url>
- <description>Maven plugin for jboss retro</description>
- <scm>
- <connection>scm:svn:https://svn.labs.jboss.org/labs/jbossbuild/maven-plugins/trunk/jboss-retro-maven-plugin</connection>
- </scm>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>2.0</version>
- <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>
- <repositories>
- <repository>
- <snapshots />
- <id>jboss</id>
- <name>JBoss Repository</name>
- <url>http://repository.jboss.com/maven2/</url>
- </repository>
- </repositories>
- <dependencies>
- <dependency>
- <groupId>jboss</groupId>
- <artifactId>jboss-backport-concurrent</artifactId>
- <version>2.1.0.GA</version>
- </dependency>
- <dependency>
- <groupId>jboss</groupId>
- <artifactId>javassist</artifactId>
- <version>3.4.ga</version>
- </dependency>
- <dependency>
- <groupId>jboss</groupId>
- <artifactId>jbossretro</artifactId>
- <version>1.0.5.beta</version>
- </dependency>
- <dependency>
- <groupId>org.apache.ant</groupId>
- <artifactId>ant</artifactId>
- <version>1.7.0</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-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>
- </dependencies>
-</project>
\ No newline at end of file
Copied: labs/jbossbuild/maven-plugins/tags/jboss-retro-maven-plugin-0.5-beta2/pom.xml (from rev 10657, labs/jbossbuild/maven-plugins/trunk/jboss-retro-maven-plugin/pom.xml)
===================================================================
--- labs/jbossbuild/maven-plugins/tags/jboss-retro-maven-plugin-0.5-beta2/pom.xml (rev 0)
+++ labs/jbossbuild/maven-plugins/tags/jboss-retro-maven-plugin-0.5-beta2/pom.xml 2007-03-30 18:35:45 UTC (rev 10658)
@@ -0,0 +1,87 @@
+<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">
+ <parent>
+ <artifactId>jboss-parent</artifactId>
+ <groupId>jboss</groupId>
+ <version>1</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>jboss.maven-plugins</groupId>
+ <artifactId>jboss-retro-maven-plugin</artifactId>
+ <packaging>maven-plugin</packaging>
+ <name>JBoss Retro Maven Plugin</name>
+ <version>0.5-beta2</version>
+ <url>http://www.jboss.org</url>
+ <description>Maven plugin for jboss retro</description>
+ <scm>
+ <connection>scm:svn:https://svn.labs.jboss.org/labs/jbossbuild/maven-plugins/tags/jboss-retro-maven-plugin-0.5-beta2</connection>
+ </scm>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.0</version>
+ <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>
+ <repositories>
+ <repository>
+ <snapshots />
+ <id>jboss</id>
+ <name>JBoss Repository</name>
+ <url>http://repository.jboss.com/maven2/</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-backport-concurrent</artifactId>
+ <version>2.1.0.GA</version>
+ </dependency>
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>javassist</artifactId>
+ <version>3.4.ga</version>
+ </dependency>
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jbossretro</artifactId>
+ <version>1.0.5.GA</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ant</groupId>
+ <artifactId>ant</artifactId>
+ <version>1.7.0</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-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>
+ </dependencies>
+</project>
\ No newline at end of file
Copied: labs/jbossbuild/maven-plugins/tags/jboss-retro-maven-plugin-0.5-beta2/src/main/java/org/jboss/maven/plugins/retro/RetroCheckMojo.java (from rev 10656, labs/jbossbuild/maven-plugins/trunk/jboss-retro-maven-plugin/src/main/java/org/jboss/maven/plugins/retro/RetroCheckMojo.java)
===================================================================
--- labs/jbossbuild/maven-plugins/tags/jboss-retro-maven-plugin-0.5-beta2/src/main/java/org/jboss/maven/plugins/retro/RetroCheckMojo.java (rev 0)
+++ labs/jbossbuild/maven-plugins/tags/jboss-retro-maven-plugin-0.5-beta2/src/main/java/org/jboss/maven/plugins/retro/RetroCheckMojo.java 2007-03-30 18:35:45 UTC (rev 10658)
@@ -0,0 +1,186 @@
+package org.jboss.maven.plugins.retro;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.project.MavenProject;
+import org.jboss.ant.tasks.retrocheck.Checker;
+
+/**
+ * Maven wrapper for JBoss Retro. By default
+ * it will bind to the process classes phase, which takes
+ * place immediately after the compile phase.
+ *
+ * @goal retro-check
+ *
+ */
+public class RetroCheckMojo extends AbstractMojo
+{
+
+ //private static String lSep = System.getProperty("line.separator");
+
+ /**
+ * The Maven Project Object
+ *
+ * @parameter expression="${project}"
+ * @required
+ */
+ protected MavenProject project;
+
+ /**
+ * The Maven Project Helper Object
+ *
+ * @component
+ * @required
+ */
+ protected org.apache.maven.project.MavenProjectHelper projectHelper;
+
+ /**
+ * The Maven Plugin Object
+ *
+ * @parameter expression="${plugin.components}"
+ * @required
+ * @readonly
+ */
+ protected List pluginComponents;
+
+ /**
+ * The plugin dependencies.
+ *
+ * @parameter expression="${plugin.artifacts}"
+ * @required
+ * @readonly
+ */
+ private List pluginArtifacts;
+
+ /**
+ * Project classpath.
+ *
+ * @parameter expression="${project.compileClasspathElements}"
+ * @required
+ * @readonly
+ */
+ private List classpathElements;
+
+ /**
+ * @parameter expression="${project.pluginArtifacts}"
+ * @required
+ * @readonly
+ */
+ //private HashSet pluginArtifacts;
+ /**
+ * The directory for compiled classes.
+ *
+ * @parameter expression="${project.build.outputDirectory}"
+ * @required
+ * @readonly
+ */
+ private File targetClassesDirectory;
+
+ /**
+ * The directory for compiled classes.
+ *
+ * @parameter expression="${project.build.directory}"
+ * @required
+ * @readonly
+ */
+ private File targetDirectory;
+
+ /**
+ * @parameter
+ */
+ private boolean verbose = false;
+
+ /**
+ * @parameter
+ */
+ private boolean suppress = true;
+
+ public void execute()
+ {
+ this.getLog().info("[retro-check] Checking classes for jdk14");
+
+ if (!project.getArtifact().getType().equalsIgnoreCase("jar")) {
+ this.getLog().info("[retro-check] Project " + project.getName() + " is not"
+ + " a jar project. No retro compile needed.");
+ return;
+ }
+ ArrayList<String> argsList = new ArrayList<String>();
+
+ if (verbose)
+ {
+ argsList.add("-verbose");
+ }
+ if (suppress)
+ {
+ argsList.add("-suppress");
+ }
+ /*argsList.add("-destdir");
+ try
+ {
+ argsList.add(targetDirectory.getCanonicalPath() + "/classes-retro");
+ }
+ catch (Exception e)
+ {
+ this.getLog().error(e);
+ }*/
+ argsList.add("-cp");
+ StringBuilder classpath = new StringBuilder();
+ String pathSeparator = System.getProperty("path.separator");
+ for (Object element : classpathElements)
+ {
+ classpath.append(element);
+ classpath.append(pathSeparator);
+ }
+
+ for (Object artifact : pluginArtifacts)
+ {
+ try
+ {
+ File artifactFile = ((Artifact) artifact).getFile();
+ if (artifactFile != null)
+ {
+ classpath.append(artifactFile.getCanonicalPath());
+ classpath.append(pathSeparator);
+ }
+ }
+ catch (IOException ioe)
+ {
+ this.getLog().warn("Could not get filename");
+ }
+ }
+
+ argsList.add(classpath.toString());
+
+ try
+ {
+ argsList.add(targetDirectory.getCanonicalPath() +
+ System.getProperty("file.separator") + "classes-retro");
+ }
+ catch (IOException ioe)
+ {
+ this.getLog().error(ioe.toString());
+ }
+
+ String[] args = new String[argsList.size()];
+ for (int i = 0; i < args.length; ++i)
+ {
+ args[i] = argsList.get(i);
+ }
+
+ Checker checker = new Checker();
+ try
+ {
+ checker.check(args);
+ }
+ catch (Exception e)
+ {
+ this.getLog().error(e);
+ }
+
+ }
+}
Deleted: labs/jbossbuild/maven-plugins/tags/jboss-retro-maven-plugin-0.5-beta2/src/main/java/org/jboss/maven/plugins/retro/RetroMojo.java
===================================================================
--- labs/jbossbuild/maven-plugins/trunk/jboss-retro-maven-plugin/src/main/java/org/jboss/maven/plugins/retro/RetroMojo.java 2007-03-29 12:45:49 UTC (rev 10612)
+++ labs/jbossbuild/maven-plugins/tags/jboss-retro-maven-plugin-0.5-beta2/src/main/java/org/jboss/maven/plugins/retro/RetroMojo.java 2007-03-30 18:35:45 UTC (rev 10658)
@@ -1,277 +0,0 @@
-package org.jboss.maven.plugins.retro;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.jar.Attributes;
-import java.util.jar.JarEntry;
-import java.util.jar.JarOutputStream;
-import java.util.jar.Manifest;
-import java.util.zip.Deflater;
-
-import org.apache.commons.io.FileUtils;
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.plugin.AbstractMojo;
-import org.apache.maven.project.MavenProject;
-import org.jboss.ant.tasks.retro.Weaver;
-
-/**
- * Maven wrapper for JBoss Retro. By default
- * it will bind to the process classes phase, which takes
- * place immediately after the compile phase.
- *
- * @phase process-classes
- * @goal retro-compile
- *
- */
-public class RetroMojo extends AbstractMojo
-{
-
- //private static String lSep = System.getProperty("line.separator");
-
- /**
- * The Maven Project Object
- *
- * @parameter expression="${project}"
- * @required
- */
- protected MavenProject project;
-
- /**
- * The Maven Project Helper Object
- *
- * @component
- * @required
- */
- protected org.apache.maven.project.MavenProjectHelper projectHelper;
-
- /**
- * The Maven Plugin Object
- *
- * @parameter expression="${plugin.components}"
- * @required
- * @readonly
- */
- protected List pluginComponents;
-
- /**
- * The plugin dependencies.
- *
- * @parameter expression="${plugin.artifacts}"
- * @required
- * @readonly
- */
- private List pluginArtifacts;
-
- /**
- * Project classpath.
- *
- * @parameter expression="${project.compileClasspathElements}"
- * @required
- * @readonly
- */
- private List classpathElements;
-
- /**
- * @parameter expression="${project.pluginArtifacts}"
- * @required
- * @readonly
- */
- //private HashSet pluginArtifacts;
- /**
- * The directory for compiled classes.
- *
- * @parameter expression="${project.build.outputDirectory}"
- * @required
- * @readonly
- */
- private File targetClassesDirectory;
-
- /**
- * The directory for compiled classes.
- *
- * @parameter expression="${project.build.directory}"
- * @required
- * @readonly
- */
- private File targetDirectory;
-
- /**
- * @parameter
- */
- private boolean verbose = false;
-
- /**
- * @parameter
- */
- private boolean suppress = true;
-
- /**
- * List of the jar file entries
- */
- private ArrayList<JarFileEntry> fileEntries = new ArrayList<JarFileEntry>();
-
- public void execute()
- {
- this.getLog().info("[retro] Compiling classes for jdk14");
-
- if (!project.getArtifact().getType().equalsIgnoreCase("jar")) {
- this.getLog().info("[retro] Project " + project.getName() + " is not"
- + " a jar project. No retro compile needed.");
- return;
- }
- ArrayList<String> argsList = new ArrayList<String>();
-
- if (verbose)
- {
- argsList.add("-verbose");
- }
- if (suppress)
- {
- argsList.add("-suppress");
- }
- argsList.add("-destdir");
- try
- {
- argsList.add(targetDirectory.getCanonicalPath() + "/classes-retro");
- }
- catch (Exception e)
- {
- this.getLog().error(e);
- }
- argsList.add("-cp");
- StringBuilder classpath = new StringBuilder();
- String pathSeparator = System.getProperty("path.separator");
- for (Object element : classpathElements)
- {
- classpath.append(element);
- classpath.append(pathSeparator);
- }
-
- for (Object artifact : pluginArtifacts)
- {
- try
- {
- File artifactFile = ((Artifact) artifact).getFile();
- if (artifactFile != null)
- {
- classpath.append(artifactFile.getCanonicalPath());
- classpath.append(pathSeparator);
- }
- }
- catch (IOException ioe)
- {
- this.getLog().warn("Could not get filename");
- }
- }
-
- argsList.add(classpath.toString());
-
- try
- {
- argsList.add(targetClassesDirectory.getCanonicalPath());
- }
- catch (IOException ioe)
- {
- this.getLog().error(ioe.toString());
- }
-
- String[] args = new String[argsList.size()];
- for (int i = 0; i < args.length; ++i)
- {
- args[i] = argsList.get(i);
- }
-
- Weaver weaver = new Weaver();
- try
- {
- weaver.weave(args);
- }
- catch (Exception e)
- {
- this.getLog().error(e);
- }
-
- // Create jar file and attach it to maven.
- File retroJarFile = new File(targetDirectory.getAbsolutePath() + "/" + project.getArtifactId() + "-jdk14.jar");
- createJarEntries();
- createRetroJarFile(retroJarFile);
- projectHelper.attachArtifact(project, retroJarFile, "jdk14");
- }
-
- private void createJarEntries()
- {
- try
- {
- File retroClassesDir = new File(targetDirectory.getAbsolutePath() + "/classes-retro");
- Collection retroClasses = FileUtils.listFiles(retroClassesDir, null, true);
- for (Object classFile : retroClasses)
- {
- String relativePath = classFile.toString().replace(retroClassesDir.getAbsolutePath() + "/", "");
- byte[] content = FileUtils.readFileToByteArray((File) classFile);
- fileEntries.add(new JarFileEntry(relativePath, content));
- }
- }
- catch (IOException ioe)
- {
- this.getLog().error("error reading class file: " + ioe);
- }
- }
-
- private void createRetroJarFile(File retroJarFile)
- {
- try
- {
- Manifest manifest = new Manifest();
- Attributes attributes = manifest.getMainAttributes();
- attributes.putValue("Manifest-Version", "1.0");
- attributes.putValue("Created-By", System.getProperty("java.vm.version") + " ("
- + System.getProperty("java.vm.vendor") + ")");
- JarOutputStream stream = new JarOutputStream(new FileOutputStream(retroJarFile), manifest);
- stream.setLevel(Deflater.BEST_COMPRESSION);
- for (JarFileEntry fileEntry : fileEntries)
- {
- JarEntry jarEntry = new JarEntry(fileEntry.getName());
- stream.putNextEntry(jarEntry);
- stream.write(fileEntry.getContent());
- }
- stream.close();
- }
- catch (IOException ioe)
- {
- this.getLog().error("Unable to write retro jar: " + ioe);
- }
- }
-
- private static class JarFileEntry
- {
-
- private byte[] content;
-
- private String name;
-
- public JarFileEntry(String name, byte[] content)
- {
- this.name = name;
- this.content = content;
- }
-
- public byte[] getContent()
- {
- return content;
- }
-
- public String getName()
- {
- return name;
- }
-
- public void setName(String name)
- {
- this.name = name;
- }
- }
-}
Copied: labs/jbossbuild/maven-plugins/tags/jboss-retro-maven-plugin-0.5-beta2/src/main/java/org/jboss/maven/plugins/retro/RetroMojo.java (from rev 10655, labs/jbossbuild/maven-plugins/trunk/jboss-retro-maven-plugin/src/main/java/org/jboss/maven/plugins/retro/RetroMojo.java)
===================================================================
--- labs/jbossbuild/maven-plugins/tags/jboss-retro-maven-plugin-0.5-beta2/src/main/java/org/jboss/maven/plugins/retro/RetroMojo.java (rev 0)
+++ labs/jbossbuild/maven-plugins/tags/jboss-retro-maven-plugin-0.5-beta2/src/main/java/org/jboss/maven/plugins/retro/RetroMojo.java 2007-03-30 18:35:45 UTC (rev 10658)
@@ -0,0 +1,281 @@
+package org.jboss.maven.plugins.retro;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.jar.Attributes;
+import java.util.jar.JarEntry;
+import java.util.jar.JarOutputStream;
+import java.util.jar.Manifest;
+import java.util.zip.Deflater;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.project.MavenProject;
+import org.jboss.ant.tasks.retro.Weaver;
+
+/**
+ * Maven wrapper for JBoss Retro. By default
+ * it will bind to the process classes phase, which takes
+ * place immediately after the compile phase.
+ *
+ * @phase process-classes
+ * @goal retro-compile
+ *
+ */
+public class RetroMojo extends AbstractMojo
+{
+
+ //private static String lSep = System.getProperty("line.separator");
+
+ /**
+ * The Maven Project Object
+ *
+ * @parameter expression="${project}"
+ * @required
+ */
+ protected MavenProject project;
+
+ /**
+ * The Maven Project Helper Object
+ *
+ * @component
+ * @required
+ */
+ protected org.apache.maven.project.MavenProjectHelper projectHelper;
+
+ /**
+ * The Maven Plugin Object
+ *
+ * @parameter expression="${plugin.components}"
+ * @required
+ * @readonly
+ */
+ protected List pluginComponents;
+
+ /**
+ * The plugin dependencies.
+ *
+ * @parameter expression="${plugin.artifacts}"
+ * @required
+ * @readonly
+ */
+ private List pluginArtifacts;
+
+ /**
+ * Project classpath.
+ *
+ * @parameter expression="${project.compileClasspathElements}"
+ * @required
+ * @readonly
+ */
+ private List classpathElements;
+
+ /**
+ * @parameter expression="${project.pluginArtifacts}"
+ * @required
+ * @readonly
+ */
+ //private HashSet pluginArtifacts;
+ /**
+ * The directory for compiled classes.
+ *
+ * @parameter expression="${project.build.outputDirectory}"
+ * @required
+ * @readonly
+ */
+ private File targetClassesDirectory;
+
+ /**
+ * The directory for compiled classes.
+ *
+ * @parameter expression="${project.build.directory}"
+ * @required
+ * @readonly
+ */
+ private File targetDirectory;
+
+ /**
+ * @parameter
+ */
+ private boolean verbose = false;
+
+ /**
+ * @parameter
+ */
+ private boolean suppress = true;
+
+ /**
+ * List of the jar file entries
+ */
+ private ArrayList<JarFileEntry> fileEntries = new ArrayList<JarFileEntry>();
+
+ public void execute()
+ {
+ this.getLog().info("[retro] Compiling classes for jdk14");
+
+ if (!project.getArtifact().getType().equalsIgnoreCase("jar")) {
+ this.getLog().info("[retro] Project " + project.getName() + " is not"
+ + " a jar project. No retro compile needed.");
+ return;
+ }
+ ArrayList<String> argsList = new ArrayList<String>();
+
+ if (verbose)
+ {
+ argsList.add("-verbose");
+ }
+ if (suppress)
+ {
+ argsList.add("-suppress");
+ }
+ argsList.add("-destdir");
+ String fileSep = System.getProperty("file.separator");
+ try
+ {
+ argsList.add(targetDirectory.getCanonicalPath() + fileSep + "classes-retro/");
+ }
+ catch (Exception e)
+ {
+ this.getLog().error(e);
+ }
+ argsList.add("-cp");
+ StringBuilder classpath = new StringBuilder();
+ String pathSeparator = System.getProperty("path.separator");
+ for (Object element : classpathElements)
+ {
+ classpath.append(element);
+ classpath.append(pathSeparator);
+ }
+
+ for (Object artifact : pluginArtifacts)
+ {
+ try
+ {
+ File artifactFile = ((Artifact) artifact).getFile();
+ if (artifactFile != null)
+ {
+ classpath.append(artifactFile.getCanonicalPath());
+ classpath.append(pathSeparator);
+ }
+ }
+ catch (IOException ioe)
+ {
+ this.getLog().warn("Could not get filename");
+ }
+ }
+
+ argsList.add(classpath.toString());
+
+ try
+ {
+ argsList.add(targetClassesDirectory.getCanonicalPath());
+ }
+ catch (IOException ioe)
+ {
+ this.getLog().error(ioe.toString());
+ }
+
+ String[] args = new String[argsList.size()];
+ for (int i = 0; i < args.length; ++i)
+ {
+ args[i] = argsList.get(i);
+ }
+
+ Weaver weaver = new Weaver();
+ try
+ {
+ weaver.weave(args);
+ }
+ catch (Exception e)
+ {
+ this.getLog().error(e);
+ }
+
+ // Create jar file and attach it to maven.
+ File retroJarFile = new File(targetDirectory.getAbsolutePath() + "/" + project.getArtifactId() + "-jdk14.jar");
+ File retroClassesDir = new File(targetDirectory.getAbsolutePath() + "/classes-retro");
+ if (retroClassesDir.exists()) {
+ createJarEntries(retroClassesDir);
+ createRetroJarFile(retroJarFile);
+ projectHelper.attachArtifact(project, retroJarFile, "jdk14");
+ }
+ }
+
+ private void createJarEntries(File retroClassesDir)
+ {
+ try
+ {
+ this.getLog().info("DEBUG: " + retroClassesDir.getAbsolutePath());
+ Collection retroClasses = FileUtils.listFiles(retroClassesDir, null, true);
+ for (Object classFile : retroClasses)
+ {
+ String relativePath = classFile.toString().replace(retroClassesDir.getAbsolutePath() + "/", "");
+ byte[] content = FileUtils.readFileToByteArray((File) classFile);
+ fileEntries.add(new JarFileEntry(relativePath, content));
+ }
+ }
+ catch (IOException ioe)
+ {
+ this.getLog().error("error reading class file: " + ioe);
+ }
+ }
+
+ private void createRetroJarFile(File retroJarFile)
+ {
+ try
+ {
+ Manifest manifest = new Manifest();
+ Attributes attributes = manifest.getMainAttributes();
+ attributes.putValue("Manifest-Version", "1.0");
+ attributes.putValue("Created-By", System.getProperty("java.vm.version") + " ("
+ + System.getProperty("java.vm.vendor") + ")");
+ JarOutputStream stream = new JarOutputStream(new FileOutputStream(retroJarFile), manifest);
+ stream.setLevel(Deflater.BEST_COMPRESSION);
+ for (JarFileEntry fileEntry : fileEntries)
+ {
+ JarEntry jarEntry = new JarEntry(fileEntry.getName());
+ stream.putNextEntry(jarEntry);
+ stream.write(fileEntry.getContent());
+ }
+ stream.close();
+ }
+ catch (IOException ioe)
+ {
+ this.getLog().error("Unable to write retro jar: " + ioe);
+ }
+ }
+
+ private static class JarFileEntry
+ {
+
+ private byte[] content;
+
+ private String name;
+
+ public JarFileEntry(String name, byte[] content)
+ {
+ this.name = name;
+ this.content = content;
+ }
+
+ public byte[] getContent()
+ {
+ return content;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+ }
+}
More information about the jboss-svn-commits
mailing list