Skip to content

Commit

Permalink
Merge pull request #217 from ascopes/bugfix/GH-172
Browse files Browse the repository at this point in the history
GH-172: Fix dependency conflict resolution
  • Loading branch information
ascopes authored May 12, 2024
2 parents 2d0cea3 + 176367b commit 6187513
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 22 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ public boolean generate(GenerationRequest request) throws ResolutionException, I
final var protocPath = discoverProtocPath(request);

final var resolvedPlugins = discoverPlugins(request);
final var importPaths = discoverImportPaths(request);
final var sourcePaths = discoverCompilableSources(request);
final var importPaths = discoverImportPaths(sourcePaths, request);

if (sourcePaths.isEmpty()) {
if (request.isFailOnMissingSources()) {
Expand Down Expand Up @@ -173,17 +173,24 @@ private Collection<ResolvedProtocPlugin> discoverPlugins(
}

private Collection<ProtoFileListing> discoverImportPaths(
Collection<ProtoFileListing> sourcePathListings,
GenerationRequest request
) throws IOException, ResolutionException {
var artifacts = concat(request.getImportDependencies(), request.getSourceDependencies());
var artifactPaths = artifactPathResolver.resolveDependencies(
artifacts,
request.getImportDependencies(),
request.getDependencyResolutionDepth(),
!request.isIgnoreProjectDependencies()
);
var importPaths = request.getImportPaths();

return protoListingResolver.createProtoFileListings(concat(artifactPaths, importPaths));
var importPathListings = protoListingResolver
.createProtoFileListings(concat(request.getImportPaths(), artifactPaths));

// Use the source paths here as well and use them first to give them precedence. This works
// around GH-172 where we can end up with different versions on the import and source paths
// depending on how dependency conflicts arise.
return Stream.concat(sourcePathListings.stream(), importPathListings.stream())
.distinct()
.collect(Collectors.toList());
}

private Collection<ProtoFileListing> discoverCompilableSources(
Expand Down

0 comments on commit 6187513

Please sign in to comment.