Skip to content

Commit

Permalink
Ignore IndexDependencyBuildItem for missing dependencies
Browse files Browse the repository at this point in the history
(cherry picked from commit f79f2c2)
  • Loading branch information
aloubyansky authored and gsmet committed May 31, 2023
1 parent 6212981 commit c716678
Showing 1 changed file with 17 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
Expand Down Expand Up @@ -168,35 +167,28 @@ private void addIndexDependencyPaths(List<IndexDependencyBuildItem> indexDepende
if (indexDependencyBuildItems.isEmpty()) {
return;
}
final Collection<ResolvedDependency> userDeps = curateOutcomeBuildItem.getApplicationModel()
.getRuntimeDependencies();
final Map<ArtifactKey, ResolvedDependency> userMap = new HashMap<>(userDeps.size());
for (ResolvedDependency dep : userDeps) {
userMap.put(dep.getKey(), dep);
final Set<ArtifactKey> indexDependencyKeys = new HashSet<>(indexDependencyBuildItems.size());
for (IndexDependencyBuildItem indexDependencyBuildItem : indexDependencyBuildItems) {
indexDependencyKeys.add(ArtifactKey.of(indexDependencyBuildItem.getGroupId(),
indexDependencyBuildItem.getArtifactId(),
indexDependencyBuildItem.getClassifier(),
ArtifactCoords.TYPE_JAR));
}
try {
for (IndexDependencyBuildItem indexDependencyBuildItem : indexDependencyBuildItems) {
final ArtifactKey key = ArtifactKey.of(indexDependencyBuildItem.getGroupId(),
indexDependencyBuildItem.getArtifactId(),
indexDependencyBuildItem.getClassifier(),
ArtifactCoords.TYPE_JAR);
final ResolvedDependency artifact = userMap.get(key);
if (artifact == null) {
throw new RuntimeException(
"Additional dependency to be indexed (added via 'quarkus.index-dependency' configuration) "
+ key
+ " could not be found among the runtime dependencies of the application. Either remove the indexing configuration or add the dependency to your build system.");
}
for (Path path : artifact.getContentTree().getRoots()) {
if (!root.isExcludedFromIndexing(path) && !root.getResolvedPaths().contains(path)
for (ResolvedDependency dep : curateOutcomeBuildItem.getApplicationModel().getDependencies()) {
if (dep.isRuntimeCp() && indexDependencyKeys.contains(dep.getKey())) {
for (Path path : dep.getContentTree().getRoots()) {
if (!root.isExcludedFromIndexing(path)
&& !root.getResolvedPaths().contains(path)
&& indexedDeps.add(path)) {
appArchives.add(createApplicationArchive(buildCloseables, indexCache, path, key,
removedResources));
try {
appArchives.add(createApplicationArchive(buildCloseables, indexCache, path, dep.getKey(),
removedResources));
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
}
}
} catch (IOException e) {
throw new RuntimeException(e);
}
}

Expand Down

0 comments on commit c716678

Please sign in to comment.