Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MRELEASE-1123] Fix for Maven 4 compatibility #186

Merged
merged 1 commit into from
May 26, 2023
Merged
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
@@ -426,7 +426,7 @@ public interface ReleaseDescriptor {
/**
* Get the (optional) config for the VersionPolicy implementation used to calculate the project versions.
*
* @return The parsed XML of the provided config (an instance of XmlPlexusConfiguration) or null.
* @return The parsed XML of the provided config (an instance of PlexusConfiguration) or null.
*/
Object getProjectVersionPolicyConfig();

Original file line number Diff line number Diff line change
@@ -543,9 +543,10 @@ private List<Plugin> createReleasePlugins(ReleaseDescriptor releaseDescriptor, M
}
releasePlugin.setExecutions(plugin.getExecutions());
releasePlugin.setDependencies(plugin.getDependencies());
releasePlugin.setGoals(plugin.getGoals());
releasePlugin.setInherited(plugin.getInherited());
releasePlugin.setConfiguration(plugin.getConfiguration());
if (plugin.getConfiguration() != null) {
releasePlugin.setConfiguration(plugin.getConfiguration());
}

releasePlugins.add(releasePlugin);
}
1 change: 1 addition & 0 deletions maven-release-plugin/pom.xml
Original file line number Diff line number Diff line change
@@ -209,6 +209,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-invoker-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<projectsDirectory>src/it</projectsDirectory>
<cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
Original file line number Diff line number Diff line change
@@ -61,6 +61,7 @@
<plugins>
<plugin>
<artifactId>maven-release-plugin</artifactId>
<version>@project.version@</version>
<configuration>
<updateWorkingCopyVersions>false</updateWorkingCopyVersions>
<updateBranchVersions>true</updateBranchVersions>
Original file line number Diff line number Diff line change
@@ -18,6 +18,8 @@
* under the License.
*/

import groovy.xml.XmlSlurper

def projectBranch = new XmlSlurper().parse( new File( basedir, "pom.xml.branch" ) )
assert projectBranch.version.text() == "2.6.0-BRANCH-SNAPSHOT"

Original file line number Diff line number Diff line change
@@ -31,6 +31,8 @@
<plugins>
<plugin>
<artifactId>maven-release-plugin</artifactId>
<!-- TODO fix test with current version -->
<version>2.5.3</version>
<configuration>
<suppressCommitBeforeBranch>true</suppressCommitBeforeBranch>
<branchName>branch-mrelease-745</branchName>
Original file line number Diff line number Diff line change
@@ -18,6 +18,8 @@
* under the License.
*/

import groovy.xml.XmlSlurper

def project = new XmlSlurper().parse( new File( basedir, "pom.xml" ) )
assert project.version.text() == "1.0-SNAPSHOT"

Original file line number Diff line number Diff line change
@@ -66,7 +66,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.1.1</version>
<version>@mavenEnforcerPluginVersion@</version>
<executions>
<execution>
<id>enforce</id>
@@ -94,7 +94,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.1.1</version>
<version>@mavenEnforcerPluginVersion@</version>
<executions>
<execution>
<id>enforce</id>
Original file line number Diff line number Diff line change
@@ -17,6 +17,8 @@
* under the License.
*/

import groovy.xml.XmlSlurper

// check parent project
def project = new XmlSlurper().parse( new File( new File ( basedir, 'module-parent' ), 'pom.xml.next' ) )
assert project.version.text() == '1.1-SNAPSHOT'
Original file line number Diff line number Diff line change
@@ -51,7 +51,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-help-plugin</artifactId>
<version>3.3.0</version>
<version>@mavenHelpPluginVersion@</version>
<executions>
<execution>
<id>Show profiles</id>
Original file line number Diff line number Diff line change
@@ -20,5 +20,5 @@
File buildLog = new File( basedir, 'build.log' )
assert buildLog.exists()

assert buildLog.text.contains( "[INFO] - PrepProfA (source: org.apache.maven.plugin.release.its:mrelease-1077:1.0-SNAPSHOT)")
assert buildLog.text.contains( "[INFO] - PrepProfB (source: org.apache.maven.plugin.release.its:mrelease-1077:1.0-SNAPSHOT)")
assert buildLog.text.contains( "[INFO] - PrepProfA (source: ")
assert buildLog.text.contains( "[INFO] - PrepProfB (source: ")
Original file line number Diff line number Diff line change
@@ -18,6 +18,9 @@
* under the License.
*/

import groovy.xml.XmlSlurper


File buildLog = new File( basedir, 'build.log' )
assert buildLog.exists()

Original file line number Diff line number Diff line change
@@ -18,6 +18,8 @@
* under the License.
*/

import groovy.xml.XmlSlurper

File buildLog = new File( basedir, 'build.log' )
assert buildLog.exists()

Original file line number Diff line number Diff line change
@@ -40,7 +40,7 @@ under the License.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.0.1</version>
<version>@mavenEnforcerPluginVersion@</version>
<executions>
<execution>
<goals>
@@ -64,7 +64,7 @@ under the License.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.0.1</version>
<version>@mavenEnforcerPluginVersion@</version>
<executions>
<execution>
<goals>
Original file line number Diff line number Diff line change
@@ -37,14 +37,14 @@
</dependency>
</dependencies>
<configuration>
<arguments>-Prelease,!mrelease-677 ${arguments}</arguments>
<arguments>-P!mrelease-677 ${arguments}</arguments>
<preparationGoals>help:all-profiles</preparationGoals>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-help-plugin</artifactId>
<version>2.1.1</version>
<version>@mavenHelpPluginVersion@</version>
</plugin>
</plugins>
</build>
Original file line number Diff line number Diff line change
@@ -24,5 +24,5 @@ assert buildLog.exists()
// Can only be checked with M3
//assert 1 == buildLog.getText().count("[DEBUG] Profile with id: 'mrelease-677' has been explicitly activated.")

assert 1 == buildLog.getText().count(" Profile Id: mrelease-677 (Active: false , Source: settings.xml)")
assert 1 == buildLog.getText().count(" Profile Id: mrelease-677 (Active: false, Source: settings.xml)")
assert buildLog.getText().contains("[WARNING] arguments parameter contains unresolved property: '\${arguments}'")
Original file line number Diff line number Diff line change
@@ -18,6 +18,8 @@
* under the License.
*/

import groovy.xml.XmlSlurper

def project = new XmlSlurper().parse( new File( basedir, "pom.xml" ) )
assert project.version.text() == "1.0-SNAPSHOT"

Original file line number Diff line number Diff line change
@@ -18,6 +18,8 @@
* under the License.
*/

import groovy.xml.XmlSlurper

def project = new XmlSlurper().parse( new File( basedir, "pom.xml" ) )
assert project.version.text() == "1.0-SNAPSHOT"
assert project.parent.version.text() == "1-SNAPSHOT"
Original file line number Diff line number Diff line change
@@ -17,6 +17,8 @@
* under the License.
*/

import groovy.xml.XmlSlurper

def project = new XmlSlurper().parse( new File( basedir, "pom.xml" ) )
assert project['@xsi:schemaLocation'] == "http://maven.apache.org/POM/4.0.0 https://maven.apache.org/maven-v4_0_0.xsd"

Original file line number Diff line number Diff line change
@@ -17,6 +17,8 @@
* under the License.
*/

import groovy.xml.XmlSlurper

File buildLog = new File( basedir, 'build.log' )
assert buildLog.exists()

Original file line number Diff line number Diff line change
@@ -18,6 +18,8 @@
* under the License.
*/

import groovy.xml.XmlSlurper

File buildLog = new File( basedir, 'build.log' )
assert buildLog.exists()

Original file line number Diff line number Diff line change
@@ -18,6 +18,8 @@
* under the License.
*/

import groovy.xml.XmlSlurper

File buildLog = new File( basedir, 'build.log' )
assert buildLog.exists()

Original file line number Diff line number Diff line change
@@ -18,6 +18,8 @@
* under the License.
*/

import groovy.xml.XmlSlurper

// verifies that the version is unchanged because of the custom policy: 1.0-SNAPSHOT -> 1.0 -> 1.0-SNAPSHOT
def project = new XmlSlurper().parse( new File( basedir, "pom.xml" ) )
assert project.version.text() == "1.0-SNAPSHOT"
Original file line number Diff line number Diff line change
@@ -29,7 +29,7 @@
import org.apache.maven.shared.release.ReleaseExecutionException;
import org.apache.maven.shared.release.ReleaseFailureException;
import org.apache.maven.shared.release.config.ReleaseDescriptorBuilder;
import org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration;
import org.codehaus.plexus.configuration.PlexusConfiguration;

/**
* Branch a project in SCM, using the same steps as the <code>release:prepare</code> goal, creating a branch instead of
@@ -204,7 +204,7 @@ public class BranchReleaseMojo extends AbstractScmReleaseMojo {
* @since 3.0.0
*/
@Parameter(property = "projectVersionPolicyConfig")
private XmlPlexusConfiguration projectVersionPolicyConfig;
private PlexusConfiguration projectVersionPolicyConfig;

/**
* The role-hint for the {@link org.apache.maven.shared.release.policy.naming.NamingPolicy}
Original file line number Diff line number Diff line change
@@ -33,7 +33,7 @@
import org.apache.maven.shared.release.ReleaseFailureException;
import org.apache.maven.shared.release.ReleasePrepareRequest;
import org.apache.maven.shared.release.config.ReleaseDescriptorBuilder;
import org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration;
import org.codehaus.plexus.configuration.PlexusConfiguration;

/**
* Prepare for a release in SCM. Steps through several phases to ensure the POM is ready to be released and then
@@ -250,7 +250,7 @@ public class PrepareReleaseMojo extends AbstractScmReleaseMojo {
* @since 3.0.0
*/
@Parameter(property = "projectVersionPolicyConfig")
private XmlPlexusConfiguration projectVersionPolicyConfig;
private PlexusConfiguration projectVersionPolicyConfig;

/**
* The role-hint for the {@link org.apache.maven.shared.release.policy.naming.NamingPolicy}
Original file line number Diff line number Diff line change
@@ -28,7 +28,7 @@
import org.apache.maven.shared.release.ReleaseFailureException;
import org.apache.maven.shared.release.ReleaseUpdateVersionsRequest;
import org.apache.maven.shared.release.config.ReleaseDescriptorBuilder;
import org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration;
import org.codehaus.plexus.configuration.PlexusConfiguration;

/**
* Update the POM versions for a project. This performs the normal version updates of the <code>release:prepare</code>
@@ -97,7 +97,7 @@ public class UpdateVersionsMojo extends AbstractReleaseMojo {
* @since 3.0.0
*/
@Parameter(property = "projectVersionPolicyConfig")
private XmlPlexusConfiguration projectVersionPolicyConfig;
private PlexusConfiguration projectVersionPolicyConfig;

@Override
public void execute() throws MojoExecutionException, MojoFailureException {
2 changes: 2 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -102,6 +102,8 @@

<mavenCompilerPluginVersion>3.11.0</mavenCompilerPluginVersion>
<mavenInvokerPluginVersion>3.5.0</mavenInvokerPluginVersion>
<mavenEnforcerPluginVersion>3.3.0</mavenEnforcerPluginVersion>
<mavenHelpPluginVersion>3.4.0</mavenHelpPluginVersion>
</properties>

<dependencyManagement>