diff --git a/tycho-apitools-plugin/src/main/java/org/eclipse/tycho/apitools/ApiAnalysisMojo.java b/tycho-apitools-plugin/src/main/java/org/eclipse/tycho/apitools/ApiAnalysisMojo.java index 3e83767c99..1edad48400 100644 --- a/tycho-apitools-plugin/src/main/java/org/eclipse/tycho/apitools/ApiAnalysisMojo.java +++ b/tycho-apitools-plugin/src/main/java/org/eclipse/tycho/apitools/ApiAnalysisMojo.java @@ -16,7 +16,6 @@ import java.net.URI; import java.nio.file.Path; import java.util.Collection; -import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Objects; @@ -41,23 +40,13 @@ import org.eclipse.pde.api.tools.internal.IApiCoreConstants; import org.eclipse.pde.api.tools.internal.provisional.ApiPlugin; import org.eclipse.pde.api.tools.internal.provisional.problems.IApiProblem; -import org.eclipse.tycho.ArtifactDescriptor; import org.eclipse.tycho.ArtifactKey; -import org.eclipse.tycho.ClasspathEntry; import org.eclipse.tycho.DependencyResolutionException; import org.eclipse.tycho.IllegalArtifactReferenceException; import org.eclipse.tycho.MavenRepositoryLocation; -import org.eclipse.tycho.ReactorProject; -import org.eclipse.tycho.ResolvedArtifactKey; import org.eclipse.tycho.TychoConstants; -import org.eclipse.tycho.classpath.ClasspathContributor; -import org.eclipse.tycho.core.TychoProject; import org.eclipse.tycho.core.TychoProjectManager; import org.eclipse.tycho.core.osgitools.DefaultReactorProject; -import org.eclipse.tycho.core.osgitools.MavenBundleResolver; -import org.eclipse.tycho.core.osgitools.OsgiBundleProject; -import org.eclipse.tycho.core.utils.TychoProjectUtils; -import org.eclipse.tycho.helper.PluginRealmHelper; import org.eclipse.tycho.model.project.EclipseProject; import org.eclipse.tycho.osgi.framework.EclipseApplication; import org.eclipse.tycho.osgi.framework.EclipseFramework; @@ -122,12 +111,6 @@ public class ApiAnalysisMojo extends AbstractMojo { @Component private ApiApplicationResolver resolver; - @Component - private PluginRealmHelper pluginRealmHelper; - - @Component - protected MavenBundleResolver mavenBundleResolver; - @Component private ApiApplicationResolver applicationResolver; @@ -158,7 +141,7 @@ public void execute() throws MojoExecutionException, MojoFailureException { } Collection dependencyBundles; try { - dependencyBundles = getProjectDependencies(); + dependencyBundles = projectManager.getProjectDependencies(project); } catch (Exception e) { throw new MojoFailureException("Can't fetch dependencies!", e); } @@ -279,56 +262,6 @@ private String time(long start) { return sec + " s"; } - private Collection getProjectDependencies() throws Exception { - Set dependencySet = new HashSet<>(); - TychoProject tychoProject = projectManager.getTychoProject(project).get(); - List dependencies = TychoProjectUtils - .getDependencyArtifacts(DefaultReactorProject.adapt(project)).getArtifacts(); - for (ArtifactDescriptor descriptor : dependencies) { - File location = descriptor.fetchArtifact().get(); - if (location.equals(project.getBasedir())) { - continue; - } - ReactorProject reactorProject = descriptor.getMavenProject(); - if (reactorProject == null) { - writeLocation(location, dependencySet); - } else { - ReactorProject otherProject = reactorProject; - writeLocation(otherProject.getArtifact(descriptor.getClassifier()), dependencySet); - } - } - if (tychoProject instanceof OsgiBundleProject bundleProject) { - pluginRealmHelper.visitPluginExtensions(project, session, ClasspathContributor.class, cpc -> { - List list = cpc.getAdditionalClasspathEntries(project, Artifact.SCOPE_COMPILE); - if (list != null && !list.isEmpty()) { - for (ClasspathEntry entry : list) { - for (File locations : entry.getLocations()) { - writeLocation(locations, dependencySet); - } - } - } - }); - // This is a hack because "org.eclipse.osgi.services" exports the annotation - // package and might then be resolved by Tycho as a dependency, but then PDE - // can't find the annotations here, so we always add this as a dependency - // manually here, once "org.eclipse.osgi.services" is gone we can remove this - // again! - Optional bundle = mavenBundleResolver.resolveMavenBundle(project, session, "org.osgi", - "org.osgi.service.component.annotations", "1.3.0"); - bundle.ifPresent(key -> { - writeLocation(key.getLocation(), dependencySet); - }); - } - return dependencySet; - } - - private void writeLocation(File location, Collection consumer) { - if (location == null) { - return; - } - consumer.add(location.getAbsoluteFile().toPath()); - } - private static final class ApiAppKey { private URI key; diff --git a/tycho-apitools-plugin/src/main/java/org/eclipse/tycho/apitools/ApiApplicationResolver.java b/tycho-apitools-plugin/src/main/java/org/eclipse/tycho/apitools/ApiApplicationResolver.java index edc1c11aca..57cf919f2b 100644 --- a/tycho-apitools-plugin/src/main/java/org/eclipse/tycho/apitools/ApiApplicationResolver.java +++ b/tycho-apitools-plugin/src/main/java/org/eclipse/tycho/apitools/ApiApplicationResolver.java @@ -18,6 +18,7 @@ import java.util.Collection; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import org.codehaus.plexus.component.annotations.Component; @@ -31,8 +32,11 @@ import org.eclipse.tycho.core.resolver.P2ResolutionResult; import org.eclipse.tycho.core.resolver.P2ResolutionResult.Entry; import org.eclipse.tycho.core.resolver.P2Resolver; +import org.eclipse.tycho.osgi.framework.Bundles; import org.eclipse.tycho.osgi.framework.EclipseApplication; import org.eclipse.tycho.osgi.framework.EclipseApplicationFactory; +import org.eclipse.tycho.osgi.framework.EclipseApplicationManager; +import org.eclipse.tycho.osgi.framework.Features; import org.osgi.framework.BundleException; import org.osgi.service.log.LogEntry; @@ -43,14 +47,6 @@ @Component(role = ApiApplicationResolver.class) public class ApiApplicationResolver { - private static final String FRAGMENT_COMPATIBILITY = "org.eclipse.osgi.compatibility.state"; - - private static final String BUNDLE_API_TOOLS = "org.eclipse.pde.api.tools"; - - private static final String BUNDLE_LAUNCHING_MACOS = "org.eclipse.jdt.launching.macosx"; - - private static final String FILTER_MACOS = "(osgi.os=macosx)"; - private final Map cache = new ConcurrentHashMap<>(); @Requirement @@ -59,6 +55,9 @@ public class ApiApplicationResolver { @Requirement private EclipseApplicationFactory applicationFactory; + @Requirement + private EclipseApplicationManager applicationManager; + public Collection getApiBaselineBundles(Collection baselineRepoLocations, ArtifactKey artifactKey) throws IllegalArtifactReferenceException { P2Resolver resolver = applicationFactory.createResolver(); @@ -77,16 +76,11 @@ public Collection getApiBaselineBundles(Collection { - logger.info("Resolve API tools runtime from " + apiToolsRepo + "..."); - EclipseApplication application = applicationFactory.createEclipseApplication(apiToolsRepo, - "ApiToolsApplication"); - application.addBundle(BUNDLE_API_TOOLS); - application.addBundle(FRAGMENT_COMPATIBILITY); - application.addConditionalBundle(BUNDLE_LAUNCHING_MACOS, FILTER_MACOS); - application.setLoggingFilter(ApiApplicationResolver::isOnlyDebug); - return application; - }); + + EclipseApplication application = applicationManager.getApplication(apiToolsRepo, new Bundles(Set.of(Bundles.BUNDLE_API_TOOLS)), + new Features(Set.of()), "Api Tools"); + application.setLoggingFilter(ApiApplicationResolver::isOnlyDebug); + return application; } private static boolean isOnlyDebug(LogEntry entry) { diff --git a/tycho-core/src/main/java/org/eclipse/tycho/core/TychoProjectManager.java b/tycho-core/src/main/java/org/eclipse/tycho/core/TychoProjectManager.java index 89d9481778..3487a68214 100644 --- a/tycho-core/src/main/java/org/eclipse/tycho/core/TychoProjectManager.java +++ b/tycho-core/src/main/java/org/eclipse/tycho/core/TychoProjectManager.java @@ -14,9 +14,14 @@ import java.io.File; import java.io.IOException; +import java.nio.file.Path; +import java.util.Collection; +import java.util.HashSet; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import javax.inject.Inject; @@ -31,18 +36,28 @@ import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.logging.Logger; +import org.eclipse.tycho.ArtifactDescriptor; import org.eclipse.tycho.ArtifactKey; +import org.eclipse.tycho.ClasspathEntry; import org.eclipse.tycho.DefaultArtifactKey; import org.eclipse.tycho.ExecutionEnvironmentConfiguration; import org.eclipse.tycho.ReactorProject; +import org.eclipse.tycho.ResolvedArtifactKey; +import org.eclipse.tycho.TargetPlatform; +import org.eclipse.tycho.TargetPlatformService; import org.eclipse.tycho.TychoConstants; +import org.eclipse.tycho.classpath.ClasspathContributor; import org.eclipse.tycho.core.ee.ExecutionEnvironmentConfigurationImpl; import org.eclipse.tycho.core.osgitools.AbstractTychoProject; import org.eclipse.tycho.core.osgitools.BundleReader; import org.eclipse.tycho.core.osgitools.DefaultReactorProject; +import org.eclipse.tycho.core.osgitools.MavenBundleResolver; +import org.eclipse.tycho.core.osgitools.OsgiBundleProject; import org.eclipse.tycho.core.osgitools.OsgiManifest; import org.eclipse.tycho.core.osgitools.OsgiManifestParserException; import org.eclipse.tycho.core.resolver.DefaultTargetPlatformConfigurationReader; +import org.eclipse.tycho.core.utils.TychoProjectUtils; +import org.eclipse.tycho.helper.PluginRealmHelper; import org.eclipse.tycho.model.project.EclipseProject; import org.eclipse.tycho.targetplatform.TargetDefinition; @@ -72,6 +87,15 @@ public class TychoProjectManager { @Requirement ToolchainManager toolchainManager; + @Requirement + PluginRealmHelper pluginRealmHelper; + + @Requirement + MavenBundleResolver mavenBundleResolver; + + @Requirement + TargetPlatformService targetPlatformService; + private final Map> eclipseProjectCache = new ConcurrentHashMap<>(); private final MavenSession mavenSession; @@ -203,4 +227,67 @@ public Optional getBndTychoProject(MavenProject project) { return Optional.empty(); } + /** + * Determine the list of dependencies for a given project as a collection of path items + * + * @param project + * the project to use to determine the dependencies + * @return a Collection of pathes describing the project dependencies + * @throws Exception + */ + public Collection getProjectDependencies(MavenProject project) throws Exception { + Set dependencySet = new HashSet<>(); + TychoProject tychoProject = getTychoProject(project).get(); + List dependencies = TychoProjectUtils + .getDependencyArtifacts(DefaultReactorProject.adapt(project)).getArtifacts(); + for (ArtifactDescriptor descriptor : dependencies) { + File location = descriptor.fetchArtifact().get(); + if (location.equals(project.getBasedir())) { + continue; + } + ReactorProject reactorProject = descriptor.getMavenProject(); + if (reactorProject == null) { + writeLocation(location, dependencySet); + } else { + writeLocation(reactorProject.getArtifact(descriptor.getClassifier()), dependencySet); + } + } + if (tychoProject instanceof OsgiBundleProject bundleProject) { + MavenSession session = getMavenSession(); + pluginRealmHelper.visitPluginExtensions(project, session, ClasspathContributor.class, cpc -> { + List list = cpc.getAdditionalClasspathEntries(project, Artifact.SCOPE_COMPILE); + if (list != null && !list.isEmpty()) { + for (ClasspathEntry entry : list) { + for (File locations : entry.getLocations()) { + writeLocation(locations, dependencySet); + } + } + } + }); + // This is a hack because "org.eclipse.osgi.services" exports the annotation + // package and might then be resolved by Tycho as a dependency, but then PDE + // can't find the annotations here, so we always add this as a dependency + // manually here, once "org.eclipse.osgi.services" is gone we can remove this + // again! + Optional bundle = mavenBundleResolver.resolveMavenBundle(project, session, "org.osgi", + "org.osgi.service.component.annotations", "1.3.0"); + bundle.ifPresent(key -> { + writeLocation(key.getLocation(), dependencySet); + }); + } + return dependencySet; + } + + private void writeLocation(File location, Collection consumer) { + if (location == null) { + return; + } + consumer.add(location.getAbsoluteFile().toPath()); + } + + public Optional getTargetPlatform(MavenProject project) { + return targetPlatformService.getTargetPlatform(DefaultReactorProject.adapt(project)); + + } + } diff --git a/tycho-core/src/main/java/org/eclipse/tycho/osgi/framework/Bundles.java b/tycho-core/src/main/java/org/eclipse/tycho/osgi/framework/Bundles.java new file mode 100644 index 0000000000..70d44d2c95 --- /dev/null +++ b/tycho-core/src/main/java/org/eclipse/tycho/osgi/framework/Bundles.java @@ -0,0 +1,31 @@ +/******************************************************************************* + * Copyright (c) 2023 Christoph Läubrich and others. + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Christoph Läubrich - initial API and implementation + *******************************************************************************/ +package org.eclipse.tycho.osgi.framework; + +import java.util.Set; + +public record Bundles(Set bundles) { + + public static final String BUNDLE_API_TOOLS = "org.eclipse.pde.api.tools"; + public static final String BUNDLE_ECLIPSE_HELP_BASE = "org.eclipse.help.base"; + public static final String BUNDLE_PDE_CORE = "org.eclipse.pde.core"; + static final String BUNDLE_LAUNCHING_MACOS = "org.eclipse.jdt.launching.macosx"; + static final String BUNDLE_APP = "org.eclipse.equinox.app"; + static final String BUNDLE_SCR = "org.apache.felix.scr"; + static final String BUNDLE_CORE = "org.eclipse.core.runtime"; + static final String BUNDLE_LAUNCHER = "org.eclipse.equinox.launcher"; + + public static Bundles of(String... bundles) { + return new Bundles(Set.of(bundles)); + } +} 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 0def310c5d..236e66f6e0 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 @@ -61,8 +61,8 @@ public class EclipseApplication { public static final String ARG_APPLICATION = "-application"; - private static final Set ALWAYS_START_BUNDLES = Set.of(EclipseApplicationFactory.BUNDLE_CORE, - EclipseApplicationFactory.BUNDLE_SCR, EclipseApplicationFactory.BUNDLE_APP); + private static final Set ALWAYS_START_BUNDLES = Set.of(Bundles.BUNDLE_CORE, + Bundles.BUNDLE_SCR, Bundles.BUNDLE_APP); private P2Resolver resolver; private TargetPlatform targetPlatform; private Logger logger; diff --git a/tycho-core/src/main/java/org/eclipse/tycho/osgi/framework/EclipseApplicationFactory.java b/tycho-core/src/main/java/org/eclipse/tycho/osgi/framework/EclipseApplicationFactory.java index f5c97f535f..bc4637cdc8 100644 --- a/tycho-core/src/main/java/org/eclipse/tycho/osgi/framework/EclipseApplicationFactory.java +++ b/tycho-core/src/main/java/org/eclipse/tycho/osgi/framework/EclipseApplicationFactory.java @@ -42,14 +42,6 @@ @SessionScoped public class EclipseApplicationFactory { - static final String BUNDLE_APP = "org.eclipse.equinox.app"; - - static final String BUNDLE_SCR = "org.apache.felix.scr"; - - static final String BUNDLE_CORE = "org.eclipse.core.runtime"; - - private static final String BUNDLE_LAUNCHER = "org.eclipse.equinox.launcher"; - @Requirement private ToolchainManager toolchainManager; @@ -67,15 +59,17 @@ public EclipseApplicationFactory(MavenSession mavenSession) { } public EclipseApplication createEclipseApplication(MavenRepositoryLocation repositoryLocation, String name) { + return createEclipseApplication(createTargetPlatform(List.of(repositoryLocation)), name); + } + + public EclipseApplication createEclipseApplication(TargetPlatform targetPlatform, String name) { P2Resolver resolver = createResolver(); - List locations = List.of(repositoryLocation); - TargetPlatform targetPlatform = createTargetPlatform(locations); EclipseApplication application = new EclipseApplication(name, resolver, targetPlatform, logger); //add the bare minimum required ... - application.addBundle(BUNDLE_CORE); - application.addBundle(BUNDLE_SCR); - application.addBundle(BUNDLE_APP); - application.addBundle(BUNDLE_LAUNCHER); + application.addBundle(Bundles.BUNDLE_CORE); + application.addBundle(Bundles.BUNDLE_SCR); + application.addBundle(Bundles.BUNDLE_APP); + application.addBundle(Bundles.BUNDLE_LAUNCHER); return application; } diff --git a/tycho-core/src/main/java/org/eclipse/tycho/osgi/framework/EclipseApplicationManager.java b/tycho-core/src/main/java/org/eclipse/tycho/osgi/framework/EclipseApplicationManager.java new file mode 100644 index 0000000000..025431a251 --- /dev/null +++ b/tycho-core/src/main/java/org/eclipse/tycho/osgi/framework/EclipseApplicationManager.java @@ -0,0 +1,89 @@ +/******************************************************************************* + * Copyright (c) 2023 Christoph Läubrich and others. + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Christoph Läubrich - initial API and implementation + *******************************************************************************/ +package org.eclipse.tycho.osgi.framework; + +import java.net.URI; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +import org.apache.maven.model.Repository; +import org.codehaus.plexus.component.annotations.Component; +import org.codehaus.plexus.component.annotations.Requirement; +import org.eclipse.tycho.MavenRepositoryLocation; +import org.eclipse.tycho.TargetPlatform; +import org.eclipse.tycho.TychoConstants; + +@Component(role = EclipseApplicationManager.class) +public class EclipseApplicationManager { + + private static final String FRAGMENT_COMPATIBILITY = "org.eclipse.osgi.compatibility.state"; + + private static final String FILTER_MACOS = "(osgi.os=macosx)"; + + public static MavenRepositoryLocation getRepository(Repository location) { + if (location == null) { + return new MavenRepositoryLocation(null, URI.create(TychoConstants.ECLIPSE_LATEST)); + } + return new MavenRepositoryLocation(location.getId(), URI.create(location.getUrl())); + } + + private final Map targetPlatformCache = new ConcurrentHashMap<>(); + + private final Map applicationCache = new ConcurrentHashMap<>(); + + @Requirement + private EclipseApplicationFactory applicationFactory; + + public EclipseApplication getApplication(TargetPlatform targetPlatform, Bundles bundles, Features features, + String name) { + + return applicationCache.computeIfAbsent(new TargetCacheKey(targetPlatform, bundles, features), key -> { + EclipseApplication application = applicationFactory.createEclipseApplication(key.targetPlatform(), name); + addBundlesAndFeatures(bundles, features, application); + return application; + }); + } + + public EclipseApplication getApplication(Repository location, Bundles bundles, Features features, String name) { + return getApplication(getRepository(location), bundles, features, name); + } + + public EclipseApplication getApplication(MavenRepositoryLocation repository, Bundles bundles, Features features, + String name) { + TargetPlatform targetPlatform = targetPlatformCache.computeIfAbsent(repository.getURL().normalize(), + x -> applicationFactory.createTargetPlatform(List.of(repository))); + return getApplication(targetPlatform, bundles, features, name); + } + + private void addBundlesAndFeatures(Bundles bundles, Features features, EclipseApplication application) { + for (String bsn : bundles.bundles()) { + //TODO can we do this after resolve and check to add additional things?!? + if (Bundles.BUNDLE_PDE_CORE.equals(bsn) || Bundles.BUNDLE_API_TOOLS.equals(bsn)) { + //PDE requires compatibility + application.addBundle(FRAGMENT_COMPATIBILITY); + } + if (Bundles.BUNDLE_API_TOOLS.equals(bsn)) { + application.addConditionalBundle(Bundles.BUNDLE_LAUNCHING_MACOS, FILTER_MACOS); + } + application.addBundle(bsn); + } + for (String feature : features.features()) { + //TODO application.addFeature(feature); + } + } + + private static record TargetCacheKey(TargetPlatform targetPlatform, Bundles bundles, Features feature) { + + } +} diff --git a/tycho-core/src/main/java/org/eclipse/tycho/osgi/framework/Features.java b/tycho-core/src/main/java/org/eclipse/tycho/osgi/framework/Features.java new file mode 100644 index 0000000000..631b81c372 --- /dev/null +++ b/tycho-core/src/main/java/org/eclipse/tycho/osgi/framework/Features.java @@ -0,0 +1,23 @@ +/******************************************************************************* + * Copyright (c) 2023 Christoph Läubrich and others. + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Christoph Läubrich - initial API and implementation + *******************************************************************************/ +package org.eclipse.tycho.osgi.framework; + +import java.util.Set; + +public record Features(Set features) { + + public static Features of(String... features) { + return new Features(Set.of(features)); + } + +} diff --git a/tycho-extras/tycho-document-bundle-plugin/src/main/java/org/eclipse/tycho/extras/docbundle/BuildHelpIndexMojo.java b/tycho-extras/tycho-document-bundle-plugin/src/main/java/org/eclipse/tycho/extras/docbundle/BuildHelpIndexMojo.java index 4abb60759e..a0cd7bb9b5 100644 --- a/tycho-extras/tycho-document-bundle-plugin/src/main/java/org/eclipse/tycho/extras/docbundle/BuildHelpIndexMojo.java +++ b/tycho-extras/tycho-document-bundle-plugin/src/main/java/org/eclipse/tycho/extras/docbundle/BuildHelpIndexMojo.java @@ -28,10 +28,13 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.tycho.MavenRepositoryLocation; import org.eclipse.tycho.extras.docbundle.runner.BuildHelpIndexRunner; +import org.eclipse.tycho.osgi.framework.Bundles; import org.eclipse.tycho.osgi.framework.EclipseApplication; +import org.eclipse.tycho.osgi.framework.EclipseApplicationManager; import org.eclipse.tycho.osgi.framework.EclipseFramework; import org.eclipse.tycho.osgi.framework.EclipseWorkspace; import org.eclipse.tycho.osgi.framework.EclipseWorkspaceManager; +import org.eclipse.tycho.osgi.framework.Features; import org.osgi.framework.BundleException; /** @@ -51,7 +54,7 @@ public class BuildHelpIndexMojo extends AbstractMojo { private Repository buildToolsRepository; @Component - private DocApplicationManager applicationManager; + private EclipseApplicationManager applicationManager; @Component private EclipseWorkspaceManager workspaceManager; @@ -61,8 +64,9 @@ public void execute() throws MojoExecutionException, MojoFailureException { if (manifest == null || !manifest.exists()) { throw new MojoExecutionException("Manifest is not a file: " + manifest); } - MavenRepositoryLocation repository = DocApplicationManager.getRepository(buildToolsRepository); - EclipseApplication application = applicationManager.getBuildIndexApplication(repository); + MavenRepositoryLocation repository = EclipseApplicationManager.getRepository(buildToolsRepository); + EclipseApplication application = applicationManager.getApplication(repository, + Bundles.of(Bundles.BUNDLE_ECLIPSE_HELP_BASE), Features.of(), "Build Document Index"); EclipseWorkspace workspace = workspaceManager.getWorkspace(repository.getURL(), this); try (EclipseFramework framework = application.startFramework(workspace, List.of())) { outputDirectory.mkdirs(); diff --git a/tycho-extras/tycho-document-bundle-plugin/src/main/java/org/eclipse/tycho/extras/docbundle/ConvertSchemaToHtmlMojo.java b/tycho-extras/tycho-document-bundle-plugin/src/main/java/org/eclipse/tycho/extras/docbundle/ConvertSchemaToHtmlMojo.java index 02261d272c..b2d382c414 100644 --- a/tycho-extras/tycho-document-bundle-plugin/src/main/java/org/eclipse/tycho/extras/docbundle/ConvertSchemaToHtmlMojo.java +++ b/tycho-extras/tycho-document-bundle-plugin/src/main/java/org/eclipse/tycho/extras/docbundle/ConvertSchemaToHtmlMojo.java @@ -39,10 +39,13 @@ import org.eclipse.tycho.PackagingType; import org.eclipse.tycho.extras.docbundle.runner.ConvertSchemaToHtmlResult; import org.eclipse.tycho.extras.docbundle.runner.ConvertSchemaToHtmlRunner; +import org.eclipse.tycho.osgi.framework.Bundles; import org.eclipse.tycho.osgi.framework.EclipseApplication; +import org.eclipse.tycho.osgi.framework.EclipseApplicationManager; import org.eclipse.tycho.osgi.framework.EclipseFramework; import org.eclipse.tycho.osgi.framework.EclipseWorkspace; import org.eclipse.tycho.osgi.framework.EclipseWorkspaceManager; +import org.eclipse.tycho.osgi.framework.Features; import org.osgi.framework.BundleException; /** @@ -75,12 +78,13 @@ public class ConvertSchemaToHtmlMojo extends AbstractMojo { @Component private EclipseWorkspaceManager workspaceManager; @Component - private PdeApplicationManager applicationManager; + private EclipseApplicationManager applicationManager; @Override public void execute() throws MojoExecutionException, MojoFailureException { - MavenRepositoryLocation repository = PdeApplicationManager.getRepository(pdeToolsRepository); - EclipseApplication application = applicationManager.getApplication(repository); + MavenRepositoryLocation repository = EclipseApplicationManager.getRepository(pdeToolsRepository); + EclipseApplication application = applicationManager.getApplication(repository, + Bundles.of(Bundles.BUNDLE_PDE_CORE), Features.of(), "Schema to Html"); EclipseWorkspace workspace = workspaceManager.getWorkspace(repository.getURL(), this); List searchPaths = new ArrayList<>(); // first add all userpath... diff --git a/tycho-extras/tycho-document-bundle-plugin/src/main/java/org/eclipse/tycho/extras/docbundle/DocApplicationManager.java b/tycho-extras/tycho-document-bundle-plugin/src/main/java/org/eclipse/tycho/extras/docbundle/DocApplicationManager.java deleted file mode 100644 index 9505e0a513..0000000000 --- a/tycho-extras/tycho-document-bundle-plugin/src/main/java/org/eclipse/tycho/extras/docbundle/DocApplicationManager.java +++ /dev/null @@ -1,51 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2023 Christoph Läubrich and others. - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Christoph Läubrich - initial API and implementation - *******************************************************************************/ -package org.eclipse.tycho.extras.docbundle; - -import java.net.URI; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -import org.apache.maven.model.Repository; -import org.codehaus.plexus.component.annotations.Component; -import org.codehaus.plexus.component.annotations.Requirement; -import org.eclipse.tycho.MavenRepositoryLocation; -import org.eclipse.tycho.TychoConstants; -import org.eclipse.tycho.osgi.framework.EclipseApplication; -import org.eclipse.tycho.osgi.framework.EclipseApplicationFactory; - -@Component(role = DocApplicationManager.class) -public class DocApplicationManager { - - static MavenRepositoryLocation getRepository(Repository location) { - if (location == null) { - return new MavenRepositoryLocation(null, URI.create(TychoConstants.ECLIPSE_LATEST)); - } - return new MavenRepositoryLocation(location.getId(), URI.create(location.getUrl())); - } - - private final Map buildIndexCache = new ConcurrentHashMap<>(); - - @Requirement - private EclipseApplicationFactory applicationFactory; - - public EclipseApplication getBuildIndexApplication(MavenRepositoryLocation repository) { - return buildIndexCache.computeIfAbsent(repository.getURL().normalize(), x -> { - EclipseApplication application = applicationFactory.createEclipseApplication(repository, - "Build Document Index"); - application.addBundle("org.eclipse.help.base"); - return application; - }); - - } -} diff --git a/tycho-extras/tycho-document-bundle-plugin/src/main/java/org/eclipse/tycho/extras/docbundle/PdeApplicationManager.java b/tycho-extras/tycho-document-bundle-plugin/src/main/java/org/eclipse/tycho/extras/docbundle/PdeApplicationManager.java deleted file mode 100644 index cd5482bcdc..0000000000 --- a/tycho-extras/tycho-document-bundle-plugin/src/main/java/org/eclipse/tycho/extras/docbundle/PdeApplicationManager.java +++ /dev/null @@ -1,51 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2023 Christoph Läubrich and others. - * This program and the accompanying materials - * are made available under the terms of the Eclipse Public License 2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Christoph Läubrich - initial API and implementation - *******************************************************************************/ -package org.eclipse.tycho.extras.docbundle; - -import java.net.URI; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -import org.apache.maven.model.Repository; -import org.codehaus.plexus.component.annotations.Component; -import org.codehaus.plexus.component.annotations.Requirement; -import org.eclipse.tycho.MavenRepositoryLocation; -import org.eclipse.tycho.TychoConstants; -import org.eclipse.tycho.osgi.framework.EclipseApplication; -import org.eclipse.tycho.osgi.framework.EclipseApplicationFactory; - -@Component(role = PdeApplicationManager.class) -public class PdeApplicationManager { - - static MavenRepositoryLocation getRepository(Repository location) { - if (location == null) { - return new MavenRepositoryLocation(null, URI.create(TychoConstants.ECLIPSE_LATEST)); - } - return new MavenRepositoryLocation(location.getId(), URI.create(location.getUrl())); - } - - private final Map buildIndexCache = new ConcurrentHashMap<>(); - - @Requirement - private EclipseApplicationFactory applicationFactory; - - public EclipseApplication getApplication(MavenRepositoryLocation repository) { - return buildIndexCache.computeIfAbsent(repository.getURL().normalize(), x -> { - EclipseApplication application = applicationFactory.createEclipseApplication(repository, "PDE Tools"); - application.addBundle("org.eclipse.pde.core"); - application.addBundle("org.eclipse.osgi.compatibility.state"); - return application; - }); - - } -}