
scala_maven.ScalaTestCompileMojo Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of scala-maven-plugin Show documentation
Show all versions of scala-maven-plugin Show documentation
The scala-maven-plugin (previously maven-scala-plugin) is used for compiling/testing/running/documenting scala code of any maven project.
package scala_maven;
import java.io.File;
import java.util.List;
import org.apache.maven.model.Dependency;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
/**
* Compile Scala test source into test-classes. Corresponds roughly to testCompile
* in maven-compiler-plugin
*
* @phase test-compile
* @goal testCompile
* @requiresDependencyResolution test
* @threadSafe
*/
public class ScalaTestCompileMojo extends ScalaCompilerSupport {
/**
* Set this to 'true' to bypass unit tests entirely.
* Its use is NOT RECOMMENDED, but quite convenient on occasion.
*
* @parameter property="maven.test.skip"
*/
protected boolean skip;
/**
* The directory in which to place test compilation output
*
* @parameter default-value="${project.build.testOutputDirectory}
*/
protected File testOutputDir;
/**
* The directory in which to find test scala source code
*
* @parameter default-value="${project.build.testSourceDirectory}/../scala"
*/
protected File testSourceDir;
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
if (skip) {
return;
}
super.execute();
}
/**
* Analysis cache file for incremental recompilation.
*
* @parameter property="testAnalysisCacheFile" default-value="${project.build.directory}/analysis/test-compile"
*/
protected File testAnalysisCacheFile;
@Override
protected List getClasspathElements() throws Exception {
List back = project.getTestClasspathElements();
back.remove(project.getBuild().getTestOutputDirectory());
//back.add(getOutputDir().getAbsolutePath());
return back;
}
@Override
protected List getDependencies() {
return project.getTestDependencies();
}
@Override
protected File getOutputDir() throws Exception {
return testOutputDir.getAbsoluteFile();
}
@Override
protected List getSourceDirectories() throws Exception {
List sources = project.getTestCompileSourceRoots();
String scalaSourceDir = testSourceDir.getAbsolutePath();
if(!sources.contains(scalaSourceDir)) {
sources.add(scalaSourceDir);
}
return normalize(sources);
}
@Override
protected File getAnalysisCacheFile() throws Exception {
return testAnalysisCacheFile.getAbsoluteFile();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy