Skip to content

Commit 6dc51e2

Browse files
steffenschmitt1laeubi
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 700e1c6 commit 6dc51e2

File tree

3 files changed

+57
-1
lines changed

3 files changed

+57
-1
lines changed
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
Added new method to IBuildEntry
1+
Added new method to IBuildEntry
2+
https://github.com/eclipse-pde/eclipse.pde/issues/1846
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2025 Vector Informatik GmbH 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+
*******************************************************************************/
12+
package org.eclipse.pde.core;
13+
14+
import java.util.stream.Stream;
15+
16+
import org.eclipse.jdt.core.IClasspathEntry;
17+
import org.eclipse.osgi.service.resolver.BundleDescription;
18+
import org.eclipse.pde.core.plugin.PluginRegistry;
19+
import org.osgi.resource.Resource;
20+
21+
/**
22+
* Extension interface for {@link org.eclipse.pde.core.IClasspathContributor}.
23+
* <p>
24+
* This interface allows adding classpath entries after the classpath has been
25+
* calculated.
26+
* </p>
27+
*
28+
* @since 3.21
29+
*/
30+
public interface IClasspathContributor2 extends IClasspathContributor {
31+
32+
/**
33+
* Get any additional classpath entries to add to a project when its
34+
* classpath is first computed. The provided {@link BundleDescription}
35+
* describes the plug-in project that the classpath is being computed for.
36+
* The entries are added at the end of the calculation process. Additional
37+
* PDE model information can be obtained using
38+
* {@link PluginRegistry#findModel(Resource)}.
39+
*
40+
* @param project
41+
* the bundle descriptor for the plug-in project having its
42+
* classpath computed
43+
* @return additional classpath entries to add to the project at the end of
44+
* the classpath calculation, possibly empty, must not be
45+
* <code>null</code>
46+
* @since 3.21
47+
*/
48+
Stream<IClasspathEntry> getAdditionalEntries(BundleDescription project);
49+
}

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
@@ -52,6 +52,7 @@
5252
import org.eclipse.osgi.service.resolver.ImportPackageSpecification;
5353
import org.eclipse.osgi.service.resolver.StateHelper;
5454
import org.eclipse.pde.core.IClasspathContributor;
55+
import org.eclipse.pde.core.IClasspathContributor2;
5556
import org.eclipse.pde.core.build.IBuild;
5657
import org.eclipse.pde.core.build.IBuildEntry;
5758
import org.eclipse.pde.core.build.IBuildModel;
@@ -260,6 +261,11 @@ private List<IClasspathEntry> computePluginEntriesByModel() throws CoreException
260261
addJunit5RuntimeDependencies(added, entries);
261262
addImplicitDependencies(desc, added, entries);
262263

264+
// Add any additional library entries contributed via classpath
265+
// contributor
266+
entries.addAll(getClasspathContributors().filter(IClasspathContributor2.class::isInstance)
267+
.map(IClasspathContributor2.class::cast).flatMap(cc -> cc.getAdditionalEntries(desc)).toList());
268+
263269
return entries;
264270
}
265271

0 commit comments

Comments
 (0)