From d45b6a3a900512fc2ea9247c064b94e75c07ba14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20L=C3=A4ubrich?= Date: Mon, 20 Nov 2023 15:49:17 +0100 Subject: [PATCH] Support features / dir bundles / install bundle in EclipseApplication (cherry picked from commit d76d71c0f49ec009b48d0e42ddc5e01e9b413856) --- .../osgi/framework/EclipseApplication.java | 36 ++++++++++++++++++- .../framework/EclipseApplicationManager.java | 2 +- .../osgi/framework/EclipseFramework.java | 8 +++++ .../tycho/eclipsebuild/EclipseBuildMojo.java | 15 ++++++-- 4 files changed, 57 insertions(+), 4 deletions(-) diff --git a/tycho-core/src/main/java/org/eclipse/tycho/osgi/framework/EclipseApplication.java b/tycho-core/src/main/java/org/eclipse/tycho/osgi/framework/EclipseApplication.java index 6bca6000d9..56015980f1 100644 --- a/tycho-core/src/main/java/org/eclipse/tycho/osgi/framework/EclipseApplication.java +++ b/tycho-core/src/main/java/org/eclipse/tycho/osgi/framework/EclipseApplication.java @@ -27,8 +27,10 @@ import java.util.ServiceLoader; import java.util.Set; import java.util.function.Predicate; +import java.util.jar.JarFile; import org.apache.maven.project.MavenProject; +import org.codehaus.plexus.archiver.zip.ZipUnArchiver; import org.codehaus.plexus.logging.Logger; import org.eclipse.equinox.p2.metadata.IInstallableUnit; import org.eclipse.equinox.p2.metadata.IRequirement; @@ -130,12 +132,25 @@ private List resolveBundles(P2Resolver resolver) { */ public synchronized void addBundle(String bundleSymbolicName) { try { - resolver.addDependency(ArtifactType.TYPE_INSTALLABLE_UNIT, bundleSymbolicName, "0.0.0"); + resolver.addDependency(ArtifactType.TYPE_ECLIPSE_PLUGIN, bundleSymbolicName, "0.0.0"); needResolve = true; } catch (IllegalArtifactReferenceException e) { throw new TargetPlatformConfigurationException("Can't add API tools requirement", e); } + } + /** + * Add a feature to the application + * + * @param featureId + */ + public synchronized void addFeature(String featureId) { + try { + resolver.addDependency(ArtifactType.TYPE_ECLIPSE_FEATURE, featureId, "0.0.0"); + needResolve = true; + } catch (IllegalArtifactReferenceException e) { + throw new TargetPlatformConfigurationException("Can't add API tools requirement", e); + } } /** @@ -205,6 +220,17 @@ public EclipseFramework startFramework(EclipseWorkspace workspace, List EclipseFramework startFramework(EclipseWorkspace workspace, List bundles; + @Parameter + private List features; + @Parameter(property = "project", readonly = true) private MavenProject project; @@ -101,7 +104,7 @@ public void execute() throws MojoExecutionException, MojoFailureException { EclipseApplication application; //TODO configureable by parameters! Bundles bundles = new Bundles(getBundles()); - Features features = new Features(Set.of()); + Features features = new Features(getFeatures()); if (local) { TargetPlatform targetPlatform = projectManager.getTargetPlatform(project).orElseThrow( () -> new MojoFailureException("Can't get target platform for project " + project.getId())); @@ -145,8 +148,16 @@ public void execute() throws MojoExecutionException, MojoFailureException { } } + private Set getFeatures() { + Set set = new HashSet<>(); + if (features != null) { + set.addAll(features); + } + return set; + } + private Set getBundles() { - HashSet set = new HashSet<>(); + Set set = new HashSet<>(); set.add("org.eclipse.core.resources"); set.add("org.eclipse.core.runtime"); set.add("org.eclipse.core.jobs");