Skip to content

Commit

Permalink
This fixes issue quarkusio#6442 that project dependencies end up twic…
Browse files Browse the repository at this point in the history
…e on the quarkusDev classpath
  • Loading branch information
tobad357 committed Jan 8, 2020
1 parent 7041929 commit b27ebf4
Showing 1 changed file with 18 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand All @@ -271,6 +263,7 @@ public void startDev() {
res = file.getAbsolutePath();
}

final Set<AppArtifactKey> projectDependencies = new HashSet<>();
final Configuration compileCp = project.getConfigurations()
.getByName(JavaPlugin.COMPILE_CLASSPATH_CONFIGURATION_NAME);
final DependencySet compileCpDependencies = compileCp.getAllDependencies();
Expand All @@ -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);
Expand Down Expand Up @@ -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(),
Expand Down

0 comments on commit b27ebf4

Please sign in to comment.