Search in sources :

Example 6 with ArtifactCoordinates

use of com.itemis.maven.aether.ArtifactCoordinates 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 7 with ArtifactCoordinates

use of com.itemis.maven.aether.ArtifactCoordinates in project unleash-maven-plugin by shillner.

the class CheckDependencyVersions method getSnapshotsFromManagement.

private Set<ArtifactCoordinates> getSnapshotsFromManagement(MavenProject project, PomPropertyResolver propertyResolver) {
    this.log.debug("\t\tChecking managed dependencies");
    DependencyManagement dependencyManagement = project.getDependencyManagement();
    if (dependencyManagement != null) {
        Collection<Dependency> snapshots = Collections2.filter(dependencyManagement.getDependencies(), new IsSnapshotDependency(propertyResolver));
        HashSet<ArtifactCoordinates> snapshotDependencies = Sets.newHashSet(Collections2.transform(snapshots, DependencyToCoordinates.INSTANCE));
        filterMultiModuleDependencies(snapshotDependencies);
        return snapshotDependencies;
    }
    return Collections.emptySet();
}
Also used : IsSnapshotDependency(com.itemis.maven.plugins.unleash.util.predicates.IsSnapshotDependency) ArtifactCoordinates(com.itemis.maven.aether.ArtifactCoordinates) Dependency(org.apache.maven.model.Dependency) IsSnapshotDependency(com.itemis.maven.plugins.unleash.util.predicates.IsSnapshotDependency) DependencyManagement(org.apache.maven.model.DependencyManagement)

Example 8 with ArtifactCoordinates

use of com.itemis.maven.aether.ArtifactCoordinates in project unleash-maven-plugin by shillner.

the class CheckDependencyVersions method getSnapshotsFromAllProfiles.

private Set<ArtifactCoordinates> getSnapshotsFromAllProfiles(MavenProject project, PomPropertyResolver propertyResolver) {
    Set<ArtifactCoordinates> snapshots = Sets.newHashSet();
    List<Profile> profiles = project.getModel().getProfiles();
    if (profiles != null) {
        for (Profile profile : profiles) {
            snapshots.addAll(getSnapshotsFromManagement(profile, propertyResolver));
            snapshots.addAll(getSnapshots(profile, propertyResolver));
        }
    }
    filterMultiModuleDependencies(snapshots);
    return snapshots;
}
Also used : ArtifactCoordinates(com.itemis.maven.aether.ArtifactCoordinates) Profile(org.apache.maven.model.Profile)

Example 9 with ArtifactCoordinates

use of com.itemis.maven.aether.ArtifactCoordinates in project unleash-maven-plugin by shillner.

the class CheckDependencyVersions method getSnapshots.

private Set<ArtifactCoordinates> getSnapshots(MavenProject project, PomPropertyResolver propertyResolver) {
    this.log.debug("\t\tChecking direct dependencies");
    Collection<Dependency> snapshots = Collections2.filter(project.getDependencies(), new IsSnapshotDependency(propertyResolver));
    HashSet<ArtifactCoordinates> snapshotDependencies = Sets.newHashSet(Collections2.transform(snapshots, DependencyToCoordinates.INSTANCE));
    filterMultiModuleDependencies(snapshotDependencies);
    return snapshotDependencies;
}
Also used : IsSnapshotDependency(com.itemis.maven.plugins.unleash.util.predicates.IsSnapshotDependency) ArtifactCoordinates(com.itemis.maven.aether.ArtifactCoordinates) Dependency(org.apache.maven.model.Dependency) IsSnapshotDependency(com.itemis.maven.plugins.unleash.util.predicates.IsSnapshotDependency)

Example 10 with ArtifactCoordinates

use of com.itemis.maven.aether.ArtifactCoordinates in project unleash-maven-plugin by shillner.

the class CheckParentVersions method execute.

@Override
public void execute(ExecutionContext context) throws MojoExecutionException, MojoFailureException {
    this.log.info("Checking that the project modules do not reference SNAPSHOT parents that are not scheduled for release.");
    Map<String, String> snapshotParentReferences = Maps.newHashMap();
    for (MavenProject p : this.reactorProjects) {
        MavenProject parent = p.getParent();
        if (parent != null && IsSnapshotProject.INSTANCE.apply(parent)) {
            Map<ReleasePhase, ArtifactCoordinates> coordinatesByPhase = this.metadata.getArtifactCoordinatesByPhase(parent.getGroupId(), parent.getArtifactId());
            ArtifactCoordinates coordinates = coordinatesByPhase.get(ReleasePhase.PRE_RELEASE);
            if (coordinates != null && Objects.equal(parent.getVersion(), coordinates.getVersion())) {
                this.log.debug("\tModule '" + ProjectToString.INSTANCE.apply(p) + "' references SNAPSHOT parent '" + ProjectToString.INSTANCE.apply(parent) + "' which is also scheduled for release.");
            } else {
                snapshotParentReferences.put(ProjectToString.INSTANCE.apply(p), ProjectToString.INSTANCE.apply(parent));
            }
        }
    }
    if (!snapshotParentReferences.isEmpty()) {
        this.log.error("\tThe following modules have references to SNAPSHOT parents that are not scheduled for release:");
        for (String projectCoordinates : snapshotParentReferences.keySet()) {
            this.log.error("\t\t" + projectCoordinates + " => " + snapshotParentReferences.get(projectCoordinates));
        }
        throw new MojoFailureException("There are modules that reference SNAPSHOT parents which are not scheduled for release!");
    }
}
Also used : MavenProject(org.apache.maven.project.MavenProject) MojoFailureException(org.apache.maven.plugin.MojoFailureException) ReleasePhase(com.itemis.maven.plugins.unleash.ReleasePhase) ArtifactCoordinates(com.itemis.maven.aether.ArtifactCoordinates) ProjectToString(com.itemis.maven.plugins.unleash.util.functions.ProjectToString)

Aggregations

ArtifactCoordinates (com.itemis.maven.aether.ArtifactCoordinates)29 ProjectToString (com.itemis.maven.plugins.unleash.util.functions.ProjectToString)12 MavenProject (org.apache.maven.project.MavenProject)11 ReleasePhase (com.itemis.maven.plugins.unleash.ReleasePhase)9 PomPropertyResolver (com.itemis.maven.plugins.unleash.util.PomPropertyResolver)6 IsSnapshotDependency (com.itemis.maven.plugins.unleash.util.predicates.IsSnapshotDependency)6 Dependency (org.apache.maven.model.Dependency)6 Plugin (org.apache.maven.model.Plugin)4 MojoFailureException (org.apache.maven.plugin.MojoFailureException)4 Profile (org.apache.maven.model.Profile)3 ResolutionResult (com.itemis.maven.aether.ArtifactResolver.ResolutionResult)2 IOException (java.io.IOException)2 Build (org.apache.maven.model.Build)2 BuildBase (org.apache.maven.model.BuildBase)2 Parent (org.apache.maven.model.Parent)2 PluginManagement (org.apache.maven.model.PluginManagement)2 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)2 VersionsEngine (org.eclipse.tycho.versions.engine.VersionsEngine)2 Document (org.w3c.dom.Document)2 HashMultimap (com.google.common.collect.HashMultimap)1