Search in sources :

Example 6 with SystemStreamLog

use of org.apache.maven.plugin.logging.SystemStreamLog 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"));
}
Also used : SystemStreamLog(org.apache.maven.plugin.logging.SystemStreamLog) MavenProject(org.apache.maven.project.MavenProject) ArrayList(java.util.ArrayList) AbstractOsgiCompilerMojo(org.eclipse.tycho.compiler.AbstractOsgiCompilerMojo) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) File(java.io.File) CompilationFailureException(copied.org.apache.maven.plugin.CompilationFailureException)

Example 7 with SystemStreamLog

use of org.apache.maven.plugin.logging.SystemStreamLog 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"));
}
Also used : SystemStreamLog(org.apache.maven.plugin.logging.SystemStreamLog) MavenProject(org.apache.maven.project.MavenProject) ArrayList(java.util.ArrayList) AbstractOsgiCompilerMojo(org.eclipse.tycho.compiler.AbstractOsgiCompilerMojo) File(java.io.File)

Example 8 with SystemStreamLog

use of org.apache.maven.plugin.logging.SystemStreamLog 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());
}
Also used : SystemStreamLog(org.apache.maven.plugin.logging.SystemStreamLog) MavenProject(org.apache.maven.project.MavenProject) ArrayList(java.util.ArrayList) AbstractOsgiCompilerMojo(org.eclipse.tycho.compiler.AbstractOsgiCompilerMojo) File(java.io.File)

Example 9 with SystemStreamLog

use of org.apache.maven.plugin.logging.SystemStreamLog in project tycho by eclipse.

the class OsgiCompilerTest method testUseProjectSettingsSetToTrue.

public void testUseProjectSettingsSetToTrue() throws Exception {
    // the code in the project does use boxing and the settings file
    // turns on warning for auto boxing so we expect here a warning
    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.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("is boxed"));
}
Also used : SystemStreamLog(org.apache.maven.plugin.logging.SystemStreamLog) MavenProject(org.apache.maven.project.MavenProject) ArrayList(java.util.ArrayList) AbstractOsgiCompilerMojo(org.eclipse.tycho.compiler.AbstractOsgiCompilerMojo) File(java.io.File)

Example 10 with SystemStreamLog

use of org.apache.maven.plugin.logging.SystemStreamLog in project camel by apache.

the class CamelSalesforceMojoIntegrationTest method createMojo.

protected CamelSalesforceMojo createMojo() throws IOException {
    CamelSalesforceMojo mojo = new CamelSalesforceMojo();
    mojo.setLog(new SystemStreamLog());
    // set login properties
    setLoginProperties(mojo);
    // set defaults
    mojo.version = System.getProperty("apiVersion", SalesforceEndpointConfig.DEFAULT_VERSION);
    mojo.loginUrl = System.getProperty("loginUrl", SalesforceLoginConfig.DEFAULT_LOGIN_URL);
    mojo.outputDirectory = new File("target/generated-sources/camel-salesforce");
    mojo.packageName = "org.apache.camel.salesforce.dto";
    // set code generation properties
    mojo.includePattern = "(.*__c)|(PushTopic)|(Document)|(Account)";
    // remove generated code directory
    if (mojo.outputDirectory.exists()) {
        // remove old files
        for (File file : mojo.outputDirectory.listFiles()) {
            file.delete();
        }
        mojo.outputDirectory.delete();
    }
    return mojo;
}
Also used : SystemStreamLog(org.apache.maven.plugin.logging.SystemStreamLog) File(java.io.File)

Aggregations

SystemStreamLog (org.apache.maven.plugin.logging.SystemStreamLog)10 File (java.io.File)6 ArrayList (java.util.ArrayList)5 MavenProject (org.apache.maven.project.MavenProject)5 AbstractOsgiCompilerMojo (org.eclipse.tycho.compiler.AbstractOsgiCompilerMojo)5 AnsiLogger (io.fabric8.maven.docker.util.AnsiLogger)3 CompilationFailureException (copied.org.apache.maven.plugin.CompilationFailureException)2 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)2 Test (org.junit.Test)2 DockerMachine (io.fabric8.maven.docker.access.DockerMachine)1 BuildImageConfiguration (io.fabric8.maven.docker.config.BuildImageConfiguration)1 DockerMachineConfiguration (io.fabric8.maven.docker.config.DockerMachineConfiguration)1 Expectations (mockit.Expectations)1 JqlQueryBuilder (org.apache.maven.plugins.jira.JqlQueryBuilder)1 Before (org.junit.Before)1