#63 - Additional guards against snapshots in release train BOM.
We now inspect the BOM pom.xml for references to -SNAPSHOT in declared dependencies. This is to work around the limitation of the Maven Enforcer plugin which only verifies actual project dependencies, not ones declared in a <dependencyManagement /> block. #63 - Additional guards against snapshots in release train BOM. We now inspect the BOM pom.xml for references to -SNAPSHOT in declared dependencies. This is to work around the limitation of the Maven Enforcer plugin which only verifies actual project dependencies, not ones declared in a <dependencyManagement /> block.
This commit is contained in:
@@ -24,11 +24,13 @@ import lombok.RequiredArgsConstructor;
|
||||
import lombok.experimental.FieldDefaults;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.data.release.build.CommandLine.Argument;
|
||||
import org.springframework.data.release.build.CommandLine.Goal;
|
||||
import org.springframework.data.release.build.Pom.Artifact;
|
||||
import org.springframework.data.release.deployment.DefaultDeploymentInformation;
|
||||
import org.springframework.data.release.deployment.DeploymentInformation;
|
||||
import org.springframework.data.release.deployment.DeploymentProperties;
|
||||
@@ -138,6 +140,16 @@ class MavenBuildSystem implements BuildSystem {
|
||||
module.getProject().doWithAdditionalArtifacts(
|
||||
additionalArtifact -> pom.setDependencyManagementVersion(additionalArtifact.getArtifactId(), version));
|
||||
}
|
||||
|
||||
if (updateInformation.getPhase().equals(Phase.PREPARE)) {
|
||||
|
||||
// Make sure we have no snapshot leftovers
|
||||
List<Artifact> snapshotDependencies = pom.getSnapshotDependencies();
|
||||
|
||||
if (!snapshotDependencies.isEmpty()) {
|
||||
throw new IllegalStateException(String.format("Found snapshot dependencies %s!", snapshotDependencies));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -301,8 +313,8 @@ class MavenBuildSystem implements BuildSystem {
|
||||
}
|
||||
|
||||
/**
|
||||
* Triggers Maven commands to deploy to Sonatypes OSS Nexus if the given {@link ModuleIteration} refers to a version
|
||||
* that has to be publically released.
|
||||
* Triggers Maven commands to deploy to Sonatype's OSS Nexus if the given {@link ModuleIteration} refers to a version
|
||||
* that has to be publicly released.
|
||||
*
|
||||
* @param module must not be {@literal null}.
|
||||
*/
|
||||
|
||||
@@ -24,7 +24,6 @@ import org.apache.maven.shared.invoker.DefaultInvoker;
|
||||
import org.apache.maven.shared.invoker.InvocationResult;
|
||||
import org.apache.maven.shared.invoker.Invoker;
|
||||
import org.apache.maven.shared.invoker.MavenInvocationException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.release.io.OsOperations;
|
||||
import org.springframework.data.release.io.Workspace;
|
||||
import org.springframework.data.release.model.Project;
|
||||
@@ -52,7 +51,6 @@ class MavenRuntime {
|
||||
* @param logger must not be {@literal null}.
|
||||
* @param properties must not be {@literal null}.
|
||||
*/
|
||||
@Autowired
|
||||
public MavenRuntime(Workspace workspace, OsOperations os, Logger logger, MavenProperties properties) {
|
||||
|
||||
this.workspace = workspace;
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
*/
|
||||
package org.springframework.data.release.build;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.data.release.model.ArtifactVersion;
|
||||
import org.xmlbeam.annotation.XBRead;
|
||||
import org.xmlbeam.annotation.XBValue;
|
||||
@@ -64,6 +66,9 @@ public interface Pom {
|
||||
@XBWrite("/project/dependencyManagement/dependencies/dependency[artifactId=\"{0}\"]/version")
|
||||
Pom setDependencyManagementVersion(String artifactId, @XBValue ArtifactVersion version);
|
||||
|
||||
@XBRead("//dependency[substring(version, string-length(version) - string-length('-SNAPSHOT') + 1) = '-SNAPSHOT']")
|
||||
List<Artifact> getSnapshotDependencies();
|
||||
|
||||
public interface Repository {
|
||||
|
||||
@XBRead("child::id")
|
||||
|
||||
@@ -79,4 +79,12 @@ public class MavenIntegrationTests extends AbstractIntegrationTests {
|
||||
maven.updateProjectDescriptors(build, information);
|
||||
maven.prepareVersion(build, Phase.PREPARE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void findsSnapshotDependencies() throws Exception {
|
||||
|
||||
Pom pom = projection.io().file(workspace.getFile("bom/pom.xml", Projects.BUILD)).read(Pom.class);
|
||||
|
||||
System.out.println(pom.getSnapshotDependencies());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user