diff --git a/independent-projects/bootstrap/app-model/src/main/java/io/quarkus/bootstrap/model/PlatformImportsImpl.java b/independent-projects/bootstrap/app-model/src/main/java/io/quarkus/bootstrap/model/PlatformImportsImpl.java index 9105643940b67..87b1d1a4e0019 100644 --- a/independent-projects/bootstrap/app-model/src/main/java/io/quarkus/bootstrap/model/PlatformImportsImpl.java +++ b/independent-projects/bootstrap/app-model/src/main/java/io/quarkus/bootstrap/model/PlatformImportsImpl.java @@ -3,7 +3,6 @@ import io.quarkus.bootstrap.BootstrapConstants; import io.quarkus.bootstrap.resolver.AppModelResolverException; import io.quarkus.maven.dependency.ArtifactCoords; -import io.quarkus.maven.dependency.GACTV; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStream; @@ -77,10 +76,9 @@ void addPlatformRelease(String propertyName, String propertyValue) { } public void addPlatformDescriptor(String groupId, String artifactId, String classifier, String type, String version) { - final ArtifactCoords bomCoords = new GACTV(groupId, + final ArtifactCoords bomCoords = ArtifactCoords.pom(groupId, artifactId.substring(0, artifactId.length() - BootstrapConstants.PLATFORM_DESCRIPTOR_ARTIFACT_ID_SUFFIX.length()), - null, "pom", version); platformImports.computeIfAbsent(bomCoords, c -> new PlatformImport()).descriptorFound = true; platformBoms.add(bomCoords); @@ -88,10 +86,9 @@ public void addPlatformDescriptor(String groupId, String artifactId, String clas public void addPlatformProperties(String groupId, String artifactId, String classifier, String type, String version, Path propsPath) throws AppModelResolverException { - final ArtifactCoords bomCoords = new GACTV(groupId, + final ArtifactCoords bomCoords = ArtifactCoords.pom(groupId, artifactId.substring(0, artifactId.length() - BootstrapConstants.PLATFORM_PROPERTIES_ARTIFACT_ID_SUFFIX.length()), - null, "pom", version); platformImports.computeIfAbsent(bomCoords, c -> new PlatformImport()); importedPlatformBoms.computeIfAbsent(groupId, g -> new ArrayList<>()).add(bomCoords); diff --git a/independent-projects/bootstrap/app-model/src/main/java/io/quarkus/maven/dependency/ArtifactDependency.java b/independent-projects/bootstrap/app-model/src/main/java/io/quarkus/maven/dependency/ArtifactDependency.java index 60d95c55395dc..b61b84d075b45 100644 --- a/independent-projects/bootstrap/app-model/src/main/java/io/quarkus/maven/dependency/ArtifactDependency.java +++ b/independent-projects/bootstrap/app-model/src/main/java/io/quarkus/maven/dependency/ArtifactDependency.java @@ -65,16 +65,6 @@ public int getFlags() { return flags; } - public void setFlag(int flag) { - flags |= flag; - } - - public void clearFlag(int flag) { - if ((flags & flag) > 0) { - flags ^= flag; - } - } - @Override public int hashCode() { final int prime = 31; diff --git a/independent-projects/bootstrap/app-model/src/main/java/io/quarkus/maven/dependency/DependencyFlags.java b/independent-projects/bootstrap/app-model/src/main/java/io/quarkus/maven/dependency/DependencyFlags.java index a6b37da58205e..117a6d2730eb2 100644 --- a/independent-projects/bootstrap/app-model/src/main/java/io/quarkus/maven/dependency/DependencyFlags.java +++ b/independent-projects/bootstrap/app-model/src/main/java/io/quarkus/maven/dependency/DependencyFlags.java @@ -3,20 +3,25 @@ public interface DependencyFlags { /* @formatter:off */ - public static final int OPTIONAL = 0b00000000001; - public static final int DIRECT = 0b00000000010; - public static final int RUNTIME_CP = 0b00000000100; - public static final int DEPLOYMENT_CP = 0b00000001000; - public static final int RUNTIME_EXTENSION_ARTIFACT = 0b00000010000; - public static final int WORKSPACE_MODULE = 0b00000100000; - public static final int RELOADABLE = 0b00001000000; + public static final int OPTIONAL = 0b000000000001; + public static final int DIRECT = 0b000000000010; + public static final int RUNTIME_CP = 0b000000000100; + public static final int DEPLOYMENT_CP = 0b000000001000; + public static final int RUNTIME_EXTENSION_ARTIFACT = 0b000000010000; + public static final int WORKSPACE_MODULE = 0b000000100000; + public static final int RELOADABLE = 0b000001000000; // A top-level runtime extension artifact is either a direct // dependency or a first extension dependency on the branch // navigating from the root to leaves - public static final int TOP_LEVEL_RUNTIME_EXTENSION_ARTIFACT = 0b00010000000; - public static final int CLASSLOADER_PARENT_FIRST = 0b00100000000; - public static final int CLASSLOADER_RUNNER_PARENT_FIRST = 0b01000000000; - public static final int CLASSLOADER_LESSER_PRIORITY = 0b10000000000; + public static final int TOP_LEVEL_RUNTIME_EXTENSION_ARTIFACT = 0b000010000000; + public static final int CLASSLOADER_PARENT_FIRST = 0b000100000000; + public static final int CLASSLOADER_RUNNER_PARENT_FIRST = 0b001000000000; + public static final int CLASSLOADER_LESSER_PRIORITY = 0b010000000000; + // General purpose flag that could be re-used for various + // kinds of processing indicating that a dependency has been + // visited. This flag is meant to be cleared for all the nodes + // once the processing of the whole tree has completed. + public static final int VISITED = 0b100000000000; /* @formatter:on */ } diff --git a/independent-projects/bootstrap/app-model/src/main/java/io/quarkus/maven/dependency/ResolvedDependencyBuilder.java b/independent-projects/bootstrap/app-model/src/main/java/io/quarkus/maven/dependency/ResolvedDependencyBuilder.java index 8164ca247f743..d394460843a3a 100644 --- a/independent-projects/bootstrap/app-model/src/main/java/io/quarkus/maven/dependency/ResolvedDependencyBuilder.java +++ b/independent-projects/bootstrap/app-model/src/main/java/io/quarkus/maven/dependency/ResolvedDependencyBuilder.java @@ -13,6 +13,7 @@ public static ResolvedDependencyBuilder newInstance() { PathCollection resolvedPaths; WorkspaceModule workspaceModule; + private volatile ArtifactCoords coords; public PathCollection getResolvedPaths() { return resolvedPaths; @@ -40,6 +41,10 @@ public ResolvedDependencyBuilder setWorkspaceModule(WorkspaceModule projectModul return this; } + public ArtifactCoords getArtifactCoords() { + return coords == null ? coords = ArtifactCoords.of(groupId, artifactId, classifier, type, version) : coords; + } + @Override public ResolvedDependency build() { return new ResolvedArtifactDependency(this); diff --git a/independent-projects/bootstrap/maven-resolver/src/main/java/io/quarkus/bootstrap/resolver/maven/ApplicationDependencyTreeResolver.java b/independent-projects/bootstrap/maven-resolver/src/main/java/io/quarkus/bootstrap/resolver/maven/ApplicationDependencyTreeResolver.java index 3d773e12e7141..e9e8c6d3d2a48 100644 --- a/independent-projects/bootstrap/maven-resolver/src/main/java/io/quarkus/bootstrap/resolver/maven/ApplicationDependencyTreeResolver.java +++ b/independent-projects/bootstrap/maven-resolver/src/main/java/io/quarkus/bootstrap/resolver/maven/ApplicationDependencyTreeResolver.java @@ -13,7 +13,6 @@ import io.quarkus.maven.dependency.ArtifactCoords; import io.quarkus.maven.dependency.ArtifactKey; import io.quarkus.maven.dependency.DependencyFlags; -import io.quarkus.maven.dependency.GACTV; import io.quarkus.maven.dependency.ResolvedDependencyBuilder; import io.quarkus.paths.PathList; import io.quarkus.paths.PathTree; @@ -25,7 +24,6 @@ import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Collection; -import java.util.Collections; import java.util.Deque; import java.util.HashMap; import java.util.HashSet; @@ -160,7 +158,7 @@ public void resolve(CollectRequest collectRtDepsRequest) throws AppModelResolver visitRuntimeDependencies(root.getChildren()); - List activatedConditionalDeps = Collections.emptyList(); + List activatedConditionalDeps = List.of(); if (!conditionalDepsToProcess.isEmpty()) { activatedConditionalDeps = new ArrayList<>(); @@ -209,15 +207,16 @@ public void resolve(CollectRequest collectRtDepsRequest) throws AppModelResolver buildDepsVisitor.visit(root); if (!CONVERGED_TREE_ONLY && collectReloadableModules) { - final Set visited = new HashSet<>(); for (ResolvedDependencyBuilder db : appBuilder.getDependencies()) { - if (!db.isFlagSet(DependencyFlags.RELOADABLE)) { - clearReloadableFlag(db, visited); + if (db.isFlagSet(DependencyFlags.RELOADABLE | DependencyFlags.VISITED)) { + continue; } + clearReloadableFlag(db); } } for (ResolvedDependencyBuilder db : appBuilder.getDependencies()) { + db.clearFlag(DependencyFlags.VISITED); appBuilder.addDependency(db); } @@ -243,20 +242,19 @@ private void collectPlatformProperties() throws AppModelResolverException { appBuilder.setPlatformImports(platformReleases); } - private void clearReloadableFlag(ResolvedDependencyBuilder db, Set visited) { - final GACTV coords = new GACTV(db.getGroupId(), db.getArtifactId(), db.getClassifier(), db.getType(), db.getVersion()); - final Set deps = artifactDeps.get(coords); + private void clearReloadableFlag(ResolvedDependencyBuilder db) { + final Set deps = artifactDeps.get(db.getArtifactCoords()); if (deps == null || deps.isEmpty()) { return; } for (ArtifactKey key : deps) { final ResolvedDependencyBuilder dep = appBuilder.getDependency(key); - if (dep == null || !visited.add(key)) { + if (dep == null || dep.isFlagSet(DependencyFlags.VISITED)) { continue; } + dep.setFlags(DependencyFlags.VISITED); dep.clearFlag(DependencyFlags.RELOADABLE); - clearReloadableFlag(dep, visited); - visited.remove(key); + clearReloadableFlag(dep); } } @@ -418,7 +416,7 @@ private ExtensionDependency getExtensionDependencyOrNull(DependencyNode node, Ar } } } else { - exclusions = Collections.emptyList(); + exclusions = List.of(); } return new ExtensionDependency(extInfo, node, exclusions); }