com.atlassian.maven.plugin.clover.internal.ConfigUtil Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of maven-clover2-plugin Show documentation
Show all versions of maven-clover2-plugin Show documentation
Maven plugin for Clover.
MIGRATION NOTICE: Since next major Clover release this plugin will be renamed to
com.atlassian.maven.plugins:clover-maven-plugin. Thus, goals will also be renamed, e.g.
'clover2:setup' will become 'clover:setup'.
The newest version!
package com.atlassian.maven.plugin.clover.internal;
import org.apache.maven.project.MavenProject;
import java.io.File;
import com.atlassian.clover.CloverNames;
/**
* A helper class to manage configuration of the maven-clover2-plugin
*/
public class ConfigUtil {
final CloverConfiguration config;
public ConfigUtil(final CloverConfiguration config) {
this.config = config;
}
public String resolveCloverDatabase() {
if (config.getCloverDatabase() != null) {// allow cloverDatabase to be overwritten.
return config.getCloverDatabase();
}
final MavenProject project = resolveMavenProject();
return project.getBuild().getDirectory() + "/clover/clover.db";
}
/**
* If a singleCloverDatabase is configured, return the first project in the reactor.
* Otherwise, return the current project.
* @return the project to use
*/
public MavenProject resolveMavenProject() {
// if a singleCloverDatabase should be used, use the execution root build dir
return config.isSingleCloverDatabase() ? config.getReactorProjects().get(0) : config.getProject();
}
public File resolveSnapshotFile(final File snapshot) {
if (snapshot != null) {
return snapshot;
}
// unless specified, save the snapshot file to the basedir
final MavenProject project = resolveMavenProject();
final File baseCloverDir = new File(project.getBasedir(), ".clover");
baseCloverDir.mkdir();
return new File(baseCloverDir, "clover" + CloverNames.SNAPSHOT_SUFFIX);
}
}