org.eclipse.xtend.maven.XtendTestCompile Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of report Show documentation
Show all versions of report Show documentation
The report generator for the Jnario testing language.
The newest version!
package org.eclipse.xtend.maven;
import static com.google.common.collect.Iterables.filter;
import static com.google.common.collect.Lists.newArrayList;
import static org.eclipse.xtext.util.Strings.concat;
import java.io.File;
import java.util.List;
import java.util.Set;
import org.apache.maven.artifact.DependencyResolutionRequiredException;
import org.apache.maven.plugin.MojoExecutionException;
import org.eclipse.emf.common.util.WrappedException;
import org.eclipse.xtend.core.compiler.batch.XtendBatchCompiler;
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
/**
* Goal which compiles Xtend2 test sources.
*
* @author Michael Clay - Initial contribution and API
*/
public class XtendTestCompile extends AbstractXtendCompilerMojo {
/**
* Location of the generated test files.
*
* @parameter default-value="${basedir}/src/test/generated-sources/xtend"
* @required
*/
private String testOutputDirectory;
/**
* Location of the temporary compiler directory.
*
* @parameter default-value="${project.build.directory}/xtend-test"
* @required
*/
private String testTempDirectory;
@Override
protected void internalExecute() throws MojoExecutionException {
final String defaultValue = project.getBasedir() + "/src/test/generated-sources/xtend";
getLog().debug("Output directory '" + testOutputDirectory + "'");
getLog().debug("Default directory '" + defaultValue + "'");
if (defaultValue.equals(testOutputDirectory)) {
readXtendEclipseSetting(project.getBuild().getTestSourceDirectory(), new Procedure1() {
public void apply(String xtendOutputDir) {
testOutputDirectory = xtendOutputDir;
getLog().info("Using Xtend output directory '" + testOutputDirectory + "'");
}
});
}
testOutputDirectory = resolveToBaseDir(testOutputDirectory);
compileTestSources(xtendBatchCompilerProvider.get());
}
protected void compileTestSources(XtendBatchCompiler xtend2BatchCompiler) throws MojoExecutionException {
List testCompileSourceRoots = Lists.newArrayList(project.getTestCompileSourceRoots());
String testClassPath = concat(File.pathSeparator, getTestClassPath());
project.addTestCompileSourceRoot(testOutputDirectory);
compile(xtend2BatchCompiler, testClassPath, testCompileSourceRoots, testOutputDirectory);
}
@SuppressWarnings("deprecation")
protected List getTestClassPath() {
Set classPath = Sets.newLinkedHashSet();
classPath.add(project.getBuild().getTestSourceDirectory());
try {
classPath.addAll(project.getTestClasspathElements());
} catch (DependencyResolutionRequiredException e) {
throw new WrappedException(e);
}
addDependencies(classPath, project.getTestArtifacts());
return newArrayList(filter(classPath, FILE_EXISTS));
}
@Override
protected String getTempDirectory() {
return testTempDirectory;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy