Skip to content

Commit

Permalink
bugfix:x
Browse files Browse the repository at this point in the history
  • Loading branch information
lprimak committed Dec 21, 2024
1 parent 7d37749 commit 8d2e476
Showing 1 changed file with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ public class MavenWorkingSessionImpl extends ConfigurableMavenWorkingSessionImpl

private boolean useMavenCentralRepository = true;

private static class InvalidLocalReporitoryException extends RuntimeException { }

public MavenWorkingSessionImpl() {
super();
this.remoteRepositories = new ArrayList<>();
Expand Down Expand Up @@ -242,14 +244,16 @@ private static String toVersionedArtifact(String artifactId, String version) {

private void processAdditionalDependencies(Path projectLocalRepository, String groupId,
String artifactId, String version,
Set<MavenDependency> additionalDependencies) {
Set<MavenDependency> additionalDependencies) throws InvalidLocalReporitoryException {
Path directory = projectLocalRepository.resolve(groupId).resolve(artifactId).resolve(version);
File consumerPom = directory.resolve(toVersionedArtifact(artifactId, version) + "-consumer.pom").toFile();
File buildPom = directory.resolve(toVersionedArtifact(artifactId, version) + "-build.pom").toFile();
if (!consumerPom.exists() && buildPom.exists()) {
// in some versions of maven, consumer pom is just generated with ".pom" extension
// in that case, build pom will also exist
consumerPom = directory.resolve(toVersionedArtifact(artifactId, version) + ".pom").toFile();
} else {
throw new InvalidLocalReporitoryException();
}
if (consumerPom.exists()) {
Set<MavenDependency> transitiveDependencies = loadPomFromFile(consumerPom).getParsedPomFile().getDependencies();
Expand Down Expand Up @@ -305,9 +309,14 @@ public Collection<MavenResolvedArtifact> resolveDependencies(final MavenResoluti
resolveFromRepository = depsForResolution;
} else {
Set<MavenDependency> allDependencies = new LinkedHashSet<>(depsForResolution);
projectLocalDependencies = resolveProjectLocal(depsForResolution, allDependencies);
resolveFromRepository = filterFromLocal(
allDependencies.stream().collect(Collectors.toList()), projectLocalDependencies);
try {
projectLocalDependencies = resolveProjectLocal(depsForResolution, allDependencies);
resolveFromRepository = filterFromLocal(
allDependencies.stream().collect(Collectors.toList()), projectLocalDependencies);
} catch (InvalidLocalReporitoryException e) {
log.log(Level.FINE, "Invalid local repository structure, skipping project-local resolution");
resolveFromRepository = depsForResolution;
}
}

final CollectRequest request = new CollectRequest(MavenConverter.asDependencies(resolveFromRepository,
Expand Down

0 comments on commit 8d2e476

Please sign in to comment.