Skip to content

Commit

Permalink
Handle configured parent first resources
Browse files Browse the repository at this point in the history
Configured parent first resources need to be placed on the class path to
take effect.

This fixes it for maven, a similar fix will be needed for gradle
  • Loading branch information
stuartwdouglas committed Feb 2, 2022
1 parent 8280c53 commit 2d3eb8c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
13 changes: 12 additions & 1 deletion devtools/maven/src/main/java/io/quarkus/maven/DevMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,10 @@
import org.fusesource.jansi.internal.WindowsSupport;

import io.quarkus.bootstrap.BootstrapConstants;
import io.quarkus.bootstrap.app.QuarkusBootstrap;
import io.quarkus.bootstrap.devmode.DependenciesFilter;
import io.quarkus.bootstrap.model.ApplicationModel;
import io.quarkus.bootstrap.model.PathsCollection;
import io.quarkus.bootstrap.resolver.BootstrapAppModelResolver;
import io.quarkus.bootstrap.resolver.maven.MavenArtifactResolver;
import io.quarkus.bootstrap.resolver.maven.options.BootstrapMavenOptions;
Expand Down Expand Up @@ -1028,11 +1030,20 @@ private QuarkusDevModeLauncher newLauncher() throws Exception {
}

addQuarkusDevModeDeps(builder);
//look for an application.properties
Set<Path> resourceDirs = new HashSet<>();
for (Resource resource : project.getResources()) {
String dir = resource.getDirectory();
Path path = Paths.get(dir);
resourceDirs.add(path);
}
Set<ArtifactKey> configuredParentFirst = QuarkusBootstrap.createClassLoadingConfig(PathsCollection.from(resourceDirs),
QuarkusBootstrap.Mode.DEV, Collections.emptyList()).parentFirstArtifacts;

//in most cases these are not used, however they need to be present for some
//parent-first cases such as logging
//first we go through and get all the parent first artifacts
Set<ArtifactKey> parentFirstArtifacts = new HashSet<>();
Set<ArtifactKey> parentFirstArtifacts = new HashSet<>(configuredParentFirst);
for (Artifact appDep : project.getArtifacts()) {
if (appDep.getArtifactHandler().getExtension().equals(ArtifactCoords.TYPE_JAR) && appDep.getFile().isFile()) {
try (ZipFile file = new ZipFile(appDep.getFile())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public CuratedApplication bootstrap() throws BootstrapException {
return new CuratedApplication(this, appModelFactory.resolveAppModel(), classLoadingConfig);
}

private static ConfiguredClassLoading createClassLoadingConfig(PathCollection applicationRoot, Mode mode,
public static ConfiguredClassLoading createClassLoadingConfig(PathCollection applicationRoot, Mode mode,
List<ArtifactKey> parentFirstArtifacts) {
//look for an application.properties
for (Path path : applicationRoot) {
Expand Down

0 comments on commit 2d3eb8c

Please sign in to comment.