diff --git a/maven/impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/MavenWorkingSessionImpl.java b/maven/impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/MavenWorkingSessionImpl.java index bacd99f1..696371f1 100644 --- a/maven/impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/MavenWorkingSessionImpl.java +++ b/maven/impl-maven/src/main/java/org/jboss/shrinkwrap/resolver/impl/maven/MavenWorkingSessionImpl.java @@ -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<>(); @@ -242,7 +244,7 @@ private static String toVersionedArtifact(String artifactId, String version) { private void processAdditionalDependencies(Path projectLocalRepository, String groupId, String artifactId, String version, - Set additionalDependencies) { + Set 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(); @@ -250,6 +252,8 @@ private void processAdditionalDependencies(Path projectLocalRepository, String g // 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 transitiveDependencies = loadPomFromFile(consumerPom).getParsedPomFile().getDependencies(); @@ -305,9 +309,14 @@ public Collection resolveDependencies(final MavenResoluti resolveFromRepository = depsForResolution; } else { Set 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,