From be74264edf9f15108dcce8b84658b9317e83ff48 Mon Sep 17 00:00:00 2001 From: Tobias Date: Wed, 8 Jan 2020 15:09:27 +0800 Subject: [PATCH] This fixes issue #6442 that project dependencies end up twice on the quarkusDev classpath Change logging to debug Simplify check if ProjectComponentIdentifier --- .../java/io/quarkus/gradle/AppModelGradleResolver.java | 3 +++ .../main/java/io/quarkus/gradle/tasks/QuarkusDev.java | 6 +++++- .../java/io/quarkus/bootstrap/model/AppArtifact.java | 10 ++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/devtools/gradle/src/main/java/io/quarkus/gradle/AppModelGradleResolver.java b/devtools/gradle/src/main/java/io/quarkus/gradle/AppModelGradleResolver.java index 16862ef104244..0689505975055 100644 --- a/devtools/gradle/src/main/java/io/quarkus/gradle/AppModelGradleResolver.java +++ b/devtools/gradle/src/main/java/io/quarkus/gradle/AppModelGradleResolver.java @@ -23,6 +23,8 @@ import org.gradle.api.artifacts.ModuleVersionIdentifier; import org.gradle.api.artifacts.ResolvedArtifact; import org.gradle.api.artifacts.ResolvedConfiguration; +import org.gradle.api.artifacts.component.ComponentIdentifier; +import org.gradle.api.artifacts.component.ProjectComponentIdentifier; import org.gradle.api.file.RegularFile; import org.gradle.api.internal.artifacts.DefaultModuleIdentifier; import org.gradle.api.internal.artifacts.dependencies.DefaultDependencyArtifact; @@ -192,6 +194,7 @@ private ModuleIdentifier getModuleId(ResolvedArtifact a) { private AppDependency toAppDependency(ResolvedArtifact a) { final String[] split = a.getModuleVersion().toString().split(":"); final AppArtifact appArtifact = new AppArtifact(split[0], split[1], split[2]); + appArtifact.setSubModule(a.getId().getComponentIdentifier() instanceof ProjectComponentIdentifier); appArtifact.setPath(a.getFile().toPath()); return new AppDependency(appArtifact, "runtime"); } diff --git a/devtools/gradle/src/main/java/io/quarkus/gradle/tasks/QuarkusDev.java b/devtools/gradle/src/main/java/io/quarkus/gradle/tasks/QuarkusDev.java index d5984ab07fc6a..a0dc3eee49e62 100644 --- a/devtools/gradle/src/main/java/io/quarkus/gradle/tasks/QuarkusDev.java +++ b/devtools/gradle/src/main/java/io/quarkus/gradle/tasks/QuarkusDev.java @@ -242,7 +242,11 @@ public void startDev() { e); } for (AppDependency appDep : appModel.getAllDependencies()) { - addToClassPaths(classPathManifest, context, appDep.getArtifact().getPath().toFile()); + if (!appDep.getArtifact().isSubModule()) { + addToClassPaths(classPathManifest, context, appDep.getArtifact().getPath().toFile()); + } else { + getLogger().debug("Ignoring {} as it is a project dependency", appDep); + } } args.add("-Djava.util.logging.manager=org.jboss.logmanager.LogManager"); diff --git a/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/model/AppArtifact.java b/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/model/AppArtifact.java index 5f146ad44f8c7..e1260c01de2a2 100644 --- a/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/model/AppArtifact.java +++ b/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/model/AppArtifact.java @@ -11,6 +11,8 @@ public class AppArtifact extends AppArtifactCoords { protected Path path; + protected boolean subModule; + public AppArtifact(String groupId, String artifactId, String version) { super(groupId, artifactId, version); } @@ -30,4 +32,12 @@ public void setPath(Path path) { public boolean isResolved() { return path != null; } + + public boolean isSubModule() { + return subModule; + } + + public void setSubModule(boolean subModule) { + this.subModule = subModule; + } }