Add maven4-build-vs-consumer-pom: Maven 4.0.0-rc-7 build POM vs consumer POM, lifecycle hooks, mvnup, mvnd

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017ic4b4XrpfdpsacrvqnrBM
This commit is contained in:
Ankur Mhatre
2026-11-26 21:03:12 +05:30
co-authored by Claude Sonnet 5.5
commit f32c088174
38 changed files with 1491 additions and 0 deletions
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2026 Ankur Mhatre
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+9
View File
@@ -0,0 +1,9 @@
# java-devops-demo
Runnable companion projects for build, release and DevOps posts on [ankurm.com](https://ankurm.com).
| Module | Post | What it shows |
|---|---|---|
| [maven4-build-vs-consumer-pom](maven4-build-vs-consumer-pom/) | Maven 4 for Java Developers: Build vs Consumer POM, New Lifecycle and Upgrade Checklist | Maven 4.0.0-rc-7 build POM vs consumer POM, model 4.1.0, `before:`/`after:` phases, `mvnup`, mvnd |
MIT licensed.
+2
View File
@@ -0,0 +1,2 @@
target/
.m2repo*/
+14
View File
@@ -0,0 +1,14 @@
# maven4-build-vs-consumer-pom
Companion to the ankurm.com post on Maven 4. Tested against **Maven 4.0.0-rc-7** (a release candidate, not GA as of 2026-11-26), JDK 25, Maven 3.9.16 and mvnd 2.0.0-rc-3.
| Directory | Purpose |
|---|---|
| `reactor/` | Model 4.1.0 multi-project build: `<subprojects>`, inferred `<parent/>`, `bom` packaging, `<sources>`, `${revision}` |
| `m3-consumer/` | Plain Maven 3 project (model 4.0.0) that consumes what the reactor publishes |
| `lifecycle/` | antrun echo tasks bound to `before:`/`after:` phases |
| `legacy-m3/` | Maven 3 style project used to try `mvnup`, `-fos WARN` and default plugin versions |
| `output/` | Captured real output, one file per scenario |
| `scripts/run-all.sh` | Regenerates every file in `output/` (see `scripts/env.sh` for tool locations) |
Run: unpack the three Maven tarballs and a JDK 25, set `TOOLS` and `JAVA_HOME`, then `scripts/run-all.sh`.
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.ankurm.legacy</groupId>
<artifactId>legacy-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>legacy-core</artifactId>
</project>
@@ -0,0 +1,5 @@
package demo;
public class Hello {
public static void main(String[] a) { System.out.println("legacy ok"); }
}
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- A deliberately "Maven 3 style" project: model 4.0.0, <modules>, no plugin versions, ${pom.version}. -->
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.ankurm.legacy</groupId>
<artifactId>legacy-parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<banner>legacy ${pom.version}</banner>
</properties>
<modules>
<module>core</module>
</modules>
</project>
@@ -0,0 +1,78 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Lifecycle demo: bind antrun echo tasks to Maven 4's new before:/after: phases. -->
<project xmlns="http://maven.apache.org/POM/4.1.0" root="true">
<modelVersion>4.1.0</modelVersion>
<groupId>com.ankurm.m4</groupId>
<artifactId>lifecycle-demo</artifactId>
<version>1.0.0</version>
<properties>
<maven.compiler.release>21</maven.compiler.release>
</properties>
<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.14.1</version>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.3.1</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.4</version>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.4.2</version>
</plugin>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.5.0</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<id>before-compile</id>
<phase>before:compile</phase>
<goals><goal>run</goal></goals>
<configuration><target><echo message="HOOK before:compile"/></target></configuration>
</execution>
<execution>
<id>after-compile</id>
<phase>after:compile</phase>
<goals><goal>run</goal></goals>
<configuration><target><echo message="HOOK after:compile"/></target></configuration>
</execution>
<execution>
<id>before-package-first</id>
<phase>before:package[100]</phase>
<goals><goal>run</goal></goals>
<configuration><target><echo message="HOOK before:package[100]"/></target></configuration>
</execution>
<execution>
<id>before-package-second</id>
<phase>before:package[200]</phase>
<goals><goal>run</goal></goals>
<configuration><target><echo message="HOOK before:package[200]"/></target></configuration>
</execution>
<execution>
<id>after-clean</id>
<phase>after:clean</phase>
<goals><goal>run</goal></goals>
<configuration><target><echo message="HOOK after:clean"/></target></configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
@@ -0,0 +1,5 @@
package demo;
public class App {
public static void main(String[] args) { System.out.println("lifecycle demo"); }
}
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- A plain Maven 3 project (model 4.0.0) that consumes artifacts published by the Maven 4 reactor. -->
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.ankurm.m3</groupId>
<artifactId>m3-consumer</artifactId>
<version>1.0.0</version>
<properties>
<maven.compiler.release>21</maven.compiler.release>
</properties>
<dependencies>
<dependency>
<groupId>com.ankurm.m4</groupId>
<artifactId>m4-app</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
@@ -0,0 +1,9 @@
package demo;
import com.ankurm.m4.Greeter;
public class UsesLib {
public static void main(String[] args) {
System.out.println(Greeter.greet("a Maven 3 consumer"));
}
}
@@ -0,0 +1,29 @@
$ curl -s https://repo1.maven.org/maven2/org/apache/maven/apache-maven/maven-metadata.xml | grep -E "<(latest|release|lastUpdated)>"
<latest>4.0.0-rc-7</latest>
<release>4.0.0-rc-7</release>
<lastUpdated>20261122115858</lastUpdated>
$ ... | grep -E "<version>(4\.0\.0-rc|3\.10)" (4.x release candidates and the newest 3.x line)
<version>3.10.0-rc-1</version>
<version>3.10.0</version>
<version>3.10.1</version>
<version>3.10.2</version>
<version>4.0.0-rc-1</version>
<version>4.0.0-rc-2</version>
<version>4.0.0-rc-3</version>
<version>4.0.0-rc-4</version>
<version>4.0.0-rc-5</version>
<version>4.0.0-rc-6</version>
<version>4.0.0-rc-7</version>
$ mvn -v (Maven 4)
Apache Maven 4.0.0-rc-7 (6d8f301b38af7399b36b862969d520974944f0b9)
Maven home: <maven4>
Java version: 25.0.5.1, vendor: Eclipse Adoptium, runtime: <jdk>
Default locale: en_US, platform encoding: UTF-8, time zone: Asia/Calcutta
OS name: "linux", version: "6.18.44-fc-v880", arch: "amd64", family: "unix"
$ mvn -v (Maven 3)
Apache Maven 3.9.16 (2bdd9fddda4b155ebf8000e807eb73fd829a51d5)
Maven home: <maven3>
Java version: 25.0.5.1, vendor: Eclipse Adoptium, runtime: <jdk>
@@ -0,0 +1,115 @@
$ mvn install
[INFO] Scanning for projects...
[INFO] The packaging attribute of the 'm4-bom' project is configured as 'bom' and changed to 'pom'
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] m4-demo [pom]
[INFO] m4-bom [pom]
[INFO] m4-lib [jar]
[INFO] m4-app [jar]
[INFO]
[INFO] -----------------------< com.ankurm.m4:m4-demo >------------------------
[INFO] Building m4-demo 1.0.0-SNAPSHOT [1/4]
[INFO] from pom.xml
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] --- install:3.1.4:install (default-install) @ m4-demo ---
[INFO] Installing <module>/reactor/pom.xml to <module>/.m2repo/com/ankurm/m4/m4-demo/1.0.0-SNAPSHOT/m4-demo-1.0.0-SNAPSHOT-build.pom
[INFO] Installing <module>/reactor/target/consumer-1116901588741584337.pom to <module>/.m2repo/com/ankurm/m4/m4-demo/1.0.0-SNAPSHOT/m4-demo-1.0.0-SNAPSHOT.pom
[INFO]
[INFO] ------------------------< com.ankurm.m4:m4-bom >------------------------
[INFO] Building m4-bom 1.0.0-SNAPSHOT [2/4]
[INFO] from bom/pom.xml
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] --- install:3.1.4:install (default-install) @ m4-bom ---
[INFO] Installing <module>/reactor/bom/pom.xml to <module>/.m2repo/com/ankurm/m4/m4-bom/1.0.0-SNAPSHOT/m4-bom-1.0.0-SNAPSHOT-build.pom
[INFO] Installing <module>/reactor/bom/target/consumer-16063290251144019470.pom to <module>/.m2repo/com/ankurm/m4/m4-bom/1.0.0-SNAPSHOT/m4-bom-1.0.0-SNAPSHOT.pom
[INFO]
[INFO] ------------------------< com.ankurm.m4:m4-lib >------------------------
[INFO] Building m4-lib 1.0.0-SNAPSHOT [3/4]
[INFO] from lib/pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- resources:3.3.1:resources (default-resources) @ m4-lib ---
[INFO] skip non existing resourceDirectory <module>/reactor/lib/src/main/resources
[INFO] skip non existing resourceDirectory <module>/reactor/lib/src/main/resources-filtered
[INFO]
[INFO] --- compiler:3.14.1:compile (default-compile) @ m4-lib ---
[INFO] Recompiling the module because of changed source code.
[INFO] Compiling 1 source file with javac [debug release 21] to target/classes
[INFO]
[INFO] --- resources:3.3.1:testResources (default-testResources) @ m4-lib ---
[INFO] skip non existing resourceDirectory <module>/reactor/lib/src/test/resources
[INFO] skip non existing resourceDirectory <module>/reactor/lib/src/test/resources-filtered
[INFO]
[INFO] --- compiler:3.14.1:testCompile (default-testCompile) @ m4-lib ---
[INFO] Recompiling the module because of changed dependency.
[INFO] Compiling 1 source file with javac [debug release 21] to target/test-classes
[INFO]
[INFO] --- surefire:3.5.4:test (default-test) @ m4-lib ---
[INFO] Using auto detected provider org.apache.maven.surefire.junitplatform.JUnitPlatformProvider
[INFO]
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[WARNING] [stderr] Picked up JAVA_TOOL_OPTIONS: -Djavax.net.ssl.trustStore=/etc/ssl/certs/java/cacerts -Djavax.net.ssl.trustStoreType=JKS -Dhttps.proxyHost=127.0.0.1 -Dhttps.proxyPort=42639 -Dhttp.nonProxyHosts=localhost|127.0.0.1|::1|127.*|0.*|::|169.254.*|api.anthropic.com|api-staging.anthropic.com|api-pr-preview.anthropic.com|mcp-proxy.anthropic.com|mcp-proxy-staging.anthropic.com|registry.npmjs.org|jsr.io|npm.jsr.io|pypi.org|files.pythonhosted.org|index.crates.io|proxy.golang.org|host.docker.internal|10.*|172.16.*|172.17.*|172.18.*|172.19.*|172.20.*|172.21.*|172.22.*|172.23.*|172.24.*|172.25.*|172.26.*|172.27.*|172.28.*|172.29.*|172.30.*|172.31.*|192.168.*|100.64.0.0/10|*.svc.cluster.local|*.svc.cluster.local -Djdk.http.auth.tunneling.disabledSchemes= -Djdk.http.auth.proxying.disabledSchemes=
[WARNING] [stderr] Picked up _JAVA_OPTIONS: -XX:+UnlockDiagnosticVMOptions -XX:DisableIntrinsic=_base64_encodeBlock,_base64_decodeBlock
[INFO] Running com.ankurm.m4.GreeterTest
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.179 s -- in com.ankurm.m4.GreeterTest
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO]
[INFO] --- jar:3.4.2:jar (default-jar) @ m4-lib ---
[INFO] Building jar: <module>/reactor/lib/target/m4-lib-1.0.0-SNAPSHOT.jar
[INFO]
[INFO] --- install:3.1.4:install (default-install) @ m4-lib ---
[INFO] Installing <module>/reactor/lib/target/m4-lib-1.0.0-SNAPSHOT.jar to <module>/.m2repo/com/ankurm/m4/m4-lib/1.0.0-SNAPSHOT/m4-lib-1.0.0-SNAPSHOT.jar
[INFO] Installing <module>/reactor/lib/pom.xml to <module>/.m2repo/com/ankurm/m4/m4-lib/1.0.0-SNAPSHOT/m4-lib-1.0.0-SNAPSHOT-build.pom
[INFO] Installing <module>/reactor/lib/target/consumer-2827804096093025405.pom to <module>/.m2repo/com/ankurm/m4/m4-lib/1.0.0-SNAPSHOT/m4-lib-1.0.0-SNAPSHOT.pom
[INFO]
[INFO] ------------------------< com.ankurm.m4:m4-app >------------------------
[INFO] Building m4-app 1.0.0-SNAPSHOT [4/4]
[INFO] from app/pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- resources:3.3.1:resources (default-resources) @ m4-app ---
[INFO] skip non existing resourceDirectory <module>/reactor/app/src/main/resources
[INFO] skip non existing resourceDirectory <module>/reactor/app/src/main/resources-filtered
[INFO]
[INFO] --- compiler:3.14.1:compile (default-compile) @ m4-app ---
[INFO] Recompiling the module because of changed dependency.
[INFO] Compiling 1 source file with javac [debug release 21] to target/classes
[INFO]
[INFO] --- resources:3.3.1:testResources (default-testResources) @ m4-app ---
[INFO] skip non existing resourceDirectory <module>/reactor/app/src/test/resources
[INFO] skip non existing resourceDirectory <module>/reactor/app/src/test/resources-filtered
[INFO]
[INFO] --- compiler:3.14.1:testCompile (default-testCompile) @ m4-app ---
[INFO] No sources to compile
[INFO]
[INFO] --- surefire:3.5.4:test (default-test) @ m4-app ---
[INFO] No tests to run.
[INFO]
[INFO] --- jar:3.4.2:jar (default-jar) @ m4-app ---
[INFO] Building jar: <module>/reactor/app/target/m4-app-1.0.0-SNAPSHOT.jar
[INFO]
[INFO] --- install:3.1.4:install (default-install) @ m4-app ---
[INFO] Installing <module>/reactor/app/target/m4-app-1.0.0-SNAPSHOT.jar to <module>/.m2repo/com/ankurm/m4/m4-app/1.0.0-SNAPSHOT/m4-app-1.0.0-SNAPSHOT.jar
[INFO] Installing <module>/reactor/app/pom.xml to <module>/.m2repo/com/ankurm/m4/m4-app/1.0.0-SNAPSHOT/m4-app-1.0.0-SNAPSHOT-build.pom
[INFO] Installing <module>/reactor/app/target/consumer-10425969277783569583.pom to <module>/.m2repo/com/ankurm/m4/m4-app/1.0.0-SNAPSHOT/m4-app-1.0.0-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for m4-demo 1.0.0-SNAPSHOT:
[INFO]
[INFO] m4-demo ............................................ SUCCESS [ x.xxx s]
[INFO] m4-bom ............................................. SUCCESS [ x.xxx s]
[INFO] m4-lib ............................................. SUCCESS [ x.xxx s]
[INFO] m4-app ............................................. SUCCESS [ x.xxx s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
@@ -0,0 +1,49 @@
$ ls m4-lib/1.0.0-SNAPSHOT
_remote.repositories
m4-lib-1.0.0-SNAPSHOT-build.pom
m4-lib-1.0.0-SNAPSHOT.jar
m4-lib-1.0.0-SNAPSHOT.pom
maven-metadata-local.xml
$ diff -u m4-lib-1.0.0-SNAPSHOT-build.pom m4-lib-1.0.0-SNAPSHOT.pom
@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.1.0">
- <modelVersion>4.1.0</modelVersion>
-
- <parent/>
-
+<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>com.ankurm.m4</groupId>
+ <artifactId>m4-demo</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </parent>
<artifactId>m4-lib</artifactId>
- <packaging>jar</packaging>
-
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
@@ -26,18 +26,4 @@
<scope>test</scope>
</dependency>
</dependencies>
-
- <build>
- <!-- 4.1.0: <sources> replaces <sourceDirectory>/<testSourceDirectory> -->
- <sources>
- <source>
- <scope>main</scope>
- <directory>src/main/java</directory>
- </source>
- <source>
- <scope>test</scope>
- <directory>src/test/java</directory>
- </source>
- </sources>
- </build>
-</project>
+</project>
\ No newline at end of file
@@ -0,0 +1,77 @@
$ cat m4-app-1.0.0-SNAPSHOT.pom (consumer POM)
<?xml version="1.0" encoding="UTF-8"?>
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.ankurm.m4</groupId>
<artifactId>m4-demo</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>m4-app</artifactId>
<dependencies>
<dependency>
<groupId>com.ankurm.m4</groupId>
<artifactId>m4-lib</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
$ cat m4-bom-1.0.0-SNAPSHOT.pom (consumer POM of the bom-packaged subproject)
<?xml version="1.0" encoding="UTF-8"?>
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.ankurm.m4</groupId>
<artifactId>m4-bom</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.ankurm.m4</groupId>
<artifactId>m4-lib</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
</dependencies>
</dependencyManagement>
</project>
$ cat m4-demo-1.0.0-SNAPSHOT.pom (consumer POM of the root: properties and pluginManagement are still there)
<?xml version="1.0" encoding="UTF-8"?>
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.ankurm.m4</groupId>
<artifactId>m4-demo</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<properties>
<maven.compiler.release>21</maven.compiler.release>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.14.1</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.4</version>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.4.2</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>3.1.4</version>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.3.1</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
@@ -0,0 +1,18 @@
$ mvn package (Maven 3.9.16, same reactor)
[INFO] Scanning for projects...
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[ERROR] Malformed POM <module>/reactor/pom.xml: Unknown attribute 'root' for tag 'project' (position: START_TAG seen ...->\n<project xmlns="http://maven.apache.org/POM/4.1.0" root="true">... @3:64) @ <module>/reactor/pom.xml, line 3, column 64
[FATAL] 'modelVersion' of '4.1.0' is newer than the versions supported by this version of Maven: [4.0.0]. Building this project requires a newer version of Maven. @ line 4, column 17
@
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR] The project com.ankurm.m4:m4-demo:${revision} (<module>/reactor/pom.xml) has 2 errors
[ERROR] Malformed POM <module>/reactor/pom.xml: Unknown attribute 'root' for tag 'project' (position: START_TAG seen ...->\n<project xmlns="http://maven.apache.org/POM/4.1.0" root="true">... @3:64) @ <module>/reactor/pom.xml, line 3, column 64 -> [Help 2]
[ERROR] 'modelVersion' of '4.1.0' is newer than the versions supported by this version of Maven: [4.0.0]. Building this project requires a newer version of Maven. @ line 4, column 17
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException
[ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/ModelParseException
@@ -0,0 +1,12 @@
$ mvn dependency:tree (Maven 3.9.16, model 4.0.0 project, depends on m4-app)
[INFO] ---------------------< com.ankurm.m3:m3-consumer >----------------------
[INFO] --- compiler:3.15.0:compile (default-compile) @ m3-consumer ---
[INFO] --- dependency:3.7.0:tree (default-cli) @ m3-consumer ---
[INFO] com.ankurm.m3:m3-consumer:jar:1.0.0
[INFO] \- com.ankurm.m4:m4-app:jar:1.0.0-SNAPSHOT:compile
[INFO] \- com.ankurm.m4:m4-lib:jar:1.0.0-SNAPSHOT:compile
[INFO] \- org.slf4j:slf4j-api:jar:2.0.17:compile
[INFO] BUILD SUCCESS
$ java -cp target/classes:... demo.UsesLib
Hello, a Maven 3 consumer (built with Maven 4)
@@ -0,0 +1,31 @@
$ mvn install -Dmaven.consumer.pom.flatten=true (separate local repository)
[INFO] Reactor Summary for m4-demo 1.0.0-SNAPSHOT:
[INFO] m4-demo ............................................ SUCCESS [ x.xxx s]
[INFO] m4-bom ............................................. SUCCESS [ x.xxx s]
[INFO] m4-lib ............................................. SUCCESS [ x.xxx s]
[INFO] m4-app ............................................. SUCCESS [ x.xxx s]
[INFO] BUILD SUCCESS
$ cat m4-lib-1.0.0-SNAPSHOT.pom (flattened consumer POM)
<?xml version="1.0" encoding="UTF-8"?>
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.ankurm.m4</groupId>
<artifactId>m4-lib</artifactId>
<version>1.0.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>2.0.17</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
$ ls m4-lib/1.0.0-SNAPSHOT (flattened)
_remote.repositories
m4-lib-1.0.0-SNAPSHOT-build.pom
m4-lib-1.0.0-SNAPSHOT.jar
m4-lib-1.0.0-SNAPSHOT.pom
maven-metadata-local.xml
@@ -0,0 +1,22 @@
$ mvn package (Maven 4)
[INFO] --- resources:3.3.1:resources (default-resources) @ lifecycle-demo ---
[INFO] --- antrun:3.2.0:run (before-compile) @ lifecycle-demo ---
[WARNING] [echo] HOOK before:compile
[INFO] --- compiler:3.14.1:compile (default-compile) @ lifecycle-demo ---
[INFO] --- antrun:3.2.0:run (after-compile) @ lifecycle-demo ---
[WARNING] [echo] HOOK after:compile
[INFO] --- resources:3.3.1:testResources (default-testResources) @ lifecycle-demo ---
[INFO] --- compiler:3.14.1:testCompile (default-testCompile) @ lifecycle-demo ---
[INFO] --- surefire:3.5.4:test (default-test) @ lifecycle-demo ---
[INFO] --- antrun:3.2.0:run (before-package-first) @ lifecycle-demo ---
[WARNING] [echo] HOOK before:package[100]
[INFO] --- antrun:3.2.0:run (before-package-second) @ lifecycle-demo ---
[WARNING] [echo] HOOK before:package[200]
[INFO] --- jar:3.4.2:jar (default-jar) @ lifecycle-demo ---
[INFO] BUILD SUCCESS
$ mvn clean (Maven 4)
[INFO] --- clean:3.5.0:clean (default-clean) @ lifecycle-demo ---
[INFO] --- antrun:3.2.0:run (after-clean) @ lifecycle-demo ---
[WARNING] [echo] HOOK after:clean
[INFO] BUILD SUCCESS
@@ -0,0 +1,18 @@
$ mvn package (Maven 3.9.16, same POM)
[INFO] Scanning for projects...
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[ERROR] Malformed POM <module>/lifecycle/pom.xml: Unknown attribute 'root' for tag 'project' (position: START_TAG seen ...->\n<project xmlns="http://maven.apache.org/POM/4.1.0" root="true">... @3:64) @ <module>/lifecycle/pom.xml, line 3, column 64
[FATAL] 'modelVersion' of '4.1.0' is newer than the versions supported by this version of Maven: [4.0.0]. Building this project requires a newer version of Maven. @ line 4, column 17
@
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR] The project com.ankurm.m4:lifecycle-demo:1.0.0 (<module>/lifecycle/pom.xml) has 2 errors
[ERROR] Malformed POM <module>/lifecycle/pom.xml: Unknown attribute 'root' for tag 'project' (position: START_TAG seen ...->\n<project xmlns="http://maven.apache.org/POM/4.1.0" root="true">... @3:64) @ <module>/lifecycle/pom.xml, line 3, column 64 -> [Help 2]
[ERROR] 'modelVersion' of '4.1.0' is newer than the versions supported by this version of Maven: [4.0.0]. Building this project requires a newer version of Maven. @ line 4, column 17
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException
[ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/ModelParseException
@@ -0,0 +1,22 @@
$ mvn package (Maven 4, untouched Maven 3 style project)
[INFO] ------------------------------------------------------------------------
[INFO] ------------------< com.ankurm.legacy:legacy-parent >-------------------
[INFO] --------------------------------[ pom ]---------------------------------
[INFO] -------------------< com.ankurm.legacy:legacy-core >--------------------
[INFO] --------------------------------[ jar ]---------------------------------
[WARNING] Version not locked for default bindings plugins [maven-resources-plugin, maven-compiler-plugin, maven-surefire-plugin, maven-jar-plugin], you should define versions in pluginManagement section of your pom.xml or parent
[INFO] --- resources:3.5.0:resources (default-resources) @ legacy-core ---
[INFO] --- compiler:3.16.0:compile (default-compile) @ legacy-core ---
[INFO] Compiling 1 source file with javac [debug target 17] to target/classes
[WARNING] location of system modules is not set in conjunction with -source 17
not setting the location of system modules may lead to class files that cannot run on JDK 17
--release 17 is recommended instead of -source 17 -target 17 because it sets the location of system modules automatically
[INFO] --- resources:3.5.0:testResources (default-testResources) @ legacy-core ---
[INFO] --- compiler:3.16.0:testCompile (default-testCompile) @ legacy-core ---
[INFO] --- surefire:3.6.0:test (default-test) @ legacy-core ---
[INFO] --- jar:3.5.1:jar (default-jar) @ legacy-core ---
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
@@ -0,0 +1,11 @@
$ mvn -fos WARN package (Maven 4: fail the build on any WARN)
[INFO] Enabled to break the build on log level WARN.
[WARNING] Version not locked for default bindings plugins [maven-resources-plugin, maven-compiler-plugin, maven-surefire-plugin, maven-jar-plugin], you should define versions in pluginManagement section of your pom.xml or parent
[INFO] Reactor Summary for legacy-parent 1.0.0-SNAPSHOT:
[INFO] legacy-parent ...................................... SUCCESS [ x.xxx s]
[INFO] legacy-core ........................................ SUCCESS [ x.xxx s]
[ERROR] BUILD FAILURE
[ERROR] Build failed due to log statements with a higher severity than allowed. Fix the logged issues or remove flag --fail-on-severity (-fos).
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the '-e' switch
[ERROR] Re-run Maven using the '-X' switch to enable verbose output
@@ -0,0 +1,173 @@
$ mvnup check
[INFO] Maven Upgrade Tool - Check
[INFO]
[INFO] Discovering POM files...
[INFO] Found 2 POM file(s)
[INFO]
[INFO] Maven Upgrade Tool
[INFO] Options:
[INFO]
[INFO] Executing 11 upgrade strategy(ies):
[INFO] - Applying Maven inference optimizations
[INFO] - Removing duplicate XML elements
[INFO] - Applying Maven 4 compatibility fixes
[INFO] - Deduplicating dependency and plugin declarations
[INFO] - Injecting standalone Nashorn for antrun JavaScript compatibility
[INFO] - Widening RequireMavenVersion ranges to allow Maven 4
[INFO] - Adding binary file extension exclusions to resource filtering
[INFO] - Adding maven-toolchains-plugin for JDK source level compatibility
[INFO] - Upgrading HTTP repository URLs to HTTPS
[INFO] - Fixing invalid Automatic-Module-Name manifest entries
[INFO] - Upgrading Maven plugins to recommended versions
[INFO]
[INFO] === Applying Maven inference optimizations ===
[INFO] Applying Maven inference optimizations
[INFO] Computing artifacts for inference from 2 POM(s)...
[INFO] Computed 2 unique artifact(s) for inference
[INFO] <module>/.work/legacy-upgraded/pom.xml (current: 4.0.0)
[INFO] ? No inference optimizations needed
[INFO] <module>/.work/legacy-upgraded/core/pom.xml (current: 4.0.0)
[INFO] ? No inference optimizations needed
[INFO]
[INFO] Applying Maven inference optimizations Summary:
[INFO] 0 POM(s) modified
[INFO] 2 POM(s) needed no changes
[INFO] Strategy completed (no changes needed)
[INFO] Processed: 2 POMs
[INFO]
[INFO] === Removing duplicate XML elements ===
[INFO] Removing duplicate XML elements
[INFO] <module>/.work/legacy-upgraded/pom.xml (checking for duplicate XML elements)
[INFO] ? No duplicate XML elements found
[INFO] <module>/.work/legacy-upgraded/core/pom.xml (checking for duplicate XML elements)
[INFO] ? No duplicate XML elements found
[INFO]
[INFO] Removing duplicate XML elements Summary:
[INFO] 0 POM(s) modified
[INFO] 2 POM(s) needed no changes
[INFO] Strategy completed (no changes needed)
[INFO] Processed: 2 POMs
[INFO]
[INFO] === Applying Maven 4 compatibility fixes ===
[INFO] Applying Maven 4 compatibility fixes
[INFO] <module>/.work/legacy-upgraded/pom.xml (checking for Maven 4 compatibility issues)
[INFO] ? No Maven 4 compatibility issues found
[INFO] <module>/.work/legacy-upgraded/core/pom.xml (checking for Maven 4 compatibility issues)
[INFO] ? No Maven 4 compatibility issues found
[INFO]
[INFO] Applying Maven 4 compatibility fixes Summary:
[INFO] 0 POM(s) modified
[INFO] 2 POM(s) needed no changes
[INFO] Strategy completed (no changes needed)
[INFO] Processed: 2 POMs
[INFO]
[INFO] === Deduplicating dependency and plugin declarations ===
[INFO] Deduplicating dependency and plugin declarations
[INFO] <module>/.work/legacy-upgraded/pom.xml (checking for duplicate declarations)
[INFO] ? No duplicate declarations found
[INFO] <module>/.work/legacy-upgraded/core/pom.xml (checking for duplicate declarations)
[INFO] ? No duplicate declarations found
[INFO]
[INFO] Deduplicating dependency and plugin declarations Summary:
[INFO] 0 POM(s) modified
[INFO] 2 POM(s) needed no changes
[INFO] Strategy completed (no changes needed)
[INFO] Processed: 2 POMs
[INFO]
[INFO] === Injecting standalone Nashorn for antrun JavaScript compatibility ===
[INFO] Injecting standalone Nashorn for antrun JavaScript compatibility
[INFO] <module>/.work/legacy-upgraded/pom.xml (checking for antrun JavaScript usage)
[INFO] ? No antrun JavaScript usage found
[INFO] <module>/.work/legacy-upgraded/core/pom.xml (checking for antrun JavaScript usage)
[INFO] ? No antrun JavaScript usage found
[INFO]
[INFO] Injecting standalone Nashorn for antrun JavaScript compatibility Summary:
[INFO] 0 POM(s) modified
[INFO] 2 POM(s) needed no changes
[INFO] Strategy completed (no changes needed)
[INFO] Processed: 2 POMs
[INFO]
[INFO] === Widening RequireMavenVersion ranges to allow Maven 4 ===
[INFO] Widening RequireMavenVersion ranges to allow Maven 4
[INFO] <module>/.work/legacy-upgraded/pom.xml (checking for RequireMavenVersion range restrictions)
[INFO] ? No RequireMavenVersion range restrictions found
[INFO] <module>/.work/legacy-upgraded/core/pom.xml (checking for RequireMavenVersion range restrictions)
[INFO] ? No RequireMavenVersion range restrictions found
[INFO]
[INFO] Widening RequireMavenVersion ranges to allow Maven 4 Summary:
[INFO] 0 POM(s) modified
[INFO] 2 POM(s) needed no changes
[INFO] Strategy completed (no changes needed)
[INFO] Processed: 2 POMs
[INFO]
[INFO] === Adding binary file extension exclusions to resource filtering ===
[INFO] Adding binary file extension exclusions to resource filtering
[INFO] <module>/.work/legacy-upgraded/pom.xml (checking for resource filtering of binary files)
[INFO] ? No resource filtering issues found
[INFO] <module>/.work/legacy-upgraded/core/pom.xml (checking for resource filtering of binary files)
[INFO] ? No resource filtering issues found
[INFO]
[INFO] Adding binary file extension exclusions to resource filtering Summary:
[INFO] 0 POM(s) modified
[INFO] 2 POM(s) needed no changes
[INFO] Strategy completed (no changes needed)
[INFO] Processed: 2 POMs
[INFO]
[INFO] === Adding maven-toolchains-plugin for JDK source level compatibility ===
[INFO] Adding maven-toolchains-plugin for JDK source level compatibility
[INFO] <module>/.work/legacy-upgraded/pom.xml (checking JDK source level compatibility)
[INFO] ? --source 17 is supported by all current JDKs
[INFO] <module>/.work/legacy-upgraded/core/pom.xml (checking JDK source level compatibility)
[INFO] ? --source 17 is supported by all current JDKs
[INFO]
[INFO] Adding maven-toolchains-plugin for JDK source level compatibility Summary:
[INFO] 0 POM(s) modified
[INFO] 2 POM(s) needed no changes
[INFO] Strategy completed (no changes needed)
[INFO] Processed: 2 POMs
[INFO]
[INFO] === Upgrading HTTP repository URLs to HTTPS ===
[INFO] Upgrading HTTP repository URLs to HTTPS
[INFO] <module>/.work/legacy-upgraded/pom.xml (checking for HTTP repository URLs)
[INFO] ? No HTTP repository URLs found
[INFO] <module>/.work/legacy-upgraded/core/pom.xml (checking for HTTP repository URLs)
[INFO] ? No HTTP repository URLs found
[INFO]
[INFO] Upgrading HTTP repository URLs to HTTPS Summary:
[INFO] 0 POM(s) modified
[INFO] 2 POM(s) needed no changes
[INFO] Strategy completed (no changes needed)
[INFO] Processed: 2 POMs
[INFO]
[INFO] === Fixing invalid Automatic-Module-Name manifest entries ===
[INFO] Fixing invalid Automatic-Module-Name manifest entries
[INFO] <module>/.work/legacy-upgraded/pom.xml (checking Automatic-Module-Name entries)
[INFO] ? No invalid Automatic-Module-Name entries found
[INFO] <module>/.work/legacy-upgraded/core/pom.xml (checking Automatic-Module-Name entries)
[INFO] ? No invalid Automatic-Module-Name entries found
[INFO]
[INFO] Fixing invalid Automatic-Module-Name manifest entries Summary:
[INFO] 0 POM(s) modified
[INFO] 2 POM(s) needed no changes
[INFO] Strategy completed (no changes needed)
[INFO] Processed: 2 POMs
[INFO]
[INFO] === Upgrading Maven plugins to recommended versions ===
[INFO] Upgrading Maven plugins to recommended versions
[INFO] <module>/.work/legacy-upgraded/pom.xml (checking for plugin upgrades)
[INFO] ? No plugin upgrades needed
[INFO] <module>/.work/legacy-upgraded/core/pom.xml (checking for plugin upgrades)
[INFO] ? No plugin upgrades needed
[INFO]
[INFO] Upgrading Maven plugins to recommended versions Summary:
[INFO] 0 POM(s) modified
[INFO] 2 POM(s) needed no changes
[INFO] Strategy completed (no changes needed)
[INFO] Processed: 2 POMs
[INFO]
[INFO] === Overall Results ===
[INFO] Total POMs processed: 2
[INFO] No POMs required modifications
[INFO]
[INFO] Creating .mvn directory if needed to avoid root directory warnings...
[INFO] ? .mvn directory already exists at <module>/.work/legacy-upgraded/.mvn
@@ -0,0 +1,228 @@
$ mvnup apply --all
[INFO] Maven Upgrade Tool - Apply
[INFO]
[INFO] Discovering POM files...
[INFO] Found 2 POM file(s)
[INFO]
[INFO] Maven Upgrade Tool
[INFO] Options:
[INFO] all: true (applying all available upgrades)
[INFO]
[INFO] Executing 13 upgrade strategy(ies):
[INFO] - Upgrading POM model version
[INFO] - Applying Maven inference optimizations
[INFO] - Removing duplicate XML elements
[INFO] - Applying Maven 4 compatibility fixes
[INFO] - Migrating source configuration to <source> elements
[INFO] - Deduplicating dependency and plugin declarations
[INFO] - Injecting standalone Nashorn for antrun JavaScript compatibility
[INFO] - Widening RequireMavenVersion ranges to allow Maven 4
[INFO] - Adding binary file extension exclusions to resource filtering
[INFO] - Adding maven-toolchains-plugin for JDK source level compatibility
[INFO] - Upgrading HTTP repository URLs to HTTPS
[INFO] - Fixing invalid Automatic-Module-Name manifest entries
[INFO] - Upgrading Maven plugins to recommended versions
[INFO]
[INFO] === Upgrading POM model version ===
[INFO] Upgrading POM model version
[INFO] <module>/.work/legacy-upgraded/pom.xml (current: 4.0.0)
[INFO] ? Upgrading from 4.0.0 to 4.1.0
[INFO] ? Updated modelVersion to 4.1.0
[INFO] ? Updated namespace to http://maven.apache.org/POM/4.1.0
[INFO] ? Updated xsi:schemaLocation
[INFO] ? Converted <modules> to <subprojects>
[INFO] ? Converted 1 <module> elements to <subproject>
[INFO] ? Model upgrade completed
[INFO] <module>/.work/legacy-upgraded/core/pom.xml (current: 4.0.0)
[INFO] ? Upgrading from 4.0.0 to 4.1.0
[INFO] ? Updated modelVersion to 4.1.0
[INFO] ? Updated namespace to http://maven.apache.org/POM/4.1.0
[INFO] ? Updated xsi:schemaLocation
[INFO] ? Model upgrade completed
[INFO]
[INFO] Upgrading POM model version Summary:
[INFO] 2 POM(s) modified
[INFO] 0 POM(s) needed no changes
[INFO] ? Strategy completed successfully
[INFO] Processed: 2 POMs
[INFO] ? Modified: 2 POMs
[INFO]
[INFO] === Applying Maven inference optimizations ===
[INFO] Applying Maven inference optimizations
[INFO] Computing artifacts for inference from 2 POM(s)...
[INFO] Computed 2 unique artifact(s) for inference
[INFO] <module>/.work/legacy-upgraded/pom.xml (current: 4.1.0)
[INFO] ? Removed: redundant subprojects list (matches direct children)
[INFO] ? Removed: modelVersion element (can be inferred from namespace)
[INFO] ? Full inference optimizations applied
[INFO] <module>/.work/legacy-upgraded/core/pom.xml (current: 4.1.0)
[INFO] ? Removed: parent groupId (child has no explicit groupId)
[INFO] ? Removed: parent version (child has no explicit version)
[INFO] ? Removed: parent artifactId (can be inferred from relativePath)
[INFO] ? Removed: modelVersion element (can be inferred from namespace)
[INFO] ? Full inference optimizations applied
[INFO]
[INFO] Applying Maven inference optimizations Summary:
[INFO] 2 POM(s) modified
[INFO] 0 POM(s) needed no changes
[INFO] ? Strategy completed successfully
[INFO] Processed: 2 POMs
[INFO] ? Modified: 2 POMs
[INFO]
[INFO] === Removing duplicate XML elements ===
[INFO] Removing duplicate XML elements
[INFO] <module>/.work/legacy-upgraded/pom.xml (checking for duplicate XML elements)
[INFO] ? No duplicate XML elements found
[INFO] <module>/.work/legacy-upgraded/core/pom.xml (checking for duplicate XML elements)
[INFO] ? No duplicate XML elements found
[INFO]
[INFO] Removing duplicate XML elements Summary:
[INFO] 0 POM(s) modified
[INFO] 2 POM(s) needed no changes
[INFO] Strategy completed (no changes needed)
[INFO] Processed: 2 POMs
[INFO]
[INFO] === Applying Maven 4 compatibility fixes ===
[INFO] Applying Maven 4 compatibility fixes
[INFO] <module>/.work/legacy-upgraded/pom.xml (checking for Maven 4 compatibility issues)
[INFO] ? No Maven 4 compatibility issues found
[INFO] <module>/.work/legacy-upgraded/core/pom.xml (checking for Maven 4 compatibility issues)
[INFO] ? No Maven 4 compatibility issues found
[INFO]
[INFO] Applying Maven 4 compatibility fixes Summary:
[INFO] 0 POM(s) modified
[INFO] 2 POM(s) needed no changes
[INFO] Strategy completed (no changes needed)
[INFO] Processed: 2 POMs
[INFO]
[INFO] === Migrating source configuration to <source> elements ===
[INFO] Migrating source configuration to <source> elements
[INFO] <module>/.work/legacy-upgraded/pom.xml (current: 4.1.0)
[INFO] ? Migrated properties: maven.compiler.source = maven.compiler.target = 17
[INFO] ? Set targetVersion: 17
[INFO] ? Source configuration migrated to <source> elements
[INFO] <module>/.work/legacy-upgraded/core/pom.xml (current: 4.1.0)
[INFO] ? No source configuration to migrate
[INFO]
[INFO] Migrating source configuration to <source> elements Summary:
[INFO] 1 POM(s) modified
[INFO] 1 POM(s) needed no changes
[INFO] ? Strategy completed successfully
[INFO] Processed: 2 POMs
[INFO] ? Modified: 1 POMs
[INFO]
[INFO] === Deduplicating dependency and plugin declarations ===
[INFO] Deduplicating dependency and plugin declarations
[INFO] <module>/.work/legacy-upgraded/pom.xml (checking for duplicate declarations)
[INFO] ? No duplicate declarations found
[INFO] <module>/.work/legacy-upgraded/core/pom.xml (checking for duplicate declarations)
[INFO] ? No duplicate declarations found
[INFO]
[INFO] Deduplicating dependency and plugin declarations Summary:
[INFO] 0 POM(s) modified
[INFO] 2 POM(s) needed no changes
[INFO] Strategy completed (no changes needed)
[INFO] Processed: 2 POMs
[INFO]
[INFO] === Injecting standalone Nashorn for antrun JavaScript compatibility ===
[INFO] Injecting standalone Nashorn for antrun JavaScript compatibility
[INFO] <module>/.work/legacy-upgraded/pom.xml (checking for antrun JavaScript usage)
[INFO] ? No antrun JavaScript usage found
[INFO] <module>/.work/legacy-upgraded/core/pom.xml (checking for antrun JavaScript usage)
[INFO] ? No antrun JavaScript usage found
[INFO]
[INFO] Injecting standalone Nashorn for antrun JavaScript compatibility Summary:
[INFO] 0 POM(s) modified
[INFO] 2 POM(s) needed no changes
[INFO] Strategy completed (no changes needed)
[INFO] Processed: 2 POMs
[INFO]
[INFO] === Widening RequireMavenVersion ranges to allow Maven 4 ===
[INFO] Widening RequireMavenVersion ranges to allow Maven 4
[INFO] <module>/.work/legacy-upgraded/pom.xml (checking for RequireMavenVersion range restrictions)
[INFO] ? No RequireMavenVersion range restrictions found
[INFO] <module>/.work/legacy-upgraded/core/pom.xml (checking for RequireMavenVersion range restrictions)
[INFO] ? No RequireMavenVersion range restrictions found
[INFO]
[INFO] Widening RequireMavenVersion ranges to allow Maven 4 Summary:
[INFO] 0 POM(s) modified
[INFO] 2 POM(s) needed no changes
[INFO] Strategy completed (no changes needed)
[INFO] Processed: 2 POMs
[INFO]
[INFO] === Adding binary file extension exclusions to resource filtering ===
[INFO] Adding binary file extension exclusions to resource filtering
[INFO] <module>/.work/legacy-upgraded/pom.xml (checking for resource filtering of binary files)
[INFO] ? No resource filtering issues found
[INFO] <module>/.work/legacy-upgraded/core/pom.xml (checking for resource filtering of binary files)
[INFO] ? No resource filtering issues found
[INFO]
[INFO] Adding binary file extension exclusions to resource filtering Summary:
[INFO] 0 POM(s) modified
[INFO] 2 POM(s) needed no changes
[INFO] Strategy completed (no changes needed)
[INFO] Processed: 2 POMs
[INFO]
[INFO] === Adding maven-toolchains-plugin for JDK source level compatibility ===
[INFO] Adding maven-toolchains-plugin for JDK source level compatibility
[INFO] <module>/.work/legacy-upgraded/pom.xml (checking JDK source level compatibility)
[INFO] ? --source 17 is supported by all current JDKs
[INFO] <module>/.work/legacy-upgraded/core/pom.xml (checking JDK source level compatibility)
[INFO] ? --source 17 is supported by all current JDKs
[INFO]
[INFO] Adding maven-toolchains-plugin for JDK source level compatibility Summary:
[INFO] 0 POM(s) modified
[INFO] 2 POM(s) needed no changes
[INFO] Strategy completed (no changes needed)
[INFO] Processed: 2 POMs
[INFO]
[INFO] === Upgrading HTTP repository URLs to HTTPS ===
[INFO] Upgrading HTTP repository URLs to HTTPS
[INFO] <module>/.work/legacy-upgraded/pom.xml (checking for HTTP repository URLs)
[INFO] ? No HTTP repository URLs found
[INFO] <module>/.work/legacy-upgraded/core/pom.xml (checking for HTTP repository URLs)
[INFO] ? No HTTP repository URLs found
[INFO]
[INFO] Upgrading HTTP repository URLs to HTTPS Summary:
[INFO] 0 POM(s) modified
[INFO] 2 POM(s) needed no changes
[INFO] Strategy completed (no changes needed)
[INFO] Processed: 2 POMs
[INFO]
[INFO] === Fixing invalid Automatic-Module-Name manifest entries ===
[INFO] Fixing invalid Automatic-Module-Name manifest entries
[INFO] <module>/.work/legacy-upgraded/pom.xml (checking Automatic-Module-Name entries)
[INFO] ? No invalid Automatic-Module-Name entries found
[INFO] <module>/.work/legacy-upgraded/core/pom.xml (checking Automatic-Module-Name entries)
[INFO] ? No invalid Automatic-Module-Name entries found
[INFO]
[INFO] Fixing invalid Automatic-Module-Name manifest entries Summary:
[INFO] 0 POM(s) modified
[INFO] 2 POM(s) needed no changes
[INFO] Strategy completed (no changes needed)
[INFO] Processed: 2 POMs
[INFO]
[INFO] === Upgrading Maven plugins to recommended versions ===
[INFO] Upgrading Maven plugins to recommended versions
[INFO] <module>/.work/legacy-upgraded/pom.xml (checking for plugin upgrades)
[INFO] ? No plugin upgrades needed
[INFO] <module>/.work/legacy-upgraded/core/pom.xml (checking for plugin upgrades)
[INFO] ? No plugin upgrades needed
[INFO]
[INFO] Upgrading Maven plugins to recommended versions Summary:
[INFO] 0 POM(s) modified
[INFO] 2 POM(s) needed no changes
[INFO] Strategy completed (no changes needed)
[INFO] Processed: 2 POMs
[INFO]
[INFO] === Overall Results ===
[INFO] Total POMs processed: 2
[INFO] ? Total POMs modified: 2
[INFO]
[INFO] Creating .mvn directory if needed to avoid root directory warnings...
[INFO] ? .mvn directory already exists at <module>/.work/legacy-upgraded/.mvn
[INFO]
[INFO] Saving modified POMs...
[INFO] ? Saved: <module>/.work/legacy-upgraded/pom.xml
[INFO] ? Saved: <module>/.work/legacy-upgraded/core/pom.xml
[INFO] ? All modifications saved successfully
@@ -0,0 +1,55 @@
$ diff -u legacy-m3/pom.xml (before) .../pom.xml (after)
@@ -1,9 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- A deliberately "Maven 3 style" project: model 4.0.0, <modules>, no plugin versions, ${pom.version}. -->
-<project xmlns="http://maven.apache.org/POM/4.0.0"
+<project xmlns="http://maven.apache.org/POM/4.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
+ xsi:schemaLocation="http://maven.apache.org/POM/4.1.0 https://maven.apache.org/xsd/maven-4.1.0.xsd">
<groupId>com.ankurm.legacy</groupId>
<artifactId>legacy-parent</artifactId>
@@ -11,13 +10,16 @@
<packaging>pom</packaging>
<properties>
- <maven.compiler.source>17</maven.compiler.source>
- <maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<banner>legacy ${pom.version}</banner>
</properties>
- <modules>
- <module>core</module>
- </modules>
+ <build>
+ <sources>
+ <source>
+ <targetVersion>17</targetVersion>
+ </source>
+ </sources>
+
+ </build>
</project>
$ diff -u core/pom.xml
@@ -1,14 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0"
+<project xmlns="http://maven.apache.org/POM/4.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
+ xsi:schemaLocation="http://maven.apache.org/POM/4.1.0 https://maven.apache.org/xsd/maven-4.1.0.xsd">
<parent>
- <groupId>com.ankurm.legacy</groupId>
- <artifactId>legacy-parent</artifactId>
- <version>1.0.0-SNAPSHOT</version>
- </parent>
+</parent>
<artifactId>legacy-core</artifactId>
</project>
@@ -0,0 +1,25 @@
$ mvn package (Maven 4, after mvnup apply --all)
[INFO] ------------------------------------------------------------------------
[INFO] ------------------< com.ankurm.legacy:legacy-parent >-------------------
[INFO] --------------------------------[ pom ]---------------------------------
[INFO] -------------------< com.ankurm.legacy:legacy-core >--------------------
[INFO] --------------------------------[ jar ]---------------------------------
[WARNING] Version not locked for default bindings plugins [maven-resources-plugin, maven-compiler-plugin, maven-surefire-plugin, maven-jar-plugin], you should define versions in pluginManagement section of your pom.xml or parent
[INFO] --- resources:3.5.0:resources (default-resources) @ legacy-core ---
[INFO] --- compiler:3.16.0:compile (default-compile) @ legacy-core ---
[INFO] Compiling 1 source file with javac [debug target 1.8] to target/classes
[WARNING] bootstrap class path is not set in conjunction with -source 8
not setting the bootstrap class path may lead to class files that cannot run on JDK 8
--release 8 is recommended instead of -source 8 -target 1.8 because it sets the bootstrap class path automatically
[WARNING] source value 8 is obsolete and will be removed in a future release
[WARNING] target value 8 is obsolete and will be removed in a future release
[WARNING] To suppress warnings about obsolete options, use -Xlint:-options.
[INFO] --- resources:3.5.0:testResources (default-testResources) @ legacy-core ---
[INFO] --- compiler:3.16.0:testCompile (default-testCompile) @ legacy-core ---
[INFO] --- surefire:3.6.0:test (default-test) @ legacy-core ---
[INFO] --- jar:3.5.1:jar (default-jar) @ legacy-core ---
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
@@ -0,0 +1,24 @@
$ mvnd --version
Apache Maven Daemon (mvnd) 2.0.0-rc-3 linux-amd64 native client (f912362c18c9a75faf3e31a4e0e0b921206013b9)
Apache Maven 4.0.0-rc-3 (3952d00ce65df6753b63a51e86b1f626c55a8df2)
Maven home: <mvnd>/mvn
Java version: 25.0.5.1, vendor: Eclipse Adoptium, runtime: <jdk>
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "6.18.44-fc-v880", arch: "amd64", family: "unix"
$ mvnd -o -DskipTests install (daemon starting)
[INFO] Average project wall time: 1.00s
[INFO] BUILD SUCCESS
wall: 11.646 s
$ mvnd -o -DskipTests install (daemon already running)
[INFO] Average project wall time: 0.75s
[INFO] BUILD SUCCESS
wall: 3.625 s
Stopping 2 running daemons
$ mvn -o -DskipTests install (plain Maven 4.0.0-rc-7, new JVM each time)
[INFO] BUILD SUCCESS
wall: 8.670 s
[INFO] BUILD SUCCESS
wall: 13.017 s
@@ -0,0 +1,84 @@
$ mvnup --help
usage: mvnup [options] [<goal|phase> ...]
Options:
-a,--all Apply all upgrades (equivalent to
--model-version 4.1.0 --infer --model
--plugins)
-B,--batch-mode Run in non-interactive mode. Alias for
--non-interactive (kept for backwards
compatibility)
--color <arg> Defines the color mode of the output.
Supported are 'auto', 'always', 'never'.
-D,--define <arg> Define a user property
-d,--directory <path> Directory to use as starting point for
POM discovery
--debug Launch the JVM in debug mode (script
option).
-e,--errors Produce execution error messages
--enc Launch the Maven Encryption tool (script
option).
--force-interactive Run in interactive mode. Overrides, if
applicable, the CI environment variable
and --non-interactive/--batch-mode
options
-fos,--fail-on-severity <arg> Configure which severity of logging
should cause the build to fail
-gs,--global-settings <arg> <deprecated> Alternate path for the
global settings file.
-gt,--global-toolchains <arg> <deprecated> Alternate path for the
global toolchains file.
-h,--help Display help information
-i,--infer Use inference when upgrading (remove
redundant information)
-is,--install-settings <arg> Alternate path for the installation
settings file
-it,--install-toolchains <arg> Alternate path for the installation
toolchains file
-l,--log-file <arg> Log file where all build output will go
(disables output color)
-m,--model-version <version> Target POM model version (4.0.0 or
4.1.0)
-model,--model Fix Maven 4 compatibility issues in POM
files
--non-interactive Run in non-interactive mode. Alias for
--batch-mode
-o,--offline Work offline
-plugins,--plugins Upgrade plugins known to fail with Maven
4 to their minimum compatible versions
-ps,--project-settings <arg> Alternate path for the project settings
file
-q,--quiet Quiet output - only show errors
--raw-streams Do not decorate standard output and
error streams
-s,--settings <arg> Alternate path for the user settings
file
--shell Launch the Maven Shell tool (script
option).
-t,--toolchains <arg> Alternate path for the user toolchains
file
--up Launch the Maven Upgrade tool (script
option).
-v,--version Display version information
-V,--show-version Display version information WITHOUT
stopping build
-X,--verbose Produce execution verbose output
--yjp Launch the JVM with Yourkit profiler
(script option).
Goals:
help - display this help message
check - check for available upgrades
apply - apply available upgrades
Options:
-m, --model-version <version> Target POM model version (4.0.0 or 4.1.0)
-d, --directory <path> Directory to use as starting point for POM discovery
-i, --infer Remove redundant information that can be inferred by Maven
--model Fix Maven 4 compatibility issues in POM files
--plugins Upgrade plugins known to fail with Maven 4
-a, --all Apply all upgrades (equivalent to --model-version 4.1.0 --infer --model --plugins)
Default behavior: --model --plugins --infer are applied if no other options are specified
@@ -0,0 +1 @@
-Drevision=1.0.0-SNAPSHOT
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.1.0">
<modelVersion>4.1.0</modelVersion>
<parent/>
<artifactId>m4-app</artifactId>
<packaging>jar</packaging>
<dependencies>
<!-- 4.1.0: no <version> needed for a sibling subproject -->
<dependency>
<groupId>com.ankurm.m4</groupId>
<artifactId>m4-lib</artifactId>
</dependency>
</dependencies>
</project>
@@ -0,0 +1,9 @@
package com.ankurm.m4.app;
import com.ankurm.m4.Greeter;
public class Main {
public static void main(String[] args) {
System.out.println(Greeter.greet("reader"));
}
}
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.1.0">
<modelVersion>4.1.0</modelVersion>
<!-- 4.1.0: parent coordinates inferred from ../pom.xml -->
<parent/>
<artifactId>m4-bom</artifactId>
<!-- 4.1.0: dedicated packaging for dependency-management-only POMs -->
<packaging>bom</packaging>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.ankurm.m4</groupId>
<artifactId>m4-lib</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
</project>
@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.1.0">
<modelVersion>4.1.0</modelVersion>
<parent/>
<artifactId>m4-lib</artifactId>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>2.0.17</version>
</dependency>
<dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<version>6.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.13.4</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<!-- 4.1.0: <sources> replaces <sourceDirectory>/<testSourceDirectory> -->
<sources>
<source>
<scope>main</scope>
<directory>src/main/java</directory>
</source>
<source>
<scope>test</scope>
<directory>src/test/java</directory>
</source>
</sources>
</build>
</project>
@@ -0,0 +1,10 @@
package com.ankurm.m4;
/** Tiny library class so the demo has something real to compile, test and package. */
public final class Greeter {
private Greeter() {}
public static String greet(String name) {
return "Hello, " + name + " (built with Maven 4)";
}
}
@@ -0,0 +1,12 @@
package com.ankurm.m4;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
class GreeterTest {
@Test
void greets() {
assertEquals("Hello, Ankur (built with Maven 4)", Greeter.greet("Ankur"));
}
}
@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- BUILD POM. Model 4.1.0: only Maven 4 can read this file. -->
<project xmlns="http://maven.apache.org/POM/4.1.0" root="true">
<modelVersion>4.1.0</modelVersion>
<groupId>com.ankurm.m4</groupId>
<artifactId>m4-demo</artifactId>
<version>${revision}</version>
<packaging>pom</packaging>
<properties>
<maven.compiler.release>21</maven.compiler.release>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<!-- 4.1.0: <subprojects> replaces <modules> -->
<subprojects>
<subproject>bom</subproject>
<subproject>lib</subproject>
<subproject>app</subproject>
</subprojects>
<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.14.1</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.4</version>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.4.2</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>3.1.4</version>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.3.1</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
+24
View File
@@ -0,0 +1,24 @@
#!/usr/bin/env bash
# Locate the Maven installs used for the captured runs. Override with environment variables.
# Defaults assume the tarballs were unpacked next to each other under $TOOLS.
TOOLS="${TOOLS:-$HOME/tools}"
export M4_HOME="${M4_HOME:-$TOOLS/apache-maven-4.0.0-rc-7}"
export M3_HOME="${M3_HOME:-$TOOLS/apache-maven-3.9.16}"
export MVND_HOME="${MVND_HOME:-$TOOLS/maven-mvnd-2.0.0-rc-3-linux-amd64}"
MODULE="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
export MODULE
OUT="$MODULE/output"; export OUT
# Fresh, isolated local repository so every run resolves and installs from scratch.
REPO="${REPO:-$MODULE/.m2repo}"; export REPO
# Strip environment noise and make paths stable so reruns diff cleanly.
clean() {
grep -v -E '^Picked up|^\[INFO\] (Downloading|Downloaded) from|prefixes|^WARNING: |^Nov |org.jline' \
| sed -e "s#$MODULE#<module>#g" -e "s#$REPO#<m2>#g" -e "s#$M4_HOME#<maven4>#g" \
-e "s#$M3_HOME#<maven3>#g" -e "s#$MVND_HOME#<mvnd>#g" \
-e "s#$JAVA_HOME#<jdk>#g" \
-e 's/ at [0-9.]* [kMG]B\/s//' -e 's/\[ *[0-9.]* s\]/[ x.xxx s]/' \
-e '/^\[INFO\] Total time:/d' -e '/^\[INFO\] Finished at:/d'
}
m4() { "$M4_HOME/bin/mvn" -B "$@"; }
m3() { "$M3_HOME/bin/mvn" -B "$@"; }
+109
View File
@@ -0,0 +1,109 @@
#!/usr/bin/env bash
# Regenerates every file in output/. Needs: JDK 25 on PATH (JAVA_HOME set), Maven 4.0.0-rc-7,
# Maven 3.9.16 and mvnd 2.0.0-rc-3 unpacked under $TOOLS (see scripts/env.sh), and network access.
set -u
. "$(dirname "$0")/env.sh"
mkdir -p "$OUT"; rm -f "$OUT"/*.txt
rm -rf "$REPO" "$REPO-flat"
fetch() { for i in 1 2 3 4 5; do r=$(curl -sf "$1") && { printf '%s\n' "$r"; return; }; sleep 3; done; echo "fetch failed: $1"; }
# 01 -- which Maven versions exist, and which one is GA? Straight from Maven Central metadata.
{
echo '$ curl -s https://repo1.maven.org/maven2/org/apache/maven/apache-maven/maven-metadata.xml | grep -E "<(latest|release|lastUpdated)>"'
fetch https://repo1.maven.org/maven2/org/apache/maven/apache-maven/maven-metadata.xml | grep -E '<(latest|release|lastUpdated)>'
echo
echo '$ ... | grep -E "<version>(4\.0\.0-rc|3\.10)" (4.x release candidates and the newest 3.x line)'
fetch https://repo1.maven.org/maven2/org/apache/maven/apache-maven/maven-metadata.xml | grep -E '<version>(4\.0\.0-rc|3\.10)'
echo
echo '$ mvn -v (Maven 4)'; "$M4_HOME/bin/mvn" -v 2>&1 | clean
echo
echo '$ mvn -v (Maven 3)'; "$M3_HOME/bin/mvn" -v 2>&1 | clean | head -3
} > "$OUT/01-versions.txt" 2>&1
cd "$MODULE/reactor"
# 02 -- build the 4.1.0 reactor with Maven 4
{ echo '$ mvn install'; m4 -Dmaven.repo.local="$REPO" install 2>&1 | clean; } > "$OUT/02-reactor-build.txt"
# 03 -- build POM vs consumer POM for m4-lib, as installed
L="$REPO/com/ankurm/m4/m4-lib/1.0.0-SNAPSHOT"
{
echo '$ ls m4-lib/1.0.0-SNAPSHOT'; ls "$L" | sed 's/^/ /'
echo
echo '$ diff -u m4-lib-1.0.0-SNAPSHOT-build.pom m4-lib-1.0.0-SNAPSHOT.pom'
diff -u "$L/m4-lib-1.0.0-SNAPSHOT-build.pom" "$L/m4-lib-1.0.0-SNAPSHOT.pom" | tail -n +3 | sed -E 's#^(@@.*@@).*#\1#'
} > "$OUT/03-lib-build-vs-consumer.txt"
{ echo '$ cat m4-app-1.0.0-SNAPSHOT.pom (consumer POM)'; cat "$REPO/com/ankurm/m4/m4-app/1.0.0-SNAPSHOT/m4-app-1.0.0-SNAPSHOT.pom"; echo
echo; echo '$ cat m4-bom-1.0.0-SNAPSHOT.pom (consumer POM of the bom-packaged subproject)'; cat "$REPO/com/ankurm/m4/m4-bom/1.0.0-SNAPSHOT/m4-bom-1.0.0-SNAPSHOT.pom"; echo
echo; echo '$ cat m4-demo-1.0.0-SNAPSHOT.pom (consumer POM of the root: properties and pluginManagement are still there)'; cat "$REPO/com/ankurm/m4/m4-demo/1.0.0-SNAPSHOT/m4-demo-1.0.0-SNAPSHOT.pom"; echo; } > "$OUT/04-app-and-bom-consumer-poms.txt"
# 05 -- Maven 3 trying to build the 4.1.0 project
{ echo '$ mvn package (Maven 3.9.16, same reactor)'; m3 -Dmaven.repo.local="$REPO" package 2>&1 | clean; } > "$OUT/05-maven3-reads-build-pom.txt"
# 06 -- Maven 3 consuming what Maven 4 published
cd "$MODULE/m3-consumer"
{
echo '$ mvn dependency:tree (Maven 3.9.16, model 4.0.0 project, depends on m4-app)'
m3 -Dmaven.repo.local="$REPO" compile dependency:tree 2>&1 | clean | grep -E 'dependency:|\+-|\\-|com.ankurm|BUILD|ERROR|compiler:'
echo
echo '$ java -cp target/classes:... demo.UsesLib'
m3 -q -Dmaven.repo.local="$REPO" dependency:build-classpath -Dmdep.outputFile=target/cp.txt >/dev/null 2>&1
java -cp "target/classes:$(cat target/cp.txt)" demo.UsesLib 2>&1 | clean
} > "$OUT/06-maven3-consumes-consumer-pom.txt"
# 07 -- flattened consumer POM
cd "$MODULE/reactor"
{
echo '$ mvn install -Dmaven.consumer.pom.flatten=true (separate local repository)'
m4 -Dmaven.repo.local="$REPO-flat" -Dmaven.consumer.pom.flatten=true -DskipTests install 2>&1 | clean | grep -E 'BUILD|Reactor Summary|SUCCESS|FAIL'
echo
echo '$ cat m4-lib-1.0.0-SNAPSHOT.pom (flattened consumer POM)'
cat "$REPO-flat/com/ankurm/m4/m4-lib/1.0.0-SNAPSHOT/m4-lib-1.0.0-SNAPSHOT.pom"; echo
echo; echo '$ ls m4-lib/1.0.0-SNAPSHOT (flattened)'; ls "$REPO-flat/com/ankurm/m4/m4-lib/1.0.0-SNAPSHOT" | sed 's/^/ /'
} > "$OUT/07-flatten.txt"
# 08/09 -- lifecycle
cd "$MODULE/lifecycle"
{ echo '$ mvn package (Maven 4)'; m4 -Dmaven.repo.local="$REPO" package 2>&1 | clean | grep -E 'HOOK|--- |BUILD|ERROR|WARN'
echo; echo '$ mvn clean (Maven 4)'; m4 -Dmaven.repo.local="$REPO" clean 2>&1 | clean | grep -E 'HOOK|--- |BUILD|ERROR|WARN'; } > "$OUT/08-lifecycle-maven4.txt"
{ echo '$ mvn package (Maven 3.9.16, same POM)'; m3 -Dmaven.repo.local="$REPO" package 2>&1 | clean | head -20; } > "$OUT/09-lifecycle-maven3.txt"
# 10-14 -- migration: legacy project
rm -rf "$MODULE/.work"; mkdir -p "$MODULE/.work"
cd "$MODULE/legacy-m3"
{ echo '$ mvn package (Maven 4, untouched Maven 3 style project)'; m4 -Dmaven.repo.local="$REPO" package 2>&1 | clean | grep -E 'WARN|---|BUILD|Compiling|ERROR|^ '; } > "$OUT/10-legacy-on-maven4.txt"
{ echo '$ mvn -fos WARN package (Maven 4: fail the build on any WARN)'; m4 -Dmaven.repo.local="$REPO" -fos WARN package 2>&1 | clean | grep -E 'WARN|BUILD|ERROR|Reactor Summary|SUCCESS|FAIL'; } > "$OUT/11-fail-on-severity.txt"
rm -rf legacy-m3/target; find . -name target -type d -prune -exec rm -rf {} +
cp -r "$MODULE/legacy-m3" "$MODULE/.work/legacy-upgraded"; cd "$MODULE/.work/legacy-upgraded"
{ echo '$ mvnup check'; "$M4_HOME/bin/mvnup" check -B 2>&1 | clean; } > "$OUT/12-mvnup-check.txt"
{ echo '$ mvnup apply --all'; "$M4_HOME/bin/mvnup" apply --all -B 2>&1 | clean; } > "$OUT/13-mvnup-apply.txt"
{ echo '$ diff -u legacy-m3/pom.xml (before) .../pom.xml (after)'; diff -u "$MODULE/legacy-m3/pom.xml" pom.xml | tail -n +3
echo; echo '$ diff -u core/pom.xml'; diff -u "$MODULE/legacy-m3/core/pom.xml" core/pom.xml | tail -n +3; } > "$OUT/14-mvnup-diff.txt"
{ echo '$ mvn package (Maven 4, after mvnup apply --all)'; m4 -Dmaven.repo.local="$REPO" package 2>&1 | clean | grep -E 'WARN|---|BUILD|Compiling|ERROR|^ '; } > "$OUT/15-upgraded-build.txt"
cd "$MODULE"; rm -rf "$MODULE/.work"
# 17 -- what mvnup says about itself
"$M4_HOME/bin/mvnup" --help 2>&1 | clean | sed '1i $ mvnup --help' > "$OUT/17-mvnup-help.txt"
# 16 -- mvnd 2.0.0-rc-3 vs plain Maven 4, same pre-populated local repository, offline (-o), tests skipped.
# Offline because the sandbox's egress proxy answers HTTP 429 when mvnd's parallel resolver opens many connections.
# Timings are indicative only: one machine, one run.
cd "$MODULE/reactor"
TIMEFORMAT='wall: %R s'
prep() { rm -rf "$1"; cp -r "$REPO" "$1"; find "$1" \( -name _remote.repositories -o -name '*.lastUpdated' \) -delete; }
prep "$REPO-mvnd"
{
echo '$ mvnd --version'; "$MVND_HOME/bin/mvnd" --version 2>&1 | clean
echo; echo '$ mvnd -o -DskipTests install (daemon starting)'
{ time "$MVND_HOME/bin/mvnd" -B -o -Dmaven.repo.local="$REPO-mvnd" -DskipTests install 2>&1 | clean | grep -E 'BUILD|ERROR|wall'; } 2>&1
echo; echo '$ mvnd -o -DskipTests install (daemon already running)'
{ time "$MVND_HOME/bin/mvnd" -B -o -Dmaven.repo.local="$REPO-mvnd" -DskipTests install 2>&1 | clean | grep -E 'BUILD|ERROR|wall'; } 2>&1
"$MVND_HOME/bin/mvnd" --stop 2>&1 | clean | tail -1
echo; echo '$ mvn -o -DskipTests install (plain Maven 4.0.0-rc-7, new JVM each time)'
{ time m4 -o -Dmaven.repo.local="$REPO-mvnd" -DskipTests install 2>&1 | clean | grep -E 'BUILD|ERROR'; } 2>&1
{ time m4 -o -Dmaven.repo.local="$REPO-mvnd" -DskipTests install 2>&1 | clean | grep -E 'BUILD|ERROR'; } 2>&1
} > "$OUT/16-mvnd.txt"
rm -rf "$REPO-mvnd"
find "$MODULE" -name target -type d -prune -exec rm -rf {} + 2>/dev/null
echo "done: $(ls "$OUT" | wc -l) files in $OUT"