[jboss-svn-commits] JBL Code SVN: r13845 - in labs/jbossbuild/maven-plugins/trunk/maven-jboss-retro-plugin: src/main/java/org/jboss/maven/plugins/retro and 1 other directory.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Mon Jul 30 09:59:28 EDT 2007
Author: pgier
Date: 2007-07-30 09:59:27 -0400 (Mon, 30 Jul 2007)
New Revision: 13845
Modified:
labs/jbossbuild/maven-plugins/trunk/maven-jboss-retro-plugin/pom.xml
labs/jbossbuild/maven-plugins/trunk/maven-jboss-retro-plugin/src/main/java/org/jboss/maven/plugins/retro/RetroCheckMojo.java
labs/jbossbuild/maven-plugins/trunk/maven-jboss-retro-plugin/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/WeaveTestsMojo.java
Log:
Adding working retro-check mojo.
Minor improvements to weave and weave-tests mojos.
Modified: labs/jbossbuild/maven-plugins/trunk/maven-jboss-retro-plugin/pom.xml
===================================================================
--- labs/jbossbuild/maven-plugins/trunk/maven-jboss-retro-plugin/pom.xml 2007-07-30 13:54:51 UTC (rev 13844)
+++ labs/jbossbuild/maven-plugins/trunk/maven-jboss-retro-plugin/pom.xml 2007-07-30 13:59:27 UTC (rev 13845)
@@ -21,7 +21,6 @@
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
- <version>2.0</version>
<configuration>
<optimize>true</optimize>
<source>1.5</source>
@@ -36,19 +35,11 @@
</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>org.jboss</groupId>
<artifactId>jboss-retro</artifactId>
- <version>[1.1, 1.2)</version>
+ <version>[1.1.0, 1.2.0)</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
@@ -83,7 +74,7 @@
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
- <version>1.4.4</version>
+ <version>1.4.1</version>
</dependency>
</dependencies>
<distributionManagement>
Modified: labs/jbossbuild/maven-plugins/trunk/maven-jboss-retro-plugin/src/main/java/org/jboss/maven/plugins/retro/RetroCheckMojo.java
===================================================================
--- labs/jbossbuild/maven-plugins/trunk/maven-jboss-retro-plugin/src/main/java/org/jboss/maven/plugins/retro/RetroCheckMojo.java 2007-07-30 13:54:51 UTC (rev 13844)
+++ labs/jbossbuild/maven-plugins/trunk/maven-jboss-retro-plugin/src/main/java/org/jboss/maven/plugins/retro/RetroCheckMojo.java 2007-07-30 13:59:27 UTC (rev 13845)
@@ -12,7 +12,6 @@
import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import org.apache.maven.artifact.resolver.ArtifactResolver;
-import org.apache.maven.model.Plugin;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.project.MavenProject;
@@ -33,8 +32,8 @@
public class RetroCheckMojo extends AbstractMojo
{
- //private static String lSep = System.getProperty("line.separator");
-
+ public static final String JBOSS_RETRO_ARTIFACTID = "jboss-retro";
+
/**
* The Maven Project Object
*
@@ -103,54 +102,8 @@
* @readonly
*/
private List pluginArtifacts;
-
- /**
- * The plugin dependencies.
- *
- * @parameter expression="${plugin.dependencies}"
- * @required
- * @readonly
- */
- private List pluginDependencies;
-
- /**
- * Project classpath.
- *
- * @parameter expression="${project.compileClasspathElements}"
- * @required
- * @readonly
- */
- private List classpathElements;
-
/**
- * The directory for compiled classes.
- *
- * @parameter expression="${project.build.outputDirectory}"
- * @required
- * @readonly
- */
- private File targetClassesDirectory;
-
- /**
- * The directory for compiled classes.
- *
- *
- * @required
- * @readonly
- */
- private Plugin thePlugin;
-
- /**
- * The directory for compiled classes.
- *
- * @parameter expression="${project.build.directory}"
- * @required
- * @readonly
- */
- private File targetDirectory;
-
- /**
* The path to the classes to be checked, relative to
* the build directory. Defaults to a value of
* "classes-weaved" which means that classes in the direcotry
@@ -161,11 +114,13 @@
private String checkDirectory;
/**
+ * Enable verbose output
* @parameter
*/
private boolean verbose = false;
/**
+ * Suppress output
* @parameter
*/
private boolean suppress = false;
@@ -180,10 +135,20 @@
*/
private File jbossRetroRtJar = null;
+ /**
+ * Ignore check errors. If set to true, the build will continue
+ * regardless of whether there are check errors.
+ * Default is false.
+ *
+ * @parameter
+ *
+ */
+ private boolean ignoreErrors = false;
+
public void execute() throws MojoExecutionException
{
// First, make sure checker and runtime available on the classpath
- resolveCheckerLocation();
+ this.resolveCheckerLocation();
if ( jvm == null || jvm.equals("") )
{
@@ -192,16 +157,58 @@
getLog().debug( "Using JVM: " + jvm );
}
- 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;
- }
+ this.getLog().info("Checking classes for jdk14");
+
ArrayList<String> argsList = new ArrayList<String>();
argsList.add("-cp");
+
+ String classpath = this.createCheckerClasspath();
+ getLog().debug("Using checker classpath: " + classpath);
+ argsList.add(classpath);
+
+ argsList.add("org.jboss.ant.tasks.retrocheck.Checker");
+
+ if (verbose)
+ {
+ argsList.add("-verbose");
+ }
+
+ if (suppress)
+ {
+ argsList.add("-suppress");
+ }
+
+ String retroClassesDir = project.getBuild().getDirectory() + File.separator + checkDirectory;
+ argsList.add(retroClassesDir);
+
+ String[] args = new String[argsList.size()];
+ args = argsList.toArray(args);
+
+ Commandline cli = new Commandline();
+
+ cli.setExecutable( jvm );
+ cli.addArguments(args);
+
+ StreamConsumer out = new MojoLogStreamConsumer();
+ StreamConsumer err = new MojoLogStreamConsumer();
+
+ try
+ {
+ int returnCode = CommandLineUtils.executeCommandLine( cli, out, err );
+ if ( ( ! ignoreErrors ) && returnCode != 0)
+ {
+ throw new MojoExecutionException("There were errors during the retro check");
+ }
+ }
+ catch ( CommandLineException e )
+ {
+ throw new MojoExecutionException( "Error while executing forked tests.", e );
+ }
+ }
+
+ public String createCheckerClasspath()
+ {
StringBuilder classpath = new StringBuilder();
String fileSep = System.getProperty("file.separator");
@@ -212,7 +219,7 @@
for (Object artifactObj : pluginArtifacts)
{
Artifact artifact = (Artifact)artifactObj;
- if (artifact.getArtifactId().equals("jboss-retro") && artifact.getClassifier() == null)
+ if (artifact.getArtifactId().equals(JBOSS_RETRO_ARTIFACTID) && artifact.getClassifier() == null)
{
// We don't want to include the jboss-retro dependency for the checks
// because the jboss-retro jar is jdk1.5 and we should be running under 1.4
@@ -238,85 +245,39 @@
classpath.append(this.jbossRetroRtJar.getAbsolutePath());
classpath.append(File.pathSeparator);
- getLog().debug("Using checker classpath: " +classpath.toString());
- argsList.add(classpath.toString());
-
- argsList.add("org.jboss.ant.tasks.retrocheck.Checker");
-
- if (verbose)
- {
- argsList.add("-verbose");
- }
-
- if (suppress)
- {
- argsList.add("-suppress");
- }
-
- argsList.add(project.getBuild().getDirectory() +
- File.separator + checkDirectory);
-
- String[] args = new String[argsList.size()];
- for (int i = 0; i < args.length; ++i)
- {
- args[i] = argsList.get(i);
- }
-
- Commandline cli = new Commandline();
-
- cli.setExecutable( jvm );
- cli.addArguments(args);
-
- StreamConsumer out = new MojoLogStreamConsumer();
-
- StreamConsumer err = new MojoLogStreamConsumer();
-
- int returnCode;
-
- try
- {
- returnCode = CommandLineUtils.executeCommandLine( cli, out, err );
- getLog().info("Checker returned with code: " + returnCode);
- }
- catch ( CommandLineException e )
- {
- throw new MojoExecutionException( "Error while executing forked tests.", e );
- }
+ return classpath.toString();
}
-
+
/**
* Resolve the location of the Checker class, and the retro runtime classes
*
*/
public void resolveCheckerLocation() throws MojoExecutionException
{
- // First figure out which verion of retro should be used
+ // Figure out which verion of retro should be used
String jbossRetroVersion = null;
- Iterator iter = this.pluginArtifacts.iterator();
- while(iter.hasNext()) {
- Artifact nextArtifact = (Artifact)iter.next();
- if (nextArtifact.getArtifactId().equals("jboss-retro")
- && nextArtifact.getClassifier() == null)
- {
- jbossRetroVersion = nextArtifact.getVersion();
- }
- }
-
- // Next determine if the checker and runtime are attached to the project
- // (meaning that we are checking a build of jboss-retro itself)
- List attachedArtifacts = project.getAttachedArtifacts();
- for (Object artifactObj : attachedArtifacts) {
- Artifact artifact = (Artifact)artifactObj;
- if (artifact.getArtifactId().equals("jboss-retro") && artifact.getClassifier().equals("retrocheck"))
- {
- if (artifact.getClassifier().equals("retrocheck"))
+
+ // If we are checking jboss retro itself, we have to do this to make sure
+ // the local files are used instead of repository files.
+ if (project.getArtifactId().equals(JBOSS_RETRO_ARTIFACTID))
+ {
+ jbossRetroVersion = project.getVersion();
+
+ // Determine if the checker and runtime are attached to the project
+ List attachedArtifacts = project.getAttachedArtifacts();
+ for (Object artifactObj : attachedArtifacts) {
+ Artifact artifact = (Artifact)artifactObj;
+ if (artifact.getArtifactId().equals(JBOSS_RETRO_ARTIFACTID))
{
- this.jbossRetroCheckJar = artifact.getFile();
+ if (artifact.getClassifier().equals("retrocheck"))
+ {
+ this.jbossRetroCheckJar = artifact.getFile();
+ }
+ else if(artifact.getClassifier().equals("rt"))
+ {
+ this.jbossRetroRtJar = artifact.getFile();
+ }
}
- else if(artifact.getClassifier().equals("rt"))
- {
- this.jbossRetroRtJar = artifact.getFile();
- }
}
}
@@ -326,9 +287,19 @@
return;
}
+ Iterator iter = this.pluginArtifacts.iterator();
+ while(iter.hasNext() && jbossRetroVersion==null) {
+ Artifact nextArtifact = (Artifact)iter.next();
+ if (nextArtifact.getArtifactId().equals(JBOSS_RETRO_ARTIFACTID)
+ && nextArtifact.getClassifier() == null)
+ {
+ jbossRetroVersion = nextArtifact.getVersion();
+ }
+ }
+
// Get the checker and runtime from the repository
- Artifact checkerArtifact = artifactFactory.createArtifactWithClassifier("org.jboss", "jboss-retro", jbossRetroVersion, "jar", "retrocheck");
- Artifact runtimeArtifact = artifactFactory.createArtifactWithClassifier("org.jboss", "jboss-retro", jbossRetroVersion, "jar", "rt");
+ Artifact checkerArtifact = artifactFactory.createArtifactWithClassifier("org.jboss", JBOSS_RETRO_ARTIFACTID, jbossRetroVersion, "jar", "retrocheck");
+ Artifact runtimeArtifact = artifactFactory.createArtifactWithClassifier("org.jboss", JBOSS_RETRO_ARTIFACTID, jbossRetroVersion, "jar", "rt");
try
{
artifactResolver.resolve(checkerArtifact, project.getRemoteArtifactRepositories(), localRepository);
@@ -345,7 +316,6 @@
this.jbossRetroCheckJar = checkerArtifact.getFile();
this.jbossRetroRtJar = runtimeArtifact.getFile();
-
}
Modified: labs/jbossbuild/maven-plugins/trunk/maven-jboss-retro-plugin/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-07-30 13:54:51 UTC (rev 13844)
+++ labs/jbossbuild/maven-plugins/trunk/maven-jboss-retro-plugin/src/main/java/org/jboss/maven/plugins/retro/WeaveMojo.java 2007-07-30 13:59:27 UTC (rev 13845)
@@ -13,6 +13,8 @@
import java.util.zip.Deflater;
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;
@@ -32,6 +34,8 @@
*/
public class WeaveMojo extends AbstractMojo
{
+ public static final String JBOSS_RETRO_ARTIFACTID = "jboss-retro";
+
protected final String fileSep = System.getProperty("file.separator");
protected final String pathSep = System.getProperty("path.separator");
@@ -60,16 +64,6 @@
protected org.apache.maven.project.MavenProjectHelper projectHelper;
/**
- * The Maven Plugin Components
- * TODO: I don't think this param is needed.
- *
- * @parameter expression="${plugin.components}"
- * @required
- * @readonly
- */
- protected List pluginComponents;
-
- /**
* The plugin dependencies.
*
* @parameter expression="${plugin.artifacts}"
@@ -92,7 +86,6 @@
*
* @parameter expression="${project.build.outputDirectory}"
* @required
- * @readonly
*/
protected File classesDirectory;
@@ -144,9 +137,13 @@
*/
public void execute() throws MojoFailureException
{
- this.getLog().info("[weaver] Weaving classes");
+ this.getLog().info("Weaving classes in: " + this.getClassesDirecotry());
+ long start = System.currentTimeMillis();
weaveClasses();
+
+ long end = System.currentTimeMillis();
+ this.getLog().info("Weaving complete: " + (end - start) + "ms");
}
protected void weaveClasses() throws MojoFailureException {
@@ -158,14 +155,13 @@
weaveRunner.setVerbose(verbose);
weaveRunner.setSuppress(suppress);
+ weaveRunner.setUsingSystemClasspath(false);
weaveRunner.setOutputPath(getOutputPath());
try
{
weaveRunner.addSourcePath(this.getClassesDirecotry().getAbsolutePath());
- getLog().info("Weaving classes in path: " + this.getClassesDirecotry().getAbsolutePath());
-
weaveRunner.weave();
}
catch (Exception e)
@@ -190,15 +186,29 @@
classpath.append(pathSep);
}
- for (Object artifact : pluginArtifacts)
+ // 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
{
- File artifactFile = ((Artifact) artifact).getFile();
- if (artifactFile != null)
+ Artifact artifact = (Artifact) artifactObj;
+ if (artifact.getFile() != null)
{
- classpath.append(artifactFile.getCanonicalPath());
- classpath.append(pathSep);
+ if ( useRetroDep || ( ! artifact.getArtifactId().equals(JBOSS_RETRO_ARTIFACTID)))
+ {
+ classpath.append(artifact.getFile().getCanonicalPath());
+ classpath.append(pathSep);
+ }
}
}
catch (IOException ioe)
Modified: labs/jbossbuild/maven-plugins/trunk/maven-jboss-retro-plugin/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-07-30 13:54:51 UTC (rev 13844)
+++ labs/jbossbuild/maven-plugins/trunk/maven-jboss-retro-plugin/src/main/java/org/jboss/maven/plugins/retro/WeaveTestsMojo.java 2007-07-30 13:59:27 UTC (rev 13845)
@@ -48,14 +48,6 @@
* @parameter
*/
protected boolean suppress = true;
-
- public void execute() throws MojoFailureException
- {
- this.getLog().info("[weaver] Weaving test classes");
- //System.out.println(this.classpathElements);
- //super.classpathElements = classpathElements;
- weaveClasses();
- }
public List getClasspathElements()
{
More information about the jboss-svn-commits
mailing list