Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:set -DnewVersion=2.0.0 -Dversions.skip=true
15 changes: 15 additions & 0 deletions versions-maven-plugin/src/it/it-skip-001/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>localhost</groupId>
<artifactId>it-skip-001</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Test versions.skip parameter</name>

<description>
Test that the versions.skip parameter correctly skips plugin execution.
When versions.skip=true, the version should remain unchanged.
</description>
</project>
9 changes: 9 additions & 0 deletions versions-maven-plugin/src/it/it-skip-001/verify.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import groovy.xml.XmlSlurper

def project = new XmlSlurper().parse(new File(basedir, 'pom.xml'))
// Version should remain 1.0.0-SNAPSHOT since skip=true
assert project.version == '1.0.0-SNAPSHOT'

// Check that the log contains the skip message
def buildLog = new File(basedir, 'build.log')
assert buildLog.text.contains('Skipping execution')
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
invoker.goals = ${project.groupId}:${project.artifactId}:${project.version}:display-dependency-updates -Dversions.skip=true
23 changes: 23 additions & 0 deletions versions-maven-plugin/src/it/it-skip-002/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>localhost</groupId>
<artifactId>it-skip-002</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<name>Test versions.skip parameter with display goal</name>

<dependencies>
<dependency>
<groupId>localhost</groupId>
<artifactId>dummy-api</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>

<description>
Test that the versions.skip parameter works with display goals.
When versions.skip=true, the goal should be skipped.
</description>
</project>
7 changes: 7 additions & 0 deletions versions-maven-plugin/src/it/it-skip-002/verify.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Check that the log contains the skip message
def buildLog = new File(basedir, 'build.log')
assert buildLog.text.contains('Skipping execution')

// Verify that no dependency update information is shown
// When skipped, it shouldn't display any dependency analysis
assert !buildLog.text.contains('The following dependencies in Dependencies have newer versions')
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,14 @@ public abstract class AbstractVersionsUpdaterMojo extends AbstractMojo {
@Parameter(property = "maven.version.ignore")
protected Set<String> ignoredVersions;

/**
* If true, the plugin execution will be skipped.
*
* @since 2.20.2
*/
@Parameter(property = "versions.skip", defaultValue = "false")
protected boolean skip;

/**
* (injected) map of {@link Wagon} instances per protocol
*
Expand Down Expand Up @@ -304,6 +312,10 @@ public String getVersion() {
* @since 1.0-alpha-1
*/
public void execute() throws MojoExecutionException, MojoFailureException {
if (skip) {
getLog().info("Skipping execution");
return;
}
validateInput();
File outFile = project.getFile();
process(outFile);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,25 @@ public class CommitMojo extends AbstractMojo {
@Parameter(defaultValue = "${project}", required = true, readonly = true)
private MavenProject project;

/**
* If true, the plugin execution will be skipped.
*
* @since 2.20.2
*/
@Parameter(property = "versions.skip", defaultValue = "false")
private boolean skip;

/**
* Creates a new instance.
*/
public CommitMojo() {}

@Override
public void execute() throws MojoExecutionException, MojoFailureException {
if (skip) {
getLog().info("Skipping execution");
return;
}
Path outFile = project.getFile().toPath();
Path backupFile = outFile.getParent().resolve(outFile.getFileName() + ".versionsBackup");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,10 @@ static boolean dependenciesMatch(Dependency dependency, Dependency managedDepend
*/
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
if (skip) {
getLog().info("Skipping execution");
return;
}
logInit();
validateInput();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,10 @@ protected boolean getAllowSnapshots() {

@Override
public void execute() throws MojoExecutionException, MojoFailureException {
if (skip) {
getLog().info("Skipping execution");
return;
}
logInit();
validateInput();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,10 @@ protected boolean getAllowSnapshots() {

@Override
public void execute() throws MojoExecutionException, MojoFailureException {
if (skip) {
getLog().info("Skipping execution");
return;
}
logInit();
if (getProject().getParent() == null) {
logLine(false, "Project does not have a parent.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,10 @@ private Map<String, String> getPluginManagement(Model model) {
*/
@SuppressWarnings("checkstyle:MethodLength")
public void execute() throws MojoExecutionException, MojoFailureException {
if (skip) {
getLog().info("Skipping execution");
return;
}
logInit();
Set<String> pluginsWithVersionsSpecified;
try (MutableXMLStreamReader pomReader =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,10 @@ protected boolean getAllowSnapshots() {
}

public void execute() throws MojoExecutionException, MojoFailureException {
if (skip) {
getLog().info("Skipping execution");
return;
}
logInit();
List<String> current = new ArrayList<>();
List<String> updates = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,14 @@ public class RevertMojo extends AbstractMojo {
@Parameter(property = "processFromLocalAggregationRoot", defaultValue = "true")
private boolean processFromLocalAggregationRoot;

/**
* If true, the plugin execution will be skipped.
*
* @since 2.20.2
*/
@Parameter(property = "versions.skip", defaultValue = "false")
private boolean skip;

/**
* The (injected) {@link ProjectBuilder} instance
*
Expand All @@ -83,6 +91,10 @@ protected RevertMojo(ProjectBuilder projectBuilder) {
}

public void execute() throws MojoExecutionException, MojoFailureException {
if (skip) {
getLog().info("Skipping execution");
return;
}
final MavenProject projectToProcess = !processFromLocalAggregationRoot
? PomHelper.getLocalRoot(projectBuilder, session, getLog())
: session.getCurrentProject();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,10 @@ private synchronized void addChange(String groupId, String artifactId, String ol
* @throws org.apache.maven.plugin.MojoExecutionException when things go wrong.
*/
public void execute() throws MojoExecutionException {
if (skip) {
getLog().info("Skipping execution");
return;
}
validateInput();
if (session.getProjects().size() != session.getAllProjects().size()) {
// we are running on a restricted module set (-pl)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ protected boolean getAllowSnapshots() {
*/
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
if (skip) {
getLog().info("Skipping execution");
return;
}
validateInput();
if (session.getProjects().size() != session.getAllProjects().size()) {
// we are running on a restricted module set (-pl)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ protected boolean getAllowSnapshots() {
* @throws MojoFailureException when things go wrong.
*/
public void execute() throws MojoExecutionException, MojoFailureException {
if (skip) {
getLog().info("Skipping execution");
return;
}
validateInput();
if (session.getProjects().size() != session.getAllProjects().size()) {
// we are running on a restricted module set (-pl)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,10 @@ private void execute(MavenProject currentProject) throws MojoExecutionException,

@Override
public void execute() throws MojoExecutionException, MojoFailureException {
if (skip) {
getLog().info("Skipping execution");
return;
}
validateInput();

if (session.getProjects().size() != session.getAllProjects().size()) {
Expand Down
Loading
Loading