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 2005/12/21 19:58:02 UTC
svn commit: r358345 - in
/maven/plugins/trunk/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover:
CloverInstrumentMojo.java CloverReportMojo.java
Author: vmassol
Date: Wed Dec 21 10:57:58 2005
New Revision: 358345
URL: http://svn.apache.org/viewcvs?rev=358345&view=rev
Log:
MCLOVER-13: Check artifact language (do not execute clover on non-java projects)
Modified:
maven/plugins/trunk/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/CloverInstrumentMojo.java
maven/plugins/trunk/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/CloverReportMojo.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=358345&r1=358344&r2=358345&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 Wed Dec 21 10:57:58 2005
@@ -19,6 +19,7 @@
import com.cenqua.clover.CloverInstr;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.factory.ArtifactFactory;
+import org.apache.maven.artifact.handler.ArtifactHandler;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.project.MavenProject;
@@ -85,9 +86,7 @@
public void execute()
throws MojoExecutionException
{
- // Do not perform anything if there are no source files
- File srcDir = new File(this.project.getBuild().getSourceDirectory());
- if (srcDir.exists())
+ if ( shouldExecute() )
{
init();
registerLicenseFile();
@@ -96,12 +95,30 @@
addCloverDependencyToCompileClasspath();
redirectOutputDirectories();
}
- else
+ }
+
+ private boolean shouldExecute()
+ {
+ boolean shouldExecute = true;
+
+ // Only execute reports for java projects
+ ArtifactHandler artifactHandler = this.project.getArtifact().getArtifactHandler();
+ File srcDir = new File(this.project.getBuild().getSourceDirectory());
+
+ if ( !"java".equals( artifactHandler.getLanguage() ) )
+ {
+ getLog().debug( "Not executing Clover as this is not a Java project." );
+ shouldExecute = false;
+ }
+ else if ( !srcDir.exists() )
{
getLog().debug("No sources found - No Clover instrumentation done");
+ shouldExecute = false;
}
- }
+ return shouldExecute;
+ }
+
private void instrumentSources() throws MojoExecutionException
{
int result = CloverInstr.mainImpl( createCliArgs() );
Modified: maven/plugins/trunk/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/CloverReportMojo.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/CloverReportMojo.java?rev=358345&r1=358344&r2=358345&view=diff
==============================================================================
--- maven/plugins/trunk/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/CloverReportMojo.java (original)
+++ maven/plugins/trunk/maven-clover-plugin/src/main/java/org/apache/maven/plugin/clover/CloverReportMojo.java Wed Dec 21 10:57:58 2005
@@ -17,6 +17,8 @@
*/
import com.cenqua.clover.reporters.html.HtmlReporter;
+
+import org.apache.maven.artifact.handler.ArtifactHandler;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.project.MavenProject;
import org.apache.maven.reporting.AbstractMavenReport;
@@ -75,6 +77,14 @@
public void executeReport( Locale locale )
throws MavenReportException
{
+ // Only execute reports for java projects
+ ArtifactHandler artifactHandler = this.project.getArtifact().getArtifactHandler();
+ if ( !"java".equals( artifactHandler.getLanguage() ) )
+ {
+ getLog().debug( "Not generating a Clover report as this is not a Java project." );
+ return;
+ }
+
int result = HtmlReporter.mainImpl( createCliArgs() );
if ( result != 0 )
{