use of org.apache.maven.plugin.compiler.stubs.DebugEnabledLog in project maven-plugins by apache.
the class CompilerMojoTestCase method getCompilerMojo.
private CompilerMojo getCompilerMojo(String pomXml) throws Exception {
File testPom = new File(getBasedir(), pomXml);
CompilerMojo mojo = (CompilerMojo) lookupMojo("compile", testPom);
setVariableValueToObject(mojo, "log", new DebugEnabledLog());
setVariableValueToObject(mojo, "projectArtifact", new ArtifactStub());
setVariableValueToObject(mojo, "compilePath", Collections.EMPTY_LIST);
setVariableValueToObject(mojo, "session", getMockMavenSession());
setVariableValueToObject(mojo, "project", getMockMavenProject());
setVariableValueToObject(mojo, "mojoExecution", getMockMojoExecution());
setVariableValueToObject(mojo, "source", source);
setVariableValueToObject(mojo, "target", target);
return mojo;
}
use of org.apache.maven.plugin.compiler.stubs.DebugEnabledLog in project maven-plugins by apache.
the class CompilerMojoTestCase method getTestCompilerMojo.
private TestCompilerMojo getTestCompilerMojo(CompilerMojo compilerMojo, String pomXml) throws Exception {
File testPom = new File(getBasedir(), pomXml);
TestCompilerMojo mojo = (TestCompilerMojo) lookupMojo("testCompile", testPom);
setVariableValueToObject(mojo, "log", new DebugEnabledLog());
File buildDir = (File) getVariableValueFromObject(compilerMojo, "buildDirectory");
File testClassesDir = new File(buildDir, "test-classes");
setVariableValueToObject(mojo, "outputDirectory", testClassesDir);
List<String> testClasspathList = new ArrayList<String>();
Artifact junitArtifact = mock(Artifact.class);
ArtifactHandler handler = mock(ArtifactHandler.class);
when(handler.isAddedToClasspath()).thenReturn(true);
when(junitArtifact.getArtifactHandler()).thenReturn(handler);
File artifactFile;
String localRepository = System.getProperty("localRepository");
if (localRepository != null) {
artifactFile = new File(localRepository, "junit/junit/3.8.1/junit-3.8.1.jar");
} else {
// for IDE
String junitURI = org.junit.Test.class.getResource("Test.class").toURI().toString();
junitURI = junitURI.substring("jar:".length(), junitURI.indexOf('!'));
artifactFile = new File(URI.create(junitURI));
}
when(junitArtifact.getFile()).thenReturn(artifactFile);
testClasspathList.add(artifactFile.getAbsolutePath());
testClasspathList.add(compilerMojo.getOutputDirectory().getPath());
String testSourceRoot = testPom.getParent() + "/src/test/java";
setVariableValueToObject(mojo, "compileSourceRoots", Collections.singletonList(testSourceRoot));
MavenProject project = getMockMavenProject();
project.setArtifacts(Collections.singleton(junitArtifact));
project.getBuild().setOutputDirectory(new File(buildDir, "classes").getAbsolutePath());
setVariableValueToObject(mojo, "project", project);
setVariableValueToObject(mojo, "compilePath", Collections.EMPTY_LIST);
setVariableValueToObject(mojo, "testPath", testClasspathList);
setVariableValueToObject(mojo, "session", getMockMavenSession());
setVariableValueToObject(mojo, "mojoExecution", getMockMojoExecution());
setVariableValueToObject(mojo, "source", source);
setVariableValueToObject(mojo, "target", target);
return mojo;
}
Aggregations