use of org.eclipse.tycho.compiler.AbstractOsgiCompilerMojo in project tycho by eclipse.
the class OsgiCompilerTest method getMojo.
private AbstractOsgiCompilerMojo getMojo(List<MavenProject> projects, MavenProject project) throws Exception {
AbstractOsgiCompilerMojo mojo = (AbstractOsgiCompilerMojo) lookupMojo("compile", project.getFile());
setVariableValueToObject(mojo, "project", project);
setVariableValueToObject(mojo, "session", newMavenSession(project, projects));
// setVariableValueToObject(mojo, "fork", fork? Boolean.TRUE: Boolean.FALSE);
return mojo;
}
use of org.eclipse.tycho.compiler.AbstractOsgiCompilerMojo in project tycho by eclipse.
the class OsgiCompilerTest method testWarningAndErrorMessages.
public void testWarningAndErrorMessages() throws Exception {
File basedir = getBasedir("projects/compilermessages");
List<MavenProject> projects = getSortedProjects(basedir, null);
MavenProject project = projects.get(0);
AbstractOsgiCompilerMojo mojo = getMojo(projects, project);
final List<CharSequence> warnings = new ArrayList<>();
mojo.setLog(new SystemStreamLog() {
@Override
public void warn(CharSequence content) {
warnings.add(content);
}
});
try {
mojo.execute();
fail("compilation failure expected");
} catch (CompilationFailureException e) {
String message = e.getLongMessage();
assertThat(message, containsString("3 problems (1 error, 2 warnings)"));
// 1 error
assertThat(message, containsString("Test.java:[23"));
assertThat(message, containsString("System.foo();"));
}
// 2 warnings
List<String> expectedWarnings = asList(//
"Test.java:[19", "Test.java:[21");
assertEquals(expectedWarnings.size(), warnings.size());
for (int i = 0; i < warnings.size(); i++) {
String warning = (String) warnings.get(i);
String expectedWarning = expectedWarnings.get(i);
assertThat(warning, containsString(expectedWarning));
}
}
use of org.eclipse.tycho.compiler.AbstractOsgiCompilerMojo in project tycho by eclipse.
the class OsgiCompilerTest method testCompilerArgs.
public void testCompilerArgs() throws Exception {
File basedir = getBasedir("projects/compiler-args");
List<MavenProject> projects = getSortedProjects(basedir, null);
MavenProject project = projects.get(0);
AbstractOsgiCompilerMojo mojo = getMojo(projects, project);
final List<CharSequence> warnings = new ArrayList<>();
mojo.setLog(new SystemStreamLog() {
@Override
public void warn(CharSequence content) {
warnings.add(content);
}
});
try {
mojo.execute();
fail("compilation failure expected");
} catch (CompilationFailureException e) {
String message = e.getLongMessage();
assertThat(message, containsString("2 problems (1 error, 1 warning)"));
// 1 error
assertThat(message, containsString("unused"));
}
// 1 warning
assertThat((String) warnings.iterator().next(), containsString("is boxed"));
}
use of org.eclipse.tycho.compiler.AbstractOsgiCompilerMojo in project tycho by eclipse.
the class OsgiCompilerTest method testUseProjectSettingsSetToTrueWithMissingPrefsFile.
public void testUseProjectSettingsSetToTrueWithMissingPrefsFile() throws Exception {
File basedir = getBasedir("projects/projectSettings/p002");
List<MavenProject> projects = getSortedProjects(basedir, null);
MavenProject project = projects.get(0);
AbstractOsgiCompilerMojo mojo = getMojo(projects, project);
setVariableValueToObject(mojo, "useProjectSettings", Boolean.TRUE);
final List<CharSequence> warnings = new ArrayList<>();
mojo.setLog(new SystemStreamLog() {
@Override
public void warn(CharSequence content) {
warnings.add(content);
}
});
mojo.execute();
assertThat((String) warnings.iterator().next(), containsString("Parameter 'useProjectSettings' is set to true, but preferences file"));
}
use of org.eclipse.tycho.compiler.AbstractOsgiCompilerMojo in project tycho by eclipse.
the class OsgiCompilerTest method testUseProjectSettingsSetToFalse.
public void testUseProjectSettingsSetToFalse() throws Exception {
File basedir = getBasedir("projects/projectSettings/p001");
List<MavenProject> projects = getSortedProjects(basedir, null);
MavenProject project = projects.get(0);
AbstractOsgiCompilerMojo mojo = getMojo(projects, project);
setVariableValueToObject(mojo, "useProjectSettings", Boolean.FALSE);
final List<CharSequence> warnings = new ArrayList<>();
mojo.setLog(new SystemStreamLog() {
@Override
public void warn(CharSequence content) {
warnings.add(content);
}
});
mojo.execute();
assertTrue(warnings.isEmpty());
}
Aggregations