From d31ccee9baa20b770908dff18f558f660e257dae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20L=C3=A4ubrich?= Date: Tue, 13 Jun 2023 10:20:58 +0200 Subject: [PATCH] Export the entries of transitive dependencies 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. --- .../internal/DefaultClasspathManagerDelegate.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/org.eclipse.m2e.jdt/src/org/eclipse/m2e/jdt/internal/DefaultClasspathManagerDelegate.java b/org.eclipse.m2e.jdt/src/org/eclipse/m2e/jdt/internal/DefaultClasspathManagerDelegate.java index 7e8b95f2f9..9ae03f762d 100644 --- a/org.eclipse.m2e.jdt/src/org/eclipse/m2e/jdt/internal/DefaultClasspathManagerDelegate.java +++ b/org.eclipse.m2e.jdt/src/org/eclipse/m2e/jdt/internal/DefaultClasspathManagerDelegate.java @@ -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)); } } @@ -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()); }