Skip to content

Commit

Permalink
Use test classes and resources dirs for artifacts with tests classifier
Browse files Browse the repository at this point in the history
(cherry picked from commit 4f60d2c)
  • Loading branch information
aloubyansky committed Oct 18, 2021
1 parent f684912 commit 79b41d4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ public void addIndexDependencyPaths(List<IndexDependencyBuildItem> 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");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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<ProcessedSources> 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();
Expand Down

0 comments on commit 79b41d4

Please sign in to comment.