diff --git a/core/deployment/src/main/java/io/quarkus/deployment/ApplicationArchive.java b/core/deployment/src/main/java/io/quarkus/deployment/ApplicationArchive.java index 8d4ade410d1cb..14cdfaa81eb75 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/ApplicationArchive.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/ApplicationArchive.java @@ -9,6 +9,7 @@ import io.quarkus.bootstrap.model.AppArtifactKey; import io.quarkus.bootstrap.model.PathsCollection; import io.quarkus.maven.dependency.ArtifactKey; +import io.quarkus.maven.dependency.ResolvedDependency; import io.quarkus.paths.OpenPathTree; import io.quarkus.paths.PathCollection; @@ -83,6 +84,12 @@ public interface ApplicationArchive { */ ArtifactKey getKey(); + /** + * + * @return the resolved artifact or {@code null} if not available + */ + ResolvedDependency getResolvedDependency(); + /** * Applies a function to the content tree of the archive. * diff --git a/core/deployment/src/main/java/io/quarkus/deployment/ApplicationArchiveImpl.java b/core/deployment/src/main/java/io/quarkus/deployment/ApplicationArchiveImpl.java index ad23665c4feb0..252e59aeaf3db 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/ApplicationArchiveImpl.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/ApplicationArchiveImpl.java @@ -12,6 +12,7 @@ import io.quarkus.bootstrap.model.PathsCollection; import io.quarkus.builder.item.MultiBuildItem; import io.quarkus.maven.dependency.ArtifactKey; +import io.quarkus.maven.dependency.ResolvedDependency; import io.quarkus.paths.OpenPathTree; import io.quarkus.paths.PathCollection; import io.quarkus.paths.PathList; @@ -20,12 +21,12 @@ public final class ApplicationArchiveImpl extends MultiBuildItem implements Appl private final IndexView indexView; private final OpenPathTree openTree; - private final ArtifactKey artifactKey; + private final ResolvedDependency resolvedDependency; - public ApplicationArchiveImpl(IndexView indexView, OpenPathTree openTree, ArtifactKey artifactKey) { + public ApplicationArchiveImpl(IndexView indexView, OpenPathTree openTree, ResolvedDependency resolvedDependency) { this.indexView = indexView; this.openTree = openTree; - this.artifactKey = artifactKey; + this.resolvedDependency = resolvedDependency; } @Override @@ -68,14 +69,22 @@ public PathCollection getResolvedPaths() { * @return archive key */ public AppArtifactKey getArtifactKey() { - return artifactKey == null ? null - : new AppArtifactKey(artifactKey.getGroupId(), artifactKey.getArtifactId(), artifactKey.getClassifier(), - artifactKey.getType()); + if (resolvedDependency == null) { + return null; + } + ArtifactKey artifactKey = resolvedDependency.getKey(); + return new AppArtifactKey(artifactKey.getGroupId(), artifactKey.getArtifactId(), artifactKey.getClassifier(), + artifactKey.getType()); } @Override public ArtifactKey getKey() { - return artifactKey; + return resolvedDependency != null ? resolvedDependency.getKey() : null; + } + + @Override + public ResolvedDependency getResolvedDependency() { + return resolvedDependency; } @Override diff --git a/core/deployment/src/main/java/io/quarkus/deployment/index/ApplicationArchiveBuildStep.java b/core/deployment/src/main/java/io/quarkus/deployment/index/ApplicationArchiveBuildStep.java index 8b1a926caeb30..285fa0051a1aa 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/index/ApplicationArchiveBuildStep.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/index/ApplicationArchiveBuildStep.java @@ -120,7 +120,7 @@ ApplicationArchivesBuildItem build( return new ApplicationArchivesBuildItem( new ApplicationArchiveImpl(appindex.getIndex(), tree, - curateOutcomeBuildItem.getApplicationModel().getAppArtifact().getKey()), + curateOutcomeBuildItem.getApplicationModel().getAppArtifact()), applicationArchives); } @@ -187,7 +187,7 @@ private void addIndexDependencyPaths(List indexDepende && !root.getResolvedPaths().contains(path) && indexedDeps.add(path)) { try { - appArchives.add(createApplicationArchive(buildCloseables, indexCache, path, dep.getKey(), + appArchives.add(createApplicationArchive(buildCloseables, indexCache, path, dep, removedResources)); } catch (IOException e) { throw new UncheckedIOException(e); @@ -199,10 +199,11 @@ private void addIndexDependencyPaths(List indexDepende } private static ApplicationArchive createApplicationArchive(QuarkusBuildCloseablesBuildItem buildCloseables, - IndexCache indexCache, Path dep, ArtifactKey artifactKey, Map> removedResources) + IndexCache indexCache, Path dep, ResolvedDependency resolvedDependency, + Map> removedResources) throws IOException { LOGGER.debugf("Indexing dependency: %s", dep); - final Set removed = removedResources.get(artifactKey); + final Set removed = resolvedDependency != null ? removedResources.get(resolvedDependency.getKey()) : null; final OpenPathTree openTree; final IndexView index; if (Files.isDirectory(dep)) { @@ -212,7 +213,7 @@ private static ApplicationArchive createApplicationArchive(QuarkusBuildCloseable openTree = buildCloseables.add(PathTree.ofArchive(dep).open()); index = handleJarPath(dep, indexCache, removed); } - return new ApplicationArchiveImpl(index, openTree, artifactKey); + return new ApplicationArchiveImpl(index, openTree, resolvedDependency); } private static void addMarkerFilePaths(Set applicationArchiveMarkers, @@ -253,7 +254,7 @@ private static void addMarkerFilePaths(Set applicationArchiveMarkers, } indexCache.cache.put(rootPath, index); } - appArchives.add(new ApplicationArchiveImpl(index, tree, dependencyKey)); + appArchives.add(new ApplicationArchiveImpl(index, tree, cpe.getResolvedDependency())); return null; } @@ -267,7 +268,7 @@ private static void addMarkerFilePaths(Set applicationArchiveMarkers, } catch (IOException e) { throw new UncheckedIOException(e); } - return new ApplicationArchiveImpl(index, tree, dependencyKey); + return new ApplicationArchiveImpl(index, tree, cpe.getResolvedDependency()); }); if (archive != null) { appArchives.add(archive); diff --git a/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/BeanArchiveProcessor.java b/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/BeanArchiveProcessor.java index 7eca4e3a9a281..21bb7fa92bb52 100644 --- a/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/BeanArchiveProcessor.java +++ b/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/BeanArchiveProcessor.java @@ -229,7 +229,8 @@ private boolean possiblyBeanArchive(ApplicationArchive archive, LOGGER.warnf("Detected bean archive with bean discovery mode of 'all', " + "this is not portable in CDI Lite and is treated as 'annotated' in Quarkus! " + "Path to beans.xml: %s", - archive.getKey() != null ? archive.getKey().toGacString() + ":" + pathVisit.getPath() + archive.getResolvedDependency() != null + ? archive.getResolvedDependency().toCompactCoords() + ":" + pathVisit.getPath() : pathVisit.getPath()); } } diff --git a/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/SplitPackageProcessor.java b/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/SplitPackageProcessor.java index 0f2db510602a1..f68b4256900b6 100644 --- a/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/SplitPackageProcessor.java +++ b/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/SplitPackageProcessor.java @@ -21,7 +21,7 @@ import io.quarkus.deployment.annotations.BuildProducer; import io.quarkus.deployment.annotations.BuildStep; import io.quarkus.deployment.builditem.ApplicationArchivesBuildItem; -import io.quarkus.maven.dependency.ArtifactKey; +import io.quarkus.maven.dependency.ResolvedDependency; /** * Split package (same package coming from multiple app archives) is considered a bad practice and @@ -105,9 +105,9 @@ void splitPackageDetection(ApplicationArchivesBuildItem archivesBuildItem, Set splitPackages = new TreeSet<>(); while (iterator.hasNext()) { final ApplicationArchive next = iterator.next(); - final ArtifactKey a = next.getKey(); + ResolvedDependency dep = next.getResolvedDependency(); // can be null for instance in test mode where all application classes go under target/classes - if (a == null) { + if (dep == null) { if (archivesBuildItem.getRootArchive().equals(next)) { // the archive we found is a root archive, e.g. application classes splitPackages.add("application classes"); @@ -122,8 +122,8 @@ void splitPackageDetection(ApplicationArchivesBuildItem archivesBuildItem, } } } else { - // Generates an app archive information in form of groupId:artifactId:classifier:type - splitPackages.add(a.toString()); + // Generates an app archive information in form of groupId:artifactId[:classifier][:type]:version + splitPackages.add(dep.toCompactCoords()); } } splitPackagesWarning.append(splitPackages.stream().collect(Collectors.joining(", ", "[", "]"))); diff --git a/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/app/CuratedApplication.java b/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/app/CuratedApplication.java index da469231ba265..db443557934e4 100644 --- a/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/app/CuratedApplication.java +++ b/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/app/CuratedApplication.java @@ -445,8 +445,8 @@ static class ClassFilteredBannedElement implements ClassPathElement { } @Override - public ArtifactKey getDependencyKey() { - return delegate.getDependencyKey(); + public ResolvedDependency getResolvedDependency() { + return delegate.getResolvedDependency(); } @Override diff --git a/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/classloading/ClassPathElement.java b/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/classloading/ClassPathElement.java index eefce68aa5f66..53723350b5476 100644 --- a/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/classloading/ClassPathElement.java +++ b/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/classloading/ClassPathElement.java @@ -28,6 +28,18 @@ public interface ClassPathElement extends Closeable { * this element does not represent any Maven artifact */ default ArtifactKey getDependencyKey() { + ResolvedDependency resolvedDependency = getResolvedDependency(); + return resolvedDependency != null ? resolvedDependency.getKey() : null; + } + + /** + * If this classpath element represents a Maven artifact, the method will return it, + * otherwise - null. + * + * @return the Maven artifact this classpath element represents or null, in case + * this element does not represent any Maven artifact + */ + default ResolvedDependency getResolvedDependency() { return null; } @@ -85,7 +97,7 @@ static ClassPathElement fromPath(Path path, boolean runtime) { } static ClassPathElement fromDependency(ResolvedDependency dep) { - return new PathTreeClassPathElement(dep.getContentTree(), dep.isRuntimeCp(), dep.getKey()); + return new PathTreeClassPathElement(dep.getContentTree(), dep.isRuntimeCp(), dep); } static ClassPathElement EMPTY = new ClassPathElement() { diff --git a/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/classloading/FilteredClassPathElement.java b/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/classloading/FilteredClassPathElement.java index a72fcee9259ff..3e6f9a897d277 100644 --- a/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/classloading/FilteredClassPathElement.java +++ b/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/classloading/FilteredClassPathElement.java @@ -9,7 +9,7 @@ import java.util.function.Function; import java.util.jar.Manifest; -import io.quarkus.maven.dependency.ArtifactKey; +import io.quarkus.maven.dependency.ResolvedDependency; import io.quarkus.paths.OpenPathTree; public class FilteredClassPathElement implements ClassPathElement { @@ -23,8 +23,8 @@ public FilteredClassPathElement(ClassPathElement delegate, Collection re } @Override - public ArtifactKey getDependencyKey() { - return delegate.getDependencyKey(); + public ResolvedDependency getResolvedDependency() { + return delegate.getResolvedDependency(); } @Override diff --git a/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/classloading/PathTreeClassPathElement.java b/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/classloading/PathTreeClassPathElement.java index 6f05de1707e71..17dab87f95563 100644 --- a/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/classloading/PathTreeClassPathElement.java +++ b/independent-projects/bootstrap/core/src/main/java/io/quarkus/bootstrap/classloading/PathTreeClassPathElement.java @@ -23,7 +23,7 @@ import org.jboss.logging.Logger; -import io.quarkus.maven.dependency.ArtifactKey; +import io.quarkus.maven.dependency.ResolvedDependency; import io.quarkus.paths.OpenPathTree; import io.quarkus.paths.PathTree; import io.quarkus.paths.PathVisit; @@ -36,18 +36,18 @@ public class PathTreeClassPathElement extends AbstractClassPathElement { private final ReadWriteLock lock; private final OpenPathTree pathTree; private final boolean runtime; - private final ArtifactKey dependencyKey; + private final ResolvedDependency resolvedDependency; private volatile Set resources; public PathTreeClassPathElement(PathTree pathTree, boolean runtime) { this(pathTree, runtime, null); } - public PathTreeClassPathElement(PathTree pathTree, boolean runtime, ArtifactKey dependencyKey) { + public PathTreeClassPathElement(PathTree pathTree, boolean runtime, ResolvedDependency resolvedDependency) { this.pathTree = Objects.requireNonNull(pathTree, "Path tree is null").open(); this.lock = new ReentrantReadWriteLock(); this.runtime = runtime; - this.dependencyKey = dependencyKey; + this.resolvedDependency = resolvedDependency; } @Override @@ -56,8 +56,8 @@ public boolean isRuntime() { } @Override - public ArtifactKey getDependencyKey() { - return dependencyKey; + public ResolvedDependency getResolvedDependency() { + return resolvedDependency; } @Override