Skip to content

Commit

Permalink
GH-172: Fix dependency conflict resolution
Browse files Browse the repository at this point in the history
This fixes the outstanding issue at GH-172 that creates an
issue when mixing project and plugin-based dependencies that
could be on different versions transitively. This only now
works because of GH-215 fixing the way dependencies get
resolved... we now resolve both project and plugin
dependencies at the exact same time, which allows for some
version resolution and conflict fixes to be performed
by Eclipse Aether.
  • Loading branch information
ascopes committed May 12, 2024
1 parent 275b715 commit 176367b
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 176367b

Please sign in to comment.