Search in sources :

Example 1 with ResolutionResult

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;
}
Also used : ResolutionResult(com.itemis.maven.aether.ArtifactResolver.ResolutionResult) ArtifactCoordinates(com.itemis.maven.aether.ArtifactCoordinates)

Example 2 with ResolutionResult

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);
}
Also used : MavenProject(org.apache.maven.project.MavenProject) ResolutionResult(com.itemis.maven.aether.ArtifactResolver.ResolutionResult) ArtifactCoordinates(com.itemis.maven.aether.ArtifactCoordinates) ProjectToString(com.itemis.maven.plugins.unleash.util.functions.ProjectToString)

Aggregations

ArtifactCoordinates (com.itemis.maven.aether.ArtifactCoordinates)2 ResolutionResult (com.itemis.maven.aether.ArtifactResolver.ResolutionResult)2 ProjectToString (com.itemis.maven.plugins.unleash.util.functions.ProjectToString)1 MavenProject (org.apache.maven.project.MavenProject)1