Skip to content

Commit

Permalink
Export the entries of transitive dependencies
Browse files Browse the repository at this point in the history
JDT has a concept of exporting classpath entries that can be used when
referencing a project in the remote-debugger, currently no entries are
exported.

This sets the exported flag for all items that are normally transitive
in maven.
  • Loading branch information
laeubi committed Jun 13, 2023
1 parent 1b8661c commit d31ccee
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ void addClasspathEntries(IClasspathDescriptor classpath, IMavenProjectFacade fac
entry.setArtifactKey(new ArtifactKey(a.getGroupId(), a.getArtifactId(), a.getBaseVersion(), a.getClassifier()));
entry.setScope(a.getScope());
entry.setOptionalDependency(a.isOptional());
entry.setExported(isExportedArtifact(a));
}
}

Expand All @@ -161,6 +162,19 @@ void addClasspathEntries(IClasspathDescriptor classpath, IMavenProjectFacade fac
});
}

private boolean isExportedArtifact(Artifact a) {
if(Artifact.SCOPE_PROVIDED.equals(a.getScope())) {
//provided items are not transitive
return false;
}
if(a.isOptional()) {
//optional artifacts are also not transitive
return false;
}
//everything else is considered transitive
return true;
}

private boolean isOnlyVisibleByTests(Artifact a) {
return Artifact.SCOPE_TEST.equals(a.getScope()) || Artifact.SCOPE_RUNTIME.equals(a.getScope());
}
Expand Down

0 comments on commit d31ccee

Please sign in to comment.