You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by vm...@apache.org on 2006/01/08 19:21:44 UTC
svn commit: r367064 -
/maven/plugins/trunk/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/CloverInstrumentMojo.java
Author: vmassol
Date: Sun Jan 8 10:21:40 2006
New Revision: 367064
URL: http://svn.apache.org/viewcvs?rev=367064&view=rev
Log:
MCLOVER-16: Using Clover with projects that require class post-processing
I still need to write a test to prove it works though...
Modified:
maven/plugins/trunk/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/CloverInstrumentMojo.java
Modified: maven/plugins/trunk/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/CloverInstrumentMojo.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/CloverInstrumentMojo.java?rev=367064&r1=367063&r2=367064&view=diff
==============================================================================
--- maven/plugins/trunk/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/CloverInstrumentMojo.java (original)
+++ maven/plugins/trunk/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/CloverInstrumentMojo.java Sun Jan 8 10:21:40 2006
@@ -92,8 +92,8 @@
init();
registerLicenseFile();
instrumentSources();
- addGeneratedSourcesToCompileRoots();
addCloverDependencyToCompileClasspath();
+ redirectSourceDirectories();
redirectOutputDirectories();
}
}
@@ -141,16 +141,29 @@
this.project.getBuild().setTestOutputDirectory(
new File( this.cloverOutputDirectory, "test-classes" ).getPath() );
}
-
- /**
- * @todo handle multiple source roots. At the moment only the first source root is instrumented
- */
- private void addGeneratedSourcesToCompileRoots()
+
+ private void redirectSourceDirectories()
{
- this.project.getCompileSourceRoots().remove( 0 );
- this.project.addCompileSourceRoot( this.cloverOutputSourceDirectory );
- }
+ String oldSourceDirectory = this.project.getBuild().getSourceDirectory();
+ this.project.getBuild().setSourceDirectory( this.cloverOutputSourceDirectory );
+
+ // Maven2 limitation: changing the source directory doesn't change the compile source roots
+ List sourceRoots = this.project.getCompileSourceRoots();
+ for (int i = 0; i < sourceRoots.size(); i++)
+ {
+ String sourceRoot = (String) this.project.getCompileSourceRoots().get( i );
+ if (sourceRoot.equals(oldSourceDirectory))
+ {
+ this.project.getCompileSourceRoots().remove( i );
+
+ // Note: Ideally we should add the new compile source root at the same place as the
+ // one we're removing but there's no API for this...
+ this.project.addCompileSourceRoot( this.project.getBuild().getSourceDirectory() );
+ }
+ }
+ }
+
private void addCloverDependencyToCompileClasspath()
throws MojoExecutionException
{