Search in sources :

Example 1 with ITest

use of com.github.maven_nar.ITest in project m2e-nar by maven-nar.

the class NarExecutionBuilder method build.

public NarExecution build(final String buildType) throws CoreException {
    try {
        NarExecution settings = new NarExecution(mojoExecution);
        settings.setSkip(narCompileMojo.isSkip());
        settings.setOS(narCompileMojo.getOS());
        settings.setLinkerName(narCompileMojo.getLinker().getName());
        List<NarBuildArtifact> artifactSettings = settings.getArtifactSettings();
        if (NarExecution.MAIN.equals(buildType)) {
            List<?> libraries = narCompileMojo.getLibraries();
            for (Iterator<?> iter = libraries.iterator(); iter.hasNext(); ) {
                ILibrary library = (ILibrary) iter.next();
                NarBuildArtifact buildArtifact = buildArtifactSettings(library.getType(), buildType, library.linkCPP(), null);
                buildArtifact.setArtifactName(narCompileMojo.getOutput(library.getType()));
                buildArtifact.setConfigName(CdtUtils.getConfigName(mojoExecution, buildArtifact));
                artifactSettings.add(buildArtifact);
            }
        } else if (NarExecution.TEST.equals(buildType)) {
            List<?> tests = narCompileMojo.getTests();
            for (Iterator<?> iter = tests.iterator(); iter.hasNext(); ) {
                ITest test = (ITest) iter.next();
                NarBuildArtifact buildArtifact = buildArtifactSettings(NarBuildArtifact.EXECUTABLE, buildType, true, test);
                buildArtifact.setArtifactName(test.getName());
                buildArtifact.setConfigName(CdtUtils.getTestConfigName(mojoExecution, buildArtifact));
                artifactSettings.add(buildArtifact);
            }
        }
        return settings;
    } catch (MojoFailureException e) {
        throw new CoreException(new Status(IStatus.ERROR, MavenNarPlugin.PLUGIN_ID, "Mojo failure", e));
    } catch (MojoExecutionException e) {
        throw new CoreException(new Status(IStatus.ERROR, MavenNarPlugin.PLUGIN_ID, "Mojo execution failed", e));
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) ILibrary(com.github.maven_nar.ILibrary) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) MojoFailureException(org.apache.maven.plugin.MojoFailureException) NarBuildArtifact(com.github.sdedwards.m2e_nar.internal.model.NarBuildArtifact) CoreException(org.eclipse.core.runtime.CoreException) ITest(com.github.maven_nar.ITest) Iterator(java.util.Iterator) List(java.util.List) NarExecution(com.github.sdedwards.m2e_nar.internal.model.NarExecution)

Aggregations

ILibrary (com.github.maven_nar.ILibrary)1 ITest (com.github.maven_nar.ITest)1 NarBuildArtifact (com.github.sdedwards.m2e_nar.internal.model.NarBuildArtifact)1 NarExecution (com.github.sdedwards.m2e_nar.internal.model.NarExecution)1 Iterator (java.util.Iterator)1 List (java.util.List)1 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)1 MojoFailureException (org.apache.maven.plugin.MojoFailureException)1 CoreException (org.eclipse.core.runtime.CoreException)1 IStatus (org.eclipse.core.runtime.IStatus)1 Status (org.eclipse.core.runtime.Status)1