From 79b41d4807516e4a830baa106654919629aa99e2 Mon Sep 17 00:00:00 2001 From: Alexey Loubyansky Date: Wed, 13 Oct 2021 13:36:54 +0200 Subject: [PATCH] Use test classes and resources dirs for artifacts with tests classifier (cherry picked from commit 4f60d2c2a597d9964909b4106fdf7a5a0ddc56ce) --- .../index/ApplicationArchiveBuildStep.java | 1 - .../DeploymentInjectingDependencyVisitor.java | 32 ++++++++++--------- 2 files changed, 17 insertions(+), 16 deletions(-) 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 0b95aa42ecd2c..091fd5fec4b91 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 @@ -167,7 +167,6 @@ public void addIndexDependencyPaths(List indexDependen GACTV.TYPE_JAR); final ResolvedDependency artifact = userMap.get(key); if (artifact == null) { - userMap.keySet().forEach(k -> System.out.println(" - " + k.getClass().getSimpleName() + " " + k)); throw new RuntimeException( "Could not resolve artifact " + key + " among the runtime dependencies of the application"); } diff --git a/independent-projects/bootstrap/maven-resolver/src/main/java/io/quarkus/bootstrap/resolver/maven/DeploymentInjectingDependencyVisitor.java b/independent-projects/bootstrap/maven-resolver/src/main/java/io/quarkus/bootstrap/resolver/maven/DeploymentInjectingDependencyVisitor.java index ac5e92d03ccda..c3788b7fcb12d 100644 --- a/independent-projects/bootstrap/maven-resolver/src/main/java/io/quarkus/bootstrap/resolver/maven/DeploymentInjectingDependencyVisitor.java +++ b/independent-projects/bootstrap/maven-resolver/src/main/java/io/quarkus/bootstrap/resolver/maven/DeploymentInjectingDependencyVisitor.java @@ -640,21 +640,12 @@ public static ResolvedDependencyBuilder toAppArtifact(Artifact artifact, Workspa public static PathCollection getResolvedPaths(Artifact artifact, WorkspaceModule module, boolean preferWorkspacePaths) { if (preferWorkspacePaths && module != null) { final PathList.Builder pathBuilder = PathList.builder(); - for (ProcessedSources src : module.getMainSources()) { - if (src.getDestinationDir().exists()) { - final Path p = src.getDestinationDir().toPath(); - if (!pathBuilder.contains(p)) { - pathBuilder.add(p); - } - } - } - for (ProcessedSources src : module.getMainResources()) { - if (src.getDestinationDir().exists()) { - final Path p = src.getDestinationDir().toPath(); - if (!pathBuilder.contains(p)) { - pathBuilder.add(p); - } - } + if ("tests".equals(artifact.getClassifier())) { + collectResolvedPaths(pathBuilder, module.getTestSources()); + collectResolvedPaths(pathBuilder, module.getTestResources()); + } else { + collectResolvedPaths(pathBuilder, module.getMainSources()); + collectResolvedPaths(pathBuilder, module.getMainResources()); } if (!pathBuilder.isEmpty()) { return pathBuilder.build(); @@ -663,6 +654,17 @@ public static PathCollection getResolvedPaths(Artifact artifact, WorkspaceModule return artifact.getFile() == null ? PathList.empty() : PathList.of(artifact.getFile().toPath()); } + private static void collectResolvedPaths(final PathList.Builder pathBuilder, Collection srcs) { + for (ProcessedSources src : srcs) { + if (src.getDestinationDir().exists()) { + final Path p = src.getDestinationDir().toPath(); + if (!pathBuilder.contains(p)) { + pathBuilder.add(p); + } + } + } + } + private static String toGactv(Artifact a) { return a.getGroupId() + ":" + a.getArtifactId() + ":" + a.getClassifier() + ":" + a.getExtension() + ":" + a.getVersion();