Skip to content

Commit

Permalink
Fix using the outputfolder as a classpath jar
Browse files Browse the repository at this point in the history
The ProjectBuilder currently uses the output folder of a project as an
additional classpath jar, this then can even confuse BND as it thinks we
have a split package and try to copy that class into the jar itself.

This extends the default ProjectBuilder, check if the jar is sourced at
the output location and then skip adding the jar.
  • Loading branch information
laeubi committed Oct 22, 2023
1 parent 474c50c commit 6790bd3
Showing 1 changed file with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
package org.eclipse.pde.internal.core.bnd;

import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicBoolean;
Expand Down Expand Up @@ -131,7 +132,25 @@ private static void buildProjectJar(IProject project, IProgressMonitor monitor)
if (monitor.isCanceled()) {
return;
}
try (Project bnd = bndProject.get(); ProjectBuilder builder = new ProjectBuilder(bnd)) {
try (Project bnd = bndProject.get(); ProjectBuilder builder = new ProjectBuilder(bnd) {
@Override
public void addClasspath(aQute.bnd.osgi.Jar jar) {
try {
// If the output exits, the ProjectBuilder adds the
// output as a classpath jar, this on the other hand
// later confuses BND because it thinks there is a
// splitpackage and tries to copy the class into the jar
// again...
if (Objects.equals(jar.getSource(), bnd.getOutput())) {
jar.close();
return;
}
} catch (Exception e) {
// can't do anything useful...
}
super.addClasspath(jar);
}
}) {
builder.setBase(bnd.getBase());
ProjectJar jar = new ProjectJar(project, CLASS_FILTER);
builder.setJar(jar);
Expand Down

0 comments on commit 6790bd3

Please sign in to comment.