Search in sources :

Example 1 with ArtifactCoordinates

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

the class CheckPluginDependencyVersions method getSnapshots.

private Multimap<ArtifactCoordinates, ArtifactCoordinates> getSnapshots(MavenProject project, PomPropertyResolver propertyResolver) {
    this.log.debug("\t\tChecking direct plugin references");
    Multimap<ArtifactCoordinates, ArtifactCoordinates> result = HashMultimap.create();
    Build build = project.getBuild();
    if (build != null) {
        for (Plugin plugin : build.getPlugins()) {
            Collection<Dependency> snapshots = Collections2.filter(plugin.getDependencies(), new IsSnapshotDependency(propertyResolver));
            if (!snapshots.isEmpty()) {
                result.putAll(PluginToCoordinates.INSTANCE.apply(plugin), Collections2.transform(snapshots, DependencyToCoordinates.INSTANCE));
            }
        }
    }
    return result;
}
Also used : Build(org.apache.maven.model.Build) 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) Plugin(org.apache.maven.model.Plugin)

Example 2 with ArtifactCoordinates

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

the class CheckPluginDependencyVersions method execute.

@Override
public void execute(ExecutionContext context) throws MojoExecutionException, MojoFailureException {
    this.log.info("Checking that none of the reactor project's plugins contain SNAPSHOT dependencies.");
    Map<MavenProject, PomPropertyResolver> propertyResolvers = Maps.newHashMapWithExpectedSize(this.reactorProjects.size());
    Map<MavenProject, Multimap<ArtifactCoordinates, ArtifactCoordinates>> snapshotsByProjectAndPlugin = Maps.newHashMapWithExpectedSize(this.reactorProjects.size());
    boolean hasSnapshots = false;
    for (MavenProject project : this.reactorProjects) {
        this.log.debug("\tChecking plugin dependencies of reactor project '" + ProjectToString.INSTANCE.apply(project) + "':");
        PomPropertyResolver propertyResolver = new PomPropertyResolver(project, this.settings, this.profiles, this.releaseArgs);
        propertyResolvers.put(project, propertyResolver);
        Multimap<ArtifactCoordinates, ArtifactCoordinates> snapshots = HashMultimap.create();
        snapshots.putAll(getSnapshotsFromManagement(project, propertyResolver));
        snapshots.putAll(getSnapshots(project, propertyResolver));
        snapshots.putAll(getSnapshotsFromAllProfiles(project, propertyResolver));
        removePluginForIntegrationTests(snapshots);
        snapshotsByProjectAndPlugin.put(project, snapshots);
        if (!snapshots.isEmpty()) {
            hasSnapshots = true;
        }
    }
    failIfSnapshotsAreReferenced(hasSnapshots, snapshotsByProjectAndPlugin, propertyResolvers);
}
Also used : Multimap(com.google.common.collect.Multimap) HashMultimap(com.google.common.collect.HashMultimap) PomPropertyResolver(com.itemis.maven.plugins.unleash.util.PomPropertyResolver) MavenProject(org.apache.maven.project.MavenProject) ArtifactCoordinates(com.itemis.maven.aether.ArtifactCoordinates)

Example 3 with ArtifactCoordinates

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

the class CheckPluginVersions 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));
        }
    }
    return snapshots;
}
Also used : ArtifactCoordinates(com.itemis.maven.aether.ArtifactCoordinates) Profile(org.apache.maven.model.Profile)

Example 4 with ArtifactCoordinates

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

the class AbstractTychoVersionsStep method execute.

@Override
public void execute(ExecutionContext context) throws MojoExecutionException, MojoFailureException {
    this.cachedPOMs = Maps.newHashMap();
    this.cachedModuleVersions = Maps.newHashMap();
    VersionsEngine versionsEngine = initializeVersionsEngine();
    try {
        for (MavenProject module : this.reactorProjects) {
            ArtifactCoordinates coordinates = ProjectToCoordinates.EMPTY_VERSION.apply(module);
            Optional<Document> parsedPOM = PomUtil.parsePOM(this.project);
            if (parsedPOM.isPresent()) {
                this.cachedPOMs.put(coordinates, parsedPOM.get());
            }
            this.cachedModuleVersions.put(coordinates, module.getVersion());
            Map<ReleasePhase, ArtifactCoordinates> coordinatesByPhase = this.metadata.getArtifactCoordinatesByPhase(module.getGroupId(), module.getArtifactId());
            String version = coordinatesByPhase.get(currentReleasePhase()).getVersion();
            versionsEngine.addVersionChange(module.getArtifactId(), version);
            if (module.getModel().getVersion() != null) {
                module.getModel().setVersion(version);
            }
        }
        versionsEngine.apply();
        adaptProjectMetadataWithNewVersions();
    } catch (IOException e) {
        throw new MojoExecutionException("Error during tycho version upgrade.", e);
    }
}
Also used : MavenProject(org.apache.maven.project.MavenProject) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) ReleasePhase(com.itemis.maven.plugins.unleash.ReleasePhase) ArtifactCoordinates(com.itemis.maven.aether.ArtifactCoordinates) ProjectToString(com.itemis.maven.plugins.unleash.util.functions.ProjectToString) IOException(java.io.IOException) VersionsEngine(org.eclipse.tycho.versions.engine.VersionsEngine) Document(org.w3c.dom.Document)

Example 5 with ArtifactCoordinates

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

the class AbstractTychoVersionsStep method adaptProjectMetadataWithNewVersions.

private void adaptProjectMetadataWithNewVersions() {
    // this needs to be done in order to make the changes reversible
    // if the metadata is not adapted reverting the changes wouldn't be possible for pom-less builds since the metadata
    // is initialized only once before the build starts
    this.metadataReader.getProjects().forEach(data -> {
        PomFile pom = data.getMetadata(PomFile.class);
        Map<ReleasePhase, ArtifactCoordinates> coordinatesByPhase = this.metadata.getArtifactCoordinatesByPhase(pom.getGroupId(), pom.getArtifactId());
        String version = coordinatesByPhase.get(currentReleasePhase()).getVersion();
        pom.setVersion(version);
    });
}
Also used : PomFile(org.eclipse.tycho.versions.pom.PomFile) 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