Skip to content

Commit 07740e2

Browse files
steffenschmitt1sschmitt
authored andcommitted
Add getAdditionalEntries to IClasspathContributor
Adds a new method to allow classpath contributor to append additional classpath entries at the end of the calculation process.
1 parent 92fa880 commit 07740e2

2 files changed

Lines changed: 59 additions & 0 deletions

File tree

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2013, 2024 BestSolution.at and others.
3+
*
4+
* This program and the accompanying materials
5+
* are made available under the terms of the Eclipse Public License 2.0
6+
* which accompanies this distribution, and is available at
7+
* https://www.eclipse.org/legal/epl-2.0/
8+
*
9+
* SPDX-License-Identifier: EPL-2.0
10+
*
11+
* Contributors:
12+
* BestSolution.at - initial API and implementation
13+
* IBM Corporation - ongoing enhancements
14+
* Christoph Läubrich - allow register as a service
15+
*******************************************************************************/
16+
package org.eclipse.pde.core;
17+
18+
import java.util.stream.Stream;
19+
20+
import org.eclipse.jdt.core.IClasspathEntry;
21+
import org.eclipse.osgi.service.resolver.BundleDescription;
22+
import org.eclipse.pde.core.plugin.PluginRegistry;
23+
import org.osgi.resource.Resource;
24+
25+
/**
26+
* Extension interface for {@link org.eclipse.pde.core.IClasspathContributor}.
27+
* <p>
28+
* This interface allows adding classpath entries after the classpath has been
29+
* calculated.
30+
* </p>
31+
*
32+
* @since 3.21
33+
*/
34+
public interface IClasspathContributor2 extends IClasspathContributor {
35+
36+
/**
37+
* Get any additional classpath entries to add to a project when its
38+
* classpath is first computed. The provided {@link BundleDescription}
39+
* describes the plug-in project that the classpath is being computed for.
40+
* The entries are added at the end of the calculation process. Additional
41+
* PDE model information can be obtained using
42+
* {@link PluginRegistry#findModel(Resource)}.
43+
*
44+
* @param project
45+
* the bundle descriptor for the plug-in project having its
46+
* classpath computed
47+
* @return additional classpath entries to add to the project at the end of
48+
* the classpath calculation, possibly empty, must not be
49+
* <code>null</code>
50+
* @since 3.21
51+
*/
52+
Stream<IClasspathEntry> getAdditionalEntries(BundleDescription project);
53+
}

ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/RequiredPluginsClasspathContainer.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
import org.eclipse.osgi.service.resolver.ImportPackageSpecification;
5555
import org.eclipse.osgi.service.resolver.StateHelper;
5656
import org.eclipse.pde.core.IClasspathContributor;
57+
import org.eclipse.pde.core.IClasspathContributor2;
5758
import org.eclipse.pde.core.build.IBuild;
5859
import org.eclipse.pde.core.build.IBuildEntry;
5960
import org.eclipse.pde.core.plugin.IPluginModelBase;
@@ -278,7 +279,12 @@ private List<IClasspathEntry> computePluginEntriesByModel() {
278279
addJunit5RuntimeDependencies(added, entries);
279280
addImplicitDependencies(desc, added, entries);
280281

282+
// Add any additional library entries contributed via classpath
283+
// contributor
284+
entries.addAll(getClasspathContributors().filter(IClasspathContributor2.class::isInstance)
285+
.map(IClasspathContributor2.class::cast).flatMap(cc -> cc.getAdditionalEntries(desc)).toList());
281286
} catch (CoreException e) {
287+
282288
}
283289
return entries;
284290
}

0 commit comments

Comments
 (0)