- Upgrade to Clover 1.3.9

- Added CloverLogMojo (clover:log goal) to display the content of the clover database


git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@226483 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Vincent Massol 2005-07-30 07:50:03 +00:00
parent 475b0eb767
commit 1dc404f9ca
4 changed files with 76 additions and 20 deletions

View File

@ -47,7 +47,7 @@
<dependency>
<groupId>clover</groupId>
<artifactId>clover</artifactId>
<version>1.3.8</version>
<version>1.3.9</version>
</dependency>
<dependency>
<groupId>ant</groupId>

View File

@ -16,6 +16,8 @@
package org.apache.maven.plugin.clover;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.taskdefs.Taskdef;
public abstract class AbstractCloverMojo extends AbstractMojo
{
@ -40,4 +42,17 @@ public abstract class AbstractCloverMojo extends AbstractMojo
System.setProperty("clover.license.path", licenseToUse);
}
protected Project registerCloverAntTasks()
{
Project antProject = new Project();
antProject.init();
Taskdef taskdef = (Taskdef) antProject.createTask( "taskdef" );
taskdef.setResource( "clovertasks" );
taskdef.execute();
return antProject;
}
}

View File

@ -51,24 +51,7 @@ public class CloverCheckMojo
public void execute()
throws MojoExecutionException
{
registerLicenseFile();
checkCoverage();
}
private void registerCloverAntTasks( Project antProject )
{
Taskdef taskdef = (Taskdef) antProject.createTask( "taskdef" );
taskdef.setResource( "clovertasks" );
taskdef.execute();
}
private void checkCoverage()
throws MojoExecutionException
{
Project antProject = new Project();
antProject.init();
registerCloverAntTasks( antProject );
Project antProject = registerCloverAntTasks();
getLog().info( "Checking for coverage of " + targetPercentage + "%" );
@ -76,13 +59,14 @@ public class CloverCheckMojo
cloverPassTask.setInitString( this.cloverDatabase );
cloverPassTask.setHaltOnFailure( true );
cloverPassTask.setTarget( new Percentage( this.targetPercentage ) );
cloverPassTask.setFailureProperty("clovercheckproperty");
try
{
cloverPassTask.execute();
}
catch ( BuildException e )
{
// TODO: change to a failure, hopefully get a decent Java API out of them so we can get a better exception
getLog().error( antProject.getProperty("clovercheckproperty") );
throw new MojoExecutionException( e.getMessage(), e );
}
}

View File

@ -0,0 +1,57 @@
package org.apache.maven.plugin.clover;
/*
* Copyright 2001-2005 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import com.cenqua.clover.cfg.Percentage;
import com.cenqua.clover.tasks.CloverPassTask;
import com.cenqua.clover.tasks.CloverLogTask;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.taskdefs.Taskdef;
import com_cenqua_clover.CloverVersionInfo;
/**
* Provides information on the current Clover database.
*
* @author <a href="mailto:vmassol@apache.org">Vincent Massol</a>
* @version $Id$
* @goal log
*
*/
public class CloverLogMojo
extends AbstractCloverMojo
{
/**
* @parameter expression="${project.build.directory}/clover/clover.db"
* @required
*/
protected String cloverDatabase;
public void execute()
throws MojoExecutionException
{
Project antProject = registerCloverAntTasks();
CloverLogTask cloverLogTask = (CloverLogTask) antProject.createTask( "clover-log" );
cloverLogTask.setInitString( this.cloverDatabase );
cloverLogTask.setOutputProperty( "cloverlogproperty" );
cloverLogTask.execute();
getLog().info( antProject.getProperty( "cloverlogproperty" ) );
}
}