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
This commit is contained in:
Vincent Massol 2005-10-21 18:20:17 +00:00
parent 402843facc
commit 62adbd1175
3 changed files with 52 additions and 7 deletions

View File

@ -26,6 +26,14 @@ public abstract class AbstractCloverMojo extends AbstractMojo
*/
private String licenseFile;
/**
* Whether the Clover instrumentation should use the Clover <code>jdk14</code> or
* <code>jdk15<code> flags to parse sources.
*
* @parameter
*/
protected String jdk;
/**
* Registers the license file for Clover runtime by setting the
* <code>clover.license.path</code> system property. If the <code>licenseFile</code>

View File

@ -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

View File

@ -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]);
}
}