use of com.itemis.maven.aether.ArtifactResolver.ResolutionResult in project unleash-maven-plugin by shillner.
the class CheckAether method resolve.
private Optional<ResolutionResult> resolve(String groupId, String artifactId, String version, boolean remoteOnly) {
ArtifactCoordinates coordinates = new ArtifactCoordinates(groupId, artifactId, version, PomUtil.ARTIFACT_TYPE_POM);
Optional<ResolutionResult> result = this.artifactResolver.resolve(coordinates, remoteOnly);
return result;
}
use of com.itemis.maven.aether.ArtifactResolver.ResolutionResult in project unleash-maven-plugin by shillner.
the class CheckAether method execute.
@Override
public void execute(ExecutionContext context) throws MojoExecutionException, MojoFailureException {
this.log.info("Checking aether for already released artifacts of modules that are scheduled for release.");
this.log.debug("\t=> If any of the modules had already been released with the corresponding release version, the release build will fail fast at this point.");
Collection<MavenProject> snapshotProjects = Collections2.filter(this.reactorProjects, IsSnapshotProject.INSTANCE);
Map<ArtifactCoordinates, String> remotelyReleasedProjects = Maps.newHashMap();
List<ArtifactCoordinates> locallyReleasedProjects = Lists.newArrayList();
for (MavenProject p : snapshotProjects) {
this.log.debug("\tChecking module '" + ProjectToString.INSTANCE.apply(p) + "'");
ArtifactCoordinates calculatedCoordinates = this.metadata.getArtifactCoordinatesByPhase(p.getGroupId(), p.getArtifactId()).get(ReleasePhase.RELEASE);
Optional<ResolutionResult> remoteResolvedArtifact = resolve(calculatedCoordinates.getGroupId(), calculatedCoordinates.getArtifactId(), calculatedCoordinates.getVersion(), true);
if (remoteResolvedArtifact.isPresent()) {
remotelyReleasedProjects.put(calculatedCoordinates, remoteResolvedArtifact.get().getRepositoryId());
} else if (resolve(calculatedCoordinates.getGroupId(), calculatedCoordinates.getArtifactId(), calculatedCoordinates.getVersion(), false).isPresent()) {
locallyReleasedProjects.add(calculatedCoordinates);
}
}
handleRemoteReleases(remotelyReleasedProjects);
handleLocalReleases(locallyReleasedProjects);
}
Aggregations