From b27ebf41a7fd12162035c6dffda5b1bf3296a19f 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 --- .../io/quarkus/gradle/tasks/QuarkusDev.java | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) 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..ab99d14206fda 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 @@ -52,6 +52,7 @@ import org.gradle.api.tasks.options.Option; import io.quarkus.bootstrap.model.AppArtifact; +import io.quarkus.bootstrap.model.AppArtifactKey; import io.quarkus.bootstrap.model.AppDependency; import io.quarkus.bootstrap.model.AppModel; import io.quarkus.bootstrap.resolver.AppModelResolver; @@ -241,22 +242,13 @@ public void startDev() { throw new GradleException("Failed to resolve application model " + extension.getAppArtifact() + " dependencies", e); } - for (AppDependency appDep : appModel.getAllDependencies()) { - addToClassPaths(classPathManifest, context, appDep.getArtifact().getPath().toFile()); - } args.add("-Djava.util.logging.manager=org.jboss.logmanager.LogManager"); File wiringClassesDirectory = new File(getBuildDir(), "wiring-classes"); wiringClassesDirectory.mkdirs(); addToClassPaths(classPathManifest, context, wiringClassesDirectory); - //we also want to add the maven plugin jar to the class path - //this allows us to just directly use classes, without messing around copying them - //to the runner jar - addGradlePluginDeps(classPathManifest, context); - //now we need to build a temporary jar to actually run - File tempFile = new File(getBuildDir(), extension.finalName() + "-dev.jar"); tempFile.delete(); tempFile.deleteOnExit(); @@ -271,6 +263,7 @@ public void startDev() { res = file.getAbsolutePath(); } + final Set projectDependencies = new HashSet<>(); final Configuration compileCp = project.getConfigurations() .getByName(JavaPlugin.COMPILE_CLASSPATH_CONFIGURATION_NAME); final DependencySet compileCpDependencies = compileCp.getAllDependencies(); @@ -280,6 +273,11 @@ public void startDev() { continue; } + // Create the key via AppArtifact to make sure we use same defaults for type and classifier + AppArtifactKey key = new AppArtifact(dependency.getGroup(), dependency.getName(), dependency.getVersion()) + .getKey(); + projectDependencies.add(key); + Project dependencyProject = ((ProjectDependency) dependency).getDependencyProject(); Convention convention = dependencyProject.getConvention(); JavaPluginConvention javaConvention = convention.findPlugin(JavaPluginConvention.class); @@ -308,6 +306,17 @@ public void startDev() { context.getModules().add(wsModuleInfo); } + for (AppDependency appDependency : appModel.getAllDependencies()) { + if (!projectDependencies.contains(appDependency.getArtifact().getKey())) { + addToClassPaths(classPathManifest, context, appDependency.getArtifact().getPath().toFile()); + } + } + + //we also want to add the maven plugin jar to the class path + //this allows us to just directly use classes, without messing around copying them + //to the runner jar + addGradlePluginDeps(classPathManifest, context); + DevModeContext.ModuleInfo moduleInfo = new DevModeContext.ModuleInfo( project.getName(), project.getProjectDir().getAbsolutePath(),