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;
}
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);
}
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;
}
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);
}
}
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);
});
}
Aggregations