Skip to content

Commit 0fb1ea0

Browse files
Add Maven 4 to build matrix on GitHub Actions (#474)
* Add Maven 4 to build matrix on GitHub Actions * Fix profile-with-deps-inherit-parent-depMgmt-jdk-multilevel, profile-with-deps-inherit-parent-depMgmt-rule for Maven 4
1 parent 35e0e0c commit 0fb1ea0

File tree

8 files changed

+152
-15
lines changed

8 files changed

+152
-15
lines changed

.github/workflows/maven.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,5 @@ jobs:
2323
build:
2424
name: Verify
2525
uses: apache/maven-gh-actions-shared/.github/workflows/maven-verify.yml@v4
26+
with:
27+
maven4-enabled: true

src/it/projects/flatten-deploy/verify.groovy

Lines changed: 43 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,51 @@ assert flattenedPomFile.exists()
2424

2525
def flattenedPom = new XmlSlurper().parse(flattenedPomFile)
2626
// check that the pom is flattened
27-
assert 0 == flattenedPom.build.pluginManagement.size()
28-
assert 0 == flattenedPom.build.plugins.size()
27+
assert 0 == flattenedPom.build.pluginManagement.size()
28+
assert 0 == flattenedPom.build.plugins.size()
2929
assert "1.1" == flattenedPom.dependencies.dependency[0].version.toString()
3030

31-
// check installed pom
32-
File flattenedInstallPomFile = new File(localRepositoryPath, 'org/codehaus/mojo/flatten/its/flatten-deploy/0.0.1/flatten-deploy-0.0.1.pom')
33-
assert flattenedInstallPomFile.exists()
34-
assert flattenedInstallPomFile.size() == flattenedPomFile.size()
31+
if (mavenVersion.startsWith('3.')) {
3532

36-
def flattenedInstallPom = new XmlSlurper().parse(flattenedInstallPomFile)
37-
assert flattenedInstallPom == flattenedPom
33+
// check installed pom
34+
File flattenedInstallPomFile = new File(localRepositoryPath, 'org/codehaus/mojo/flatten/its/flatten-deploy/0.0.1/flatten-deploy-0.0.1.pom')
35+
assert flattenedInstallPomFile.exists()
36+
assert flattenedInstallPomFile.size() == flattenedPomFile.size()
3837

39-
// check deployed pom
40-
File flattenedDeployPomFile = new File(basedir, 'target/repo/org/codehaus/mojo/flatten/its/flatten-deploy/0.0.1/flatten-deploy-0.0.1.pom')
41-
assert flattenedDeployPomFile.exists()
42-
assert flattenedDeployPomFile.size() == flattenedPomFile.size()
38+
def flattenedInstallPom = new XmlSlurper().parse(flattenedInstallPomFile)
39+
assert flattenedInstallPom == flattenedPom
4340

44-
def flattenedDeployPom = new XmlSlurper().parse(flattenedInstallPomFile)
45-
assert flattenedDeployPom == flattenedPom
41+
// check deployed pom
42+
File flattenedDeployPomFile = new File(basedir, 'target/repo/org/codehaus/mojo/flatten/its/flatten-deploy/0.0.1/flatten-deploy-0.0.1.pom')
43+
assert flattenedDeployPomFile.exists()
44+
assert flattenedDeployPomFile.size() == flattenedPomFile.size()
45+
46+
def flattenedDeployPom = new XmlSlurper().parse(flattenedDeployPomFile)
47+
assert flattenedDeployPom == flattenedPom
48+
} else {
49+
// Maven 4.x
50+
// check installed build pom
51+
File flattenedInstallPomFile = new File(localRepositoryPath, 'org/codehaus/mojo/flatten/its/flatten-deploy/0.0.1/flatten-deploy-0.0.1-build.pom')
52+
assert flattenedInstallPomFile.exists()
53+
assert flattenedInstallPomFile.size() == flattenedPomFile.size()
54+
55+
def flattenedInstallPom = new XmlSlurper().parse(flattenedInstallPomFile)
56+
assert flattenedInstallPom == flattenedPom
57+
58+
// check deployed consumer pom
59+
flattenedInstallPomFile = new File(localRepositoryPath, 'org/codehaus/mojo/flatten/its/flatten-deploy/0.0.1/flatten-deploy-0.0.1.pom')
60+
flattenedInstallPom = new XmlSlurper().parse(flattenedInstallPomFile)
61+
assert flattenedInstallPom == flattenedPom
62+
63+
// check deployed build pom
64+
File flattenedDeployPomFile = new File(basedir, 'target/repo/org/codehaus/mojo/flatten/its/flatten-deploy/0.0.1/flatten-deploy-0.0.1-build.pom')
65+
assert flattenedDeployPomFile.exists()
66+
assert flattenedDeployPomFile.size() == flattenedPomFile.size()
67+
68+
def flattenedDeployPom = new XmlSlurper().parse(flattenedDeployPomFile)
69+
assert flattenedDeployPom == flattenedPom
70+
71+
flattenedDeployPomFile = new File(basedir, 'target/repo/org/codehaus/mojo/flatten/its/flatten-deploy/0.0.1/flatten-deploy-0.0.1.pom')
72+
flattenedDeployPom = new XmlSlurper().parse(flattenedDeployPomFile)
73+
assert flattenedDeployPom == flattenedPom
74+
}

src/it/projects/profile-with-deps-inherit-parent-depMgmt-jdk-multilevel/parent/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<groupId>org.codehaus.mojo.flatten.its</groupId>
1212
<artifactId>parent-depMngt</artifactId>
1313
<version>2</version>
14+
<relativePath/>
1415
</parent>
1516

1617

src/it/projects/profile-with-deps-inherit-parent-depMgmt-rule/parent/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
<groupId>org.codehaus.mojo.flatten.its</groupId>
1111
<artifactId>parent-depMngt</artifactId>
1212
<version>2</version>
13+
<relativePath/>
1314
</parent>
1415
<dependencyManagement>
1516
<dependencies>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
invoker.mavenOpts = -Drevision=1.2.3.4 -Drevision1=1.2.3.5 -Dsmall=small -Dsha1=abcdefg -Dchangelist=1,2,3,4
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<groupId>org.codehaus.mojo.flatten.its</groupId>
5+
<artifactId>resolve-properties-ci</artifactId>
6+
<version>${revision}</version>
7+
8+
<properties>
9+
<depVersion>1.1</depVersion>
10+
<utilVersion>3.2.1</utilVersion>
11+
<revision.property>${revision}</revision.property>
12+
<revision1.property>${revision1}</revision1.property>
13+
<small.property>${small}</small.property>
14+
<changelist.property>${changelist}</changelist.property>
15+
<sha1.property>${sha1}</sha1.property>
16+
</properties>
17+
18+
<dependencies>
19+
<dependency>
20+
<groupId>org.codehaus.mojo.flatten.its</groupId>
21+
<artifactId>dep</artifactId>
22+
<version>${revision}</version>
23+
<classifier>${small}</classifier>
24+
</dependency>
25+
<dependency>
26+
<groupId>org.codehaus.mojo.flatten.its</groupId>
27+
<artifactId>dep</artifactId>
28+
<version>revision</version>
29+
<classifier>small2</classifier>
30+
</dependency>
31+
</dependencies>
32+
33+
<!-- banned -->
34+
<build>
35+
<defaultGoal>verify</defaultGoal>
36+
<plugins>
37+
<plugin>
38+
<groupId>org.codehaus.mojo</groupId>
39+
<artifactId>flatten-maven-plugin</artifactId>
40+
<version>@project.version@</version>
41+
<configuration>
42+
<flattenMode>resolveCiFriendliesOnly</flattenMode>
43+
</configuration>
44+
</plugin>
45+
</plugins>
46+
</build>
47+
48+
<profiles>
49+
<profile>
50+
<activation>
51+
<activeByDefault>true</activeByDefault>
52+
</activation>
53+
<properties>
54+
<profilerevision>${revision}</profilerevision>
55+
<profilerevision1>${revision1}</profilerevision1>
56+
</properties>
57+
</profile>
58+
</profiles>
59+
</project>
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
21+
import groovy.xml.XmlSlurper
22+
23+
File originalPom = new File( basedir, 'pom.xml' )
24+
assert originalPom.exists()
25+
26+
def originalProject = new XmlSlurper().parse( originalPom )
27+
assert '${revision}' == originalProject.dependencies.dependency[0].version.text()
28+
assert '${small}' == originalProject.dependencies.dependency[0].classifier.text()
29+
30+
File flattenedPom = new File( basedir, '.flattened-pom.xml' )
31+
assert flattenedPom.exists()
32+
def flattenedProject = new XmlSlurper().parse( flattenedPom )
33+
34+
assert '1.2.3.4' == flattenedProject.version.text()
35+
assert '1.2.3.4' == flattenedProject.dependencies.dependency[0].version.text()
36+
assert '${small}' == flattenedProject.dependencies.dependency[0].classifier.text()
37+
38+
assert 'revision' == flattenedProject.dependencies.dependency[1].version.text()
39+
assert 'small2' == flattenedProject.dependencies.dependency[1].classifier.text()
40+
41+
assert '1.2.3.4' == flattenedProject.profiles.profile.properties.profilerevision.text()
42+
assert '${revision1}' == flattenedProject.profiles.profile.properties.profilerevision1.text()
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
invoker.mavenOpts = -Drevision=1.2.3.4 -Drevision1=1.2.3.5 -Dsmall=small -Dsha1=abcdefg -Dchangelist=1,2,3,4
1+
invoker.mavenOpts = -Drevision=1.2.3.4 -Drevision1=1.2.3.5 -Dsmall=small -Dsha1=abcdefg -Dchangelist=1,2,3,4
2+
# Maven 4 requires all properties to be resolved in dependencies
3+
invoker.maven.version = !4.0.0+

0 commit comments

Comments
 (0)