use of com.itemis.maven.aether.ArtifactCoordinates in project unleash-maven-plugin by shillner.
the class TagScm method init.
private void init() {
this.scmProvider = this.scmProviderRegistry.getProvider();
Map<ReleasePhase, ArtifactCoordinates> coordinates = this.metadata.getArtifactCoordinatesByPhase(this.project.getGroupId(), this.project.getArtifactId());
ArtifactCoordinates postReleaseCoordinates = coordinates.get(ReleasePhase.RELEASE);
this.globalReleaseVersion = postReleaseCoordinates.getVersion();
this.cachedPOMs = Maps.newHashMap();
}
use of com.itemis.maven.aether.ArtifactCoordinates in project unleash-maven-plugin by shillner.
the class AbstractTychoVersionsStep method rollback.
@RollbackOnError
public void rollback() throws MojoExecutionException, MojoFailureException {
VersionsEngine versionsEngine = initializeVersionsEngine();
try {
// first add all module version changes to the versions engine of tycho and execute the change command
for (MavenProject module : this.reactorProjects) {
String version = this.cachedModuleVersions.get(ProjectToCoordinates.EMPTY_VERSION.apply(module));
versionsEngine.addVersionChange(module.getArtifactId(), version);
}
versionsEngine.apply();
// second step is to revert all pom changes by simply replacing the poms
for (MavenProject module : this.reactorProjects) {
this.log.debug("\tRolling back modifications on POM of module '" + ProjectToString.INSTANCE.apply(this.project) + "'");
ArtifactCoordinates coordinates = ProjectToCoordinates.EMPTY_VERSION.apply(module);
Document document = this.cachedPOMs.get(coordinates);
if (document != null) {
try {
PomUtil.writePOM(document, this.project);
} catch (Throwable t) {
throw new MojoExecutionException("Could not revert the version update after a failed release build.", t);
}
}
String version = this.cachedModuleVersions.get(coordinates);
if (module.getModel().getVersion() != null) {
module.getModel().setVersion(version);
}
}
} catch (IOException e) {
throw new MojoExecutionException("Could not revert the version update after a failed release build.", e);
}
}
use of com.itemis.maven.aether.ArtifactCoordinates 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);
}
use of com.itemis.maven.aether.ArtifactCoordinates in project unleash-maven-plugin by shillner.
the class CheckDependencyVersions method execute.
@Override
public void execute(ExecutionContext context) throws MojoExecutionException, MojoFailureException {
this.log.info("Checking that none of the reactor projects contain SNAPSHOT dependencies.");
Map<MavenProject, PomPropertyResolver> propertyResolvers = Maps.newHashMapWithExpectedSize(this.reactorProjects.size());
Multimap<MavenProject, ArtifactCoordinates> snapshotsByProject = HashMultimap.create();
for (MavenProject project : this.reactorProjects) {
this.log.debug("\tChecking dependencies of reactor project '" + ProjectToString.INSTANCE.apply(project) + "':");
PomPropertyResolver propertyResolver = new PomPropertyResolver(project, this.settings, this.profiles, this.releaseArgs);
propertyResolvers.put(project, propertyResolver);
snapshotsByProject.putAll(project, getSnapshotsFromManagement(project, propertyResolver));
snapshotsByProject.putAll(project, getSnapshots(project, propertyResolver));
snapshotsByProject.putAll(project, getSnapshotsFromAllProfiles(project, propertyResolver));
}
failIfSnapshotsAreReferenced(snapshotsByProject, propertyResolvers);
}
use of com.itemis.maven.aether.ArtifactCoordinates in project unleash-maven-plugin by shillner.
the class CheckDependencyVersions method failIfSnapshotsAreReferenced.
private void failIfSnapshotsAreReferenced(Multimap<MavenProject, ArtifactCoordinates> snapshotsByProject, Map<MavenProject, PomPropertyResolver> propertyResolvers) throws MojoFailureException {
if (!snapshotsByProject.values().isEmpty()) {
this.log.error("\tThere are SNAPSHOT dependency references! The following list contains all SNAPSHOT dependencies grouped by module:");
for (MavenProject p : snapshotsByProject.keySet()) {
PomPropertyResolver propertyResolver = propertyResolvers.get(p);
Collection<ArtifactCoordinates> snapshots = snapshotsByProject.get(p);
if (!snapshots.isEmpty()) {
this.log.error("\t\t[PROJECT] " + ProjectToString.INSTANCE.apply(p));
for (ArtifactCoordinates dependency : snapshots) {
String resolvedVersion = propertyResolver.expandPropertyReferences(dependency.getVersion());
String coordinates = dependency.toString();
if (!Objects.equal(resolvedVersion, dependency.getVersion())) {
coordinates = coordinates + " (resolves to " + resolvedVersion + ")";
}
this.log.error("\t\t\t[DEPENDENCY] " + coordinates);
}
}
}
throw new MojoFailureException("The project cannot be released due to one or more SNAPSHOT dependencies!");
}
}
Aggregations