From 62adbd11751495fef157a99927daa217b9bfa249 Mon Sep 17 00:00:00 2001 From: Vincent Massol Date: Fri, 21 Oct 2005 18:20:17 +0000 Subject: [PATCH] First pass at fixing MNG-1136. This is still not working as the jdk config property is not passed by the check mojo. Thus the jdk property is always null git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@327233 13f79535-47bb-0310-9956-ffa450edef68 --- .../plugin/clover/AbstractCloverMojo.java | 8 ++++ .../maven/plugin/clover/CloverCheckMojo.java | 4 +- .../plugin/clover/CloverInstrumentMojo.java | 47 +++++++++++++++++-- 3 files changed, 52 insertions(+), 7 deletions(-) diff --git a/maven-plugins/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/AbstractCloverMojo.java b/maven-plugins/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/AbstractCloverMojo.java index f42ba43016..21cbb46392 100644 --- a/maven-plugins/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/AbstractCloverMojo.java +++ b/maven-plugins/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/AbstractCloverMojo.java @@ -26,6 +26,14 @@ public abstract class AbstractCloverMojo extends AbstractMojo */ private String licenseFile; + /** + * Whether the Clover instrumentation should use the Clover jdk14 or + * jdk15 flags to parse sources. + * + * @parameter + */ + protected String jdk; + /** * Registers the license file for Clover runtime by setting the * clover.license.path system property. If the licenseFile diff --git a/maven-plugins/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/CloverCheckMojo.java b/maven-plugins/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/CloverCheckMojo.java index c65eb82fee..1fd4690134 100644 --- a/maven-plugins/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/CloverCheckMojo.java +++ b/maven-plugins/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/CloverCheckMojo.java @@ -39,13 +39,13 @@ public class CloverCheckMojo * @parameter expression="${project.build.directory}/clover/clover.db" * @required */ - protected String cloverDatabase; + private String cloverDatabase; /** * @parameter default-value="70%" * @required */ - protected String targetPercentage; + private String targetPercentage; public void execute() throws MojoExecutionException diff --git a/maven-plugins/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/CloverInstrumentMojo.java b/maven-plugins/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/CloverInstrumentMojo.java index 987158f202..d3da861d98 100644 --- a/maven-plugins/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/CloverInstrumentMojo.java +++ b/maven-plugins/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/CloverInstrumentMojo.java @@ -23,6 +23,7 @@ import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.project.MavenProject; import java.io.File; +import java.util.ArrayList; import java.util.HashSet; import java.util.Iterator; import java.util.List; @@ -149,11 +150,47 @@ public class CloverInstrumentMojo * @return the CLI args to be passed to CloverInstr * @todo handle multiple source roots. At the moment only the first source root is instrumented */ - private String[] createCliArgs() + private String[] createCliArgs() throws MojoExecutionException { - // TODO: Temporary while we wait for surefire to be able to fork unit tests. See - // http://jira.codehaus.org/browse/MNG-441 - return new String[]{"-p", "threaded", "-f", "100", "-i", this.cloverDatabase, "-s", - (String) this.project.getCompileSourceRoots().get( 0 ), "-d", this.cloverOutputSourceDirectory}; + List parameters = new ArrayList(); + + // TODO: The usage of the threaded flushpolicy model and a flush policy is temporary while + // we wait for surefire to be able to fork unit tests. See http://jira.codehaus.org/browse/MNG-441 + + parameters.add( "-p" ); + parameters.add( "threaded" ); + parameters.add( "-f" ); + parameters.add( "100" ); + + parameters.add( "-i" ); + parameters.add( this.cloverDatabase ); + parameters.add( "-s" ); + + // TODO: Allow support for several source roots in the future. + parameters.add( (String) this.project.getCompileSourceRoots().get( 0 ) ); + + parameters.add( "-d" ); + parameters.add( this.cloverOutputSourceDirectory ); + + if ( this.jdk != null ) + { + if ( this.jdk.equals( "1.4" ) ) + { + parameters.add( "-jdk14" ); + } + else if ( this.jdk.equals( "1.5" ) ) + { + parameters.add( "-jdk15" ); + } + else + { + throw new MojoExecutionException("Unsupported jdk version [" + this.jdk + + "]. Valid values are [1.4] and [1.5]"); + } + } + + getLog().debug( "Instrumenting using parameters [" + parameters.toString() + "]"); + + return (String[]) parameters.toArray(new String[0]); } }