fix(java): order the IDE build's Maven classpath as Maven does (#7767)

The build model listed a dependency's own dependencies after all of its siblings instead of right after it, so of two artifacts with the same classes (dom4j:dom4j 1.6.1 and org.dom4j:dom4j 2.x) javac could load the one Maven does not. Walk the resolved graph in pre-order and rebuild openidea-java-build.jar.

Closes #7743
Цей коміт міститься в:
l0ng-ai authored and GitHub committed 2026-12-03 17:47:45 +08:00
1 джерело fc60719d4b
коміт 69c9521e85
3 files changed
+47 -2

No files matched your search

+6 -2
Переглянути файл
@@ -323,15 +323,19 @@ public final class BuildModel extends AbstractMavenLifecycleParticipant {
}
}
/** Pre-order, as Maven lists `project.getArtifacts()` for classpaths. */
/**
* Pre-order, as Maven lists `project.getArtifacts()` for classpaths: a dependency's own
* dependencies come before its next sibling, so jars with the same classes but different
* coordinates (`dom4j:dom4j` and `org.dom4j:dom4j`) resolve as they do in `mvn compile`.
*/
private static void collect(DependencyNode node, List<DependencyNode> out, Set<String> seen) {
for (DependencyNode child : node.getChildren()) {
Artifact a = child.getArtifact();
String key = a == null ? String.valueOf(System.identityHashCode(child))
: a.getGroupId() + ":" + a.getArtifactId() + ":" + a.getExtension() + ":" + a.getClassifier();
if (seen.add(key)) out.add(child);
collect(child, out, seen);
}
for (DependencyNode child : node.getChildren()) collect(child, out, seen);
}
/**
Бінарний файл не відображається.