com.atlassian.maven.plugin.clover.internal
Class AbstractCloverMojo

java.lang.Object
  extended by org.apache.maven.plugin.AbstractMojo
      extended by com.atlassian.maven.plugin.clover.internal.AbstractCloverMojo
All Implemented Interfaces:
CloverConfiguration, org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo
Direct Known Subclasses:
AbstractCloverInstrumentMojo, CloverAggregateMojo, CloverCheckMojo, CloverCleanMojo, CloverLogMojo, CloverMergeMojo, CloverOptimizerMojo, CloverSaveHistoryMojo, CloverSnapshotMojo

public abstract class AbstractCloverMojo
extends org.apache.maven.plugin.AbstractMojo
implements CloverConfiguration

Common code for all Clover plugin build Mojos.

Author:
Vincent Massol, Nick Pellow

Field Summary
protected  String cloverOutputDirectory
          The directory where the Clover plugin will put all the files it generates during the build process.
protected  boolean debug
          If you wish to enable debug level logging in just the Clover plugin, set this to true.
protected  String license
          The full Clover license String to use.
protected  String licenseLocation
          A Clover license file to be used by the plugin.
protected  boolean skip
          A flag to indicate not to run clover for this execution.
protected  File snapshot
          The location to store the clover snapshot file.
 
Fields inherited from interface org.apache.maven.plugin.Mojo
ROLE
 
Constructor Summary
AbstractCloverMojo()
           
 
Method Summary
protected  boolean areCloverDatabasesAvailable()
          Check if a Clover database exists (either a single module Clover database or an aggregated one).
 void execute()
          
 String getCloverDatabase()
           
protected  String getCloverMergeDatabase()
           
protected  List<org.apache.maven.project.MavenProject> getDescendentModuleProjects(org.apache.maven.project.MavenProject project)
          returns all the projects that are in the reactor build as direct or indirect modules of the specified project.
 int getFlushInterval()
           
protected  List<org.apache.maven.project.MavenProject> getModuleProjects(org.apache.maven.project.MavenProject project, int levels)
          Returns all the projects that are modules, or modules of modules, of the specified project found within the reactor.
 org.apache.maven.project.MavenProject getProject()
           
 List<org.apache.maven.project.MavenProject> getReactorProjects()
           
static File getResourceAsFile(org.apache.maven.project.MavenProject project, org.codehaus.plexus.resource.ResourceManager resourceManager, String resourceLocation, org.apache.maven.plugin.logging.Log logger, ClassLoader classloader)
           
 org.codehaus.plexus.resource.ResourceManager getResourceManager()
           
 boolean getWaitForFlush()
           
protected  boolean isLastProjectInReactor()
           
protected  boolean isModuleOfProject(org.apache.maven.project.MavenProject parentProject, org.apache.maven.project.MavenProject potentialModule)
          Returns true if the supplied potentialModule project is a module of the specified parentProject.
 boolean isSingleCloverDatabase()
           
static void registerCloverAntTasks(org.apache.tools.ant.Project antProject, org.apache.maven.plugin.logging.Log log)
          Register the Clover Ant tasks against a fake Ant {Project} object so that we can the tasks later on.
protected  void registerLicenseFile()
           
static void registerLicenseFile(org.apache.maven.project.MavenProject project, org.codehaus.plexus.resource.ResourceManager resourceManager, String licenseLocation, org.apache.maven.plugin.logging.Log logger, ClassLoader classloader, String licenseCert)
          Registers the license file for Clover runtime by setting the clover.license.path system property.
 String resolveCloverDatabase()
           
 void setLicense(String license)
           
 void setLicenseLocation(String licenseLocation)
           
 void setProject(org.apache.maven.project.MavenProject project)
           
 void setResourceManager(org.codehaus.plexus.resource.ResourceManager resourceManager)
           
static void waitForFlush(boolean waitForFlush, int flushInterval)
          Wait 2*'flush interval' milliseconds to ensure that the coverage data have been flushed to the Clover database.
 
Methods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.atlassian.maven.plugin.clover.internal.CloverConfiguration
getLog
 

Field Detail

cloverOutputDirectory

protected String cloverOutputDirectory
The directory where the Clover plugin will put all the files it generates during the build process. For example the Clover plugin will put instrumented sources somewhere inside this directory.


snapshot

protected File snapshot
The location to store the clover snapshot file. This file needs to persist between builds to enable Clover's build optimization feature. If not specified, the snapshot will be stored next to the cloverDatabase.


licenseLocation

protected String licenseLocation
A Clover license file to be used by the plugin. The plugin tries to resolve this parameter first as a resource, then as a URL, and then as a file location on the filesystem. A trial Clover license can be generated here.

See Also:
license

license

protected String license
The full Clover license String to use. If supplied, this certificate will be used over licenseLocation. NB. newline chars must be preserved. A trial Clover license can be generated here.

See Also:
licenseLocation

skip

protected boolean skip
A flag to indicate not to run clover for this execution. If set to true, Clover will not be run.


debug

protected boolean debug
If you wish to enable debug level logging in just the Clover plugin, set this to true. This is useful for integrating Clover into the build.

Constructor Detail

AbstractCloverMojo

public AbstractCloverMojo()
Method Detail

execute

public void execute()
             throws org.apache.maven.plugin.MojoExecutionException

Specified by:
execute in interface org.apache.maven.plugin.Mojo
Throws:
org.apache.maven.plugin.MojoExecutionException
See Also:
Mojo.execute()

setResourceManager

public void setResourceManager(org.codehaus.plexus.resource.ResourceManager resourceManager)

getResourceManager

public org.codehaus.plexus.resource.ResourceManager getResourceManager()

registerLicenseFile

protected void registerLicenseFile()
                            throws org.apache.maven.plugin.MojoExecutionException
Throws:
org.apache.maven.plugin.MojoExecutionException

registerLicenseFile

public static void registerLicenseFile(org.apache.maven.project.MavenProject project,
                                       org.codehaus.plexus.resource.ResourceManager resourceManager,
                                       String licenseLocation,
                                       org.apache.maven.plugin.logging.Log logger,
                                       ClassLoader classloader,
                                       String licenseCert)
                                throws org.apache.maven.plugin.MojoExecutionException
Registers the license file for Clover runtime by setting the clover.license.path system property. If the user has configured the licenseLocation parameter the plugin tries to resolve it first as a resource, then as a URL, and then as a file location on the filesystem. If the licenseLocation parameter has not been defined by the user we look up a default Clover license in the classpath in /clover.license. Note: We're defining this method as static because it is also required in the report mojo and reporting mojos and main mojos cannot share anything right now. See http://jira.codehaus.org/browse/MNG-1886.

Throws:
org.apache.maven.plugin.MojoExecutionException - when the license file cannot be found

getResourceAsFile

public static File getResourceAsFile(org.apache.maven.project.MavenProject project,
                                     org.codehaus.plexus.resource.ResourceManager resourceManager,
                                     String resourceLocation,
                                     org.apache.maven.plugin.logging.Log logger,
                                     ClassLoader classloader)
                              throws org.apache.maven.plugin.MojoExecutionException
Throws:
org.apache.maven.plugin.MojoExecutionException

registerCloverAntTasks

public static void registerCloverAntTasks(org.apache.tools.ant.Project antProject,
                                          org.apache.maven.plugin.logging.Log log)
Register the Clover Ant tasks against a fake Ant {Project} object so that we can the tasks later on. This is the Java equivalent of the taskdef call that you would need in your Ant build.xml file if you wanted to use the Clover Ant tasks from Ant. Note: We're defining this method as static because it is also required in the report mojo and reporting mojos and main mojos cannot share anything right now. See http://jira.codehaus.org/browse/MNG-1886.


waitForFlush

public static void waitForFlush(boolean waitForFlush,
                                int flushInterval)
Wait 2*'flush interval' milliseconds to ensure that the coverage data have been flushed to the Clover database. TODO: This method should not be static but we need it static here because we cannot share code between non report mojos and main build mojos. See http://jira.codehaus.org/browse/MNG-1886


areCloverDatabasesAvailable

protected boolean areCloverDatabasesAvailable()
Check if a Clover database exists (either a single module Clover database or an aggregated one).

Returns:
true if a Clover database exists.

getProject

public org.apache.maven.project.MavenProject getProject()
Specified by:
getProject in interface CloverConfiguration

getWaitForFlush

public boolean getWaitForFlush()

getCloverDatabase

public String getCloverDatabase()
Specified by:
getCloverDatabase in interface CloverConfiguration

resolveCloverDatabase

public String resolveCloverDatabase()
Specified by:
resolveCloverDatabase in interface CloverConfiguration

getCloverMergeDatabase

protected String getCloverMergeDatabase()

getFlushInterval

public int getFlushInterval()

setProject

public void setProject(org.apache.maven.project.MavenProject project)

setLicenseLocation

public void setLicenseLocation(String licenseLocation)

setLicense

public void setLicense(String license)

getReactorProjects

public List<org.apache.maven.project.MavenProject> getReactorProjects()
Specified by:
getReactorProjects in interface CloverConfiguration

isSingleCloverDatabase

public boolean isSingleCloverDatabase()
Specified by:
isSingleCloverDatabase in interface CloverConfiguration

isLastProjectInReactor

protected boolean isLastProjectInReactor()

isModuleOfProject

protected boolean isModuleOfProject(org.apache.maven.project.MavenProject parentProject,
                                    org.apache.maven.project.MavenProject potentialModule)
Returns true if the supplied potentialModule project is a module of the specified parentProject.

Parameters:
parentProject - the parent project.
potentialModule - the potential moduleproject.
Returns:
true if the potentialModule is indeed a module of the specified parent project.

getModuleProjects

protected List<org.apache.maven.project.MavenProject> getModuleProjects(org.apache.maven.project.MavenProject project,
                                                                        int levels)
Returns all the projects that are modules, or modules of modules, of the specified project found within the reactor. The searchLevel parameter controls how many descendent levels of modules are returned. With a searchLevels equals to 1, only the immediate modules of the specified project are returned. A searchLevel equals to 2 returns those module's modules as well. A searchLevel equals to -1 returns the entire module hierarchy beneath the specified project. Note that this is simply the equivalent to the entire reactor if the specified project is the root execution project.

Parameters:
project - the project to search under
levels - the number of descendent levels to return (List<MavenProject>)
Returns:
the list of module projects.

getDescendentModuleProjects

protected List<org.apache.maven.project.MavenProject> getDescendentModuleProjects(org.apache.maven.project.MavenProject project)
returns all the projects that are in the reactor build as direct or indirect modules of the specified project.

Parameters:
project - the project to search beneath
Returns:
the list of modules that are direct or indirect module descendents (List<MavenProject>) of the specified project


Copyright © 2015 Atlassian Pty Ltd. All Rights Reserved.