Search in sources :

Example 1 with StandardExecutionEnvironment

use of org.eclipse.tycho.core.ee.StandardExecutionEnvironment in project tycho by eclipse.

the class AbstractOsgiCompilerMojo method checkTargetLevelCompatibleWithManifestBREEs.

private void checkTargetLevelCompatibleWithManifestBREEs(String effectiveTargetLevel, StandardExecutionEnvironment[] manifestBREEs) throws MojoExecutionException {
    List<String> incompatibleBREEs = new ArrayList<>();
    for (StandardExecutionEnvironment ee : manifestBREEs) {
        if (!ee.isCompatibleCompilerTargetLevel(effectiveTargetLevel)) {
            incompatibleBREEs.add(ee.getProfileName() + " (assumes " + ee.getCompilerTargetLevelDefault() + ")");
        }
    }
    if (!incompatibleBREEs.isEmpty()) {
        String message = "The effective compiler target level " + effectiveTargetLevel + " is incompatible with the following OSGi execution environments: " + incompatibleBREEs + " @ " + project;
        if (strictCompilerTarget) {
            throw new MojoExecutionException(message);
        }
        getLog().warn(message);
    }
}
Also used : StandardExecutionEnvironment(org.eclipse.tycho.core.ee.StandardExecutionEnvironment) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) ArrayList(java.util.ArrayList)

Example 2 with StandardExecutionEnvironment

use of org.eclipse.tycho.core.ee.StandardExecutionEnvironment in project tycho by eclipse.

the class OsgiBundleProject method readExecutionEnvironmentConfiguration.

@Override
public void readExecutionEnvironmentConfiguration(MavenProject project, ExecutionEnvironmentConfiguration sink) {
    // read packaging-type independent configuration
    super.readExecutionEnvironmentConfiguration(project, sink);
    // only in plugin projects, the profile may also be ...
    // ... specified in build.properties (for PDE compatibility)
    String pdeProfile = getEclipsePluginProject(DefaultReactorProject.adapt(project)).getBuildProperties().getJreCompilationProfile();
    if (pdeProfile != null) {
        sink.setProfileConfiguration(pdeProfile.trim(), "build.properties");
    } else {
        // ... derived from BREE in bundle manifest
        StandardExecutionEnvironment[] manifestBREEs = getManifest(project).getExecutionEnvironments();
        if (manifestBREEs.length > 0) {
            TargetPlatformConfiguration tpConfiguration = TychoProjectUtils.getTargetPlatformConfiguration(project);
            switch(tpConfiguration.getBREEHeaderSelectionPolicy()) {
                case first:
                    sink.setProfileConfiguration(manifestBREEs[0].getProfileName(), "Bundle-RequiredExecutionEnvironment (first entry)");
                    break;
                case minimal:
                    ExecutionEnvironment manifestMinimalEE = Collections.min(Arrays.asList(manifestBREEs));
                    sink.setProfileConfiguration(manifestMinimalEE.getProfileName(), "Bundle-RequiredExecutionEnvironment (minimal entry)");
            }
        }
    }
}
Also used : StandardExecutionEnvironment(org.eclipse.tycho.core.ee.StandardExecutionEnvironment) StandardExecutionEnvironment(org.eclipse.tycho.core.ee.StandardExecutionEnvironment) ExecutionEnvironment(org.eclipse.tycho.core.ee.shared.ExecutionEnvironment) TargetPlatformConfiguration(org.eclipse.tycho.core.TargetPlatformConfiguration)

Example 3 with StandardExecutionEnvironment

use of org.eclipse.tycho.core.ee.StandardExecutionEnvironment in project tycho by eclipse.

the class GeneratePomsMojo method addPluginImpl.

private void addPluginImpl(Set<File> result, File basedir) throws MojoExecutionException {
    if (result.add(basedir)) {
        try {
            StandardExecutionEnvironment ee = ExecutionEnvironmentUtils.getExecutionEnvironment(executionEnvironment);
            State state = resolver.newResolvedState(basedir, ee, platform);
            BundleDescription bundle = state.getBundleByLocation(basedir.getAbsolutePath());
            if (bundle != null) {
                for (DependencyComputer.DependencyEntry entry : dependencyComputer.computeDependencies(state.getStateHelper(), bundle)) {
                    BundleDescription supplier = entry.desc;
                    File suppliedDir = new File(supplier.getLocation());
                    if (supplier.getHost() == null && isModuleDir(suppliedDir)) {
                        addPlugin(result, suppliedDir.getName());
                    }
                }
            } else {
                getLog().warn("Not an OSGi bundle " + basedir.toString());
            }
        } catch (BundleException e) {
            warnNoBundleDependencies(e);
        }
    }
}
Also used : StandardExecutionEnvironment(org.eclipse.tycho.core.ee.StandardExecutionEnvironment) State(org.eclipse.osgi.service.resolver.State) BundleDescription(org.eclipse.osgi.service.resolver.BundleDescription) DependencyComputer(org.eclipse.tycho.core.osgitools.DependencyComputer) BundleException(org.osgi.framework.BundleException) File(java.io.File)

Example 4 with StandardExecutionEnvironment

use of org.eclipse.tycho.core.ee.StandardExecutionEnvironment in project tycho by eclipse.

the class AbstractOsgiCompilerMojo method execute.

@Override
public void execute() throws MojoExecutionException, MojoFailureException {
    StandardExecutionEnvironment[] manifestBREEs = bundleReader.loadManifest(project.getBasedir()).getExecutionEnvironments();
    getLog().debug("Manifest BREEs: " + Arrays.toString(manifestBREEs));
    getLog().debug("Effective EE: " + getTargetExecutionEnvironment());
    String effectiveTargetLevel = getTargetLevel();
    getLog().debug("Effective source/target: " + getSourceLevel() + "/" + effectiveTargetLevel);
    checkTargetLevelCompatibleWithManifestBREEs(effectiveTargetLevel, manifestBREEs);
    for (BuildOutputJar jar : getEclipsePluginProject().getOutputJars()) {
        this.outputJar = jar;
        this.outputJar.getOutputDirectory().mkdirs();
        super.execute();
        doCopyResources();
    }
    // this does not include classes from nested jars
    BuildOutputJar dotOutputJar = getEclipsePluginProject().getDotOutputJar();
    if (dotOutputJar != null) {
        project.getArtifact().setFile(dotOutputJar.getOutputDirectory());
    }
}
Also used : StandardExecutionEnvironment(org.eclipse.tycho.core.ee.StandardExecutionEnvironment) BuildOutputJar(org.eclipse.tycho.core.osgitools.project.BuildOutputJar)

Aggregations

StandardExecutionEnvironment (org.eclipse.tycho.core.ee.StandardExecutionEnvironment)4 File (java.io.File)1 ArrayList (java.util.ArrayList)1 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)1 BundleDescription (org.eclipse.osgi.service.resolver.BundleDescription)1 State (org.eclipse.osgi.service.resolver.State)1 TargetPlatformConfiguration (org.eclipse.tycho.core.TargetPlatformConfiguration)1 ExecutionEnvironment (org.eclipse.tycho.core.ee.shared.ExecutionEnvironment)1 DependencyComputer (org.eclipse.tycho.core.osgitools.DependencyComputer)1 BuildOutputJar (org.eclipse.tycho.core.osgitools.project.BuildOutputJar)1 BundleException (org.osgi.framework.BundleException)1