commit f32c088174cd660cbb61bd8bbc611f46683e8db4 Author: Ankur Mhatre Date: Thu Nov 26 21:02:45 2026 +0530 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 Claude-Session: https://claude.ai/code/session_017ic4b4XrpfdpsacrvqnrBM diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..aa5473f --- /dev/null +++ b/LICENSE @@ -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. diff --git a/README.md b/README.md new file mode 100644 index 0000000..92961f2 --- /dev/null +++ b/README.md @@ -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. diff --git a/maven4-build-vs-consumer-pom/.gitignore b/maven4-build-vs-consumer-pom/.gitignore new file mode 100644 index 0000000..5a72cc1 --- /dev/null +++ b/maven4-build-vs-consumer-pom/.gitignore @@ -0,0 +1,2 @@ +target/ +.m2repo*/ diff --git a/maven4-build-vs-consumer-pom/README.md b/maven4-build-vs-consumer-pom/README.md new file mode 100644 index 0000000..abee709 --- /dev/null +++ b/maven4-build-vs-consumer-pom/README.md @@ -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: ``, inferred ``, `bom` packaging, ``, `${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`. diff --git a/maven4-build-vs-consumer-pom/legacy-m3/core/pom.xml b/maven4-build-vs-consumer-pom/legacy-m3/core/pom.xml new file mode 100644 index 0000000..f27609d --- /dev/null +++ b/maven4-build-vs-consumer-pom/legacy-m3/core/pom.xml @@ -0,0 +1,14 @@ + + + 4.0.0 + + + com.ankurm.legacy + legacy-parent + 1.0.0-SNAPSHOT + + + legacy-core + diff --git a/maven4-build-vs-consumer-pom/legacy-m3/core/src/main/java/demo/Hello.java b/maven4-build-vs-consumer-pom/legacy-m3/core/src/main/java/demo/Hello.java new file mode 100644 index 0000000..dd95226 --- /dev/null +++ b/maven4-build-vs-consumer-pom/legacy-m3/core/src/main/java/demo/Hello.java @@ -0,0 +1,5 @@ +package demo; + +public class Hello { + public static void main(String[] a) { System.out.println("legacy ok"); } +} diff --git a/maven4-build-vs-consumer-pom/legacy-m3/pom.xml b/maven4-build-vs-consumer-pom/legacy-m3/pom.xml new file mode 100644 index 0000000..a17e15d --- /dev/null +++ b/maven4-build-vs-consumer-pom/legacy-m3/pom.xml @@ -0,0 +1,23 @@ + + + + 4.0.0 + + com.ankurm.legacy + legacy-parent + 1.0.0-SNAPSHOT + pom + + + 17 + 17 + UTF-8 + legacy ${pom.version} + + + + core + + diff --git a/maven4-build-vs-consumer-pom/lifecycle/pom.xml b/maven4-build-vs-consumer-pom/lifecycle/pom.xml new file mode 100644 index 0000000..7787e4c --- /dev/null +++ b/maven4-build-vs-consumer-pom/lifecycle/pom.xml @@ -0,0 +1,78 @@ + + + + 4.1.0 + + com.ankurm.m4 + lifecycle-demo + 1.0.0 + + + 21 + + + + + + + maven-compiler-plugin + 3.14.1 + + + maven-resources-plugin + 3.3.1 + + + maven-surefire-plugin + 3.5.4 + + + maven-jar-plugin + 3.4.2 + + + maven-clean-plugin + 3.5.0 + + + + + + maven-antrun-plugin + 3.2.0 + + + before-compile + before:compile + run + + + + after-compile + after:compile + run + + + + before-package-first + before:package[100] + run + + + + before-package-second + before:package[200] + run + + + + after-clean + after:clean + run + + + + + + + diff --git a/maven4-build-vs-consumer-pom/lifecycle/src/main/java/demo/App.java b/maven4-build-vs-consumer-pom/lifecycle/src/main/java/demo/App.java new file mode 100644 index 0000000..f015a3a --- /dev/null +++ b/maven4-build-vs-consumer-pom/lifecycle/src/main/java/demo/App.java @@ -0,0 +1,5 @@ +package demo; + +public class App { + public static void main(String[] args) { System.out.println("lifecycle demo"); } +} diff --git a/maven4-build-vs-consumer-pom/m3-consumer/pom.xml b/maven4-build-vs-consumer-pom/m3-consumer/pom.xml new file mode 100644 index 0000000..3c5db25 --- /dev/null +++ b/maven4-build-vs-consumer-pom/m3-consumer/pom.xml @@ -0,0 +1,23 @@ + + + + 4.0.0 + + com.ankurm.m3 + m3-consumer + 1.0.0 + + + 21 + + + + + com.ankurm.m4 + m4-app + 1.0.0-SNAPSHOT + + + diff --git a/maven4-build-vs-consumer-pom/m3-consumer/src/main/java/demo/UsesLib.java b/maven4-build-vs-consumer-pom/m3-consumer/src/main/java/demo/UsesLib.java new file mode 100644 index 0000000..0e65ab1 --- /dev/null +++ b/maven4-build-vs-consumer-pom/m3-consumer/src/main/java/demo/UsesLib.java @@ -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")); + } +} diff --git a/maven4-build-vs-consumer-pom/output/01-versions.txt b/maven4-build-vs-consumer-pom/output/01-versions.txt new file mode 100644 index 0000000..3467327 --- /dev/null +++ b/maven4-build-vs-consumer-pom/output/01-versions.txt @@ -0,0 +1,29 @@ +$ curl -s https://repo1.maven.org/maven2/org/apache/maven/apache-maven/maven-metadata.xml | grep -E "<(latest|release|lastUpdated)>" + 4.0.0-rc-7 + 4.0.0-rc-7 + 20261122115858 + +$ ... | grep -E "(4\.0\.0-rc|3\.10)" (4.x release candidates and the newest 3.x line) + 3.10.0-rc-1 + 3.10.0 + 3.10.1 + 3.10.2 + 4.0.0-rc-1 + 4.0.0-rc-2 + 4.0.0-rc-3 + 4.0.0-rc-4 + 4.0.0-rc-5 + 4.0.0-rc-6 + 4.0.0-rc-7 + +$ mvn -v (Maven 4) +Apache Maven 4.0.0-rc-7 (6d8f301b38af7399b36b862969d520974944f0b9) +Maven home: +Java version: 25.0.5.1, vendor: Eclipse Adoptium, runtime: +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: +Java version: 25.0.5.1, vendor: Eclipse Adoptium, runtime: diff --git a/maven4-build-vs-consumer-pom/output/02-reactor-build.txt b/maven4-build-vs-consumer-pom/output/02-reactor-build.txt new file mode 100644 index 0000000..2cec280 --- /dev/null +++ b/maven4-build-vs-consumer-pom/output/02-reactor-build.txt @@ -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 /reactor/pom.xml to /.m2repo/com/ankurm/m4/m4-demo/1.0.0-SNAPSHOT/m4-demo-1.0.0-SNAPSHOT-build.pom +[INFO] Installing /reactor/target/consumer-1116901588741584337.pom to /.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 /reactor/bom/pom.xml to /.m2repo/com/ankurm/m4/m4-bom/1.0.0-SNAPSHOT/m4-bom-1.0.0-SNAPSHOT-build.pom +[INFO] Installing /reactor/bom/target/consumer-16063290251144019470.pom to /.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 /reactor/lib/src/main/resources +[INFO] skip non existing resourceDirectory /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 /reactor/lib/src/test/resources +[INFO] skip non existing resourceDirectory /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: /reactor/lib/target/m4-lib-1.0.0-SNAPSHOT.jar +[INFO] +[INFO] --- install:3.1.4:install (default-install) @ m4-lib --- +[INFO] Installing /reactor/lib/target/m4-lib-1.0.0-SNAPSHOT.jar to /.m2repo/com/ankurm/m4/m4-lib/1.0.0-SNAPSHOT/m4-lib-1.0.0-SNAPSHOT.jar +[INFO] Installing /reactor/lib/pom.xml to /.m2repo/com/ankurm/m4/m4-lib/1.0.0-SNAPSHOT/m4-lib-1.0.0-SNAPSHOT-build.pom +[INFO] Installing /reactor/lib/target/consumer-2827804096093025405.pom to /.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 /reactor/app/src/main/resources +[INFO] skip non existing resourceDirectory /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 /reactor/app/src/test/resources +[INFO] skip non existing resourceDirectory /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: /reactor/app/target/m4-app-1.0.0-SNAPSHOT.jar +[INFO] +[INFO] --- install:3.1.4:install (default-install) @ m4-app --- +[INFO] Installing /reactor/app/target/m4-app-1.0.0-SNAPSHOT.jar to /.m2repo/com/ankurm/m4/m4-app/1.0.0-SNAPSHOT/m4-app-1.0.0-SNAPSHOT.jar +[INFO] Installing /reactor/app/pom.xml to /.m2repo/com/ankurm/m4/m4-app/1.0.0-SNAPSHOT/m4-app-1.0.0-SNAPSHOT-build.pom +[INFO] Installing /reactor/app/target/consumer-10425969277783569583.pom to /.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] ------------------------------------------------------------------------ diff --git a/maven4-build-vs-consumer-pom/output/03-lib-build-vs-consumer.txt b/maven4-build-vs-consumer-pom/output/03-lib-build-vs-consumer.txt new file mode 100644 index 0000000..008c907 --- /dev/null +++ b/maven4-build-vs-consumer-pom/output/03-lib-build-vs-consumer.txt @@ -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 @@ + +- +- 4.1.0 +- +- +- ++ ++ 4.0.0 ++ ++ com.ankurm.m4 ++ m4-demo ++ 1.0.0-SNAPSHOT ++ + m4-lib +- jar +- + + + org.slf4j +@@ -26,18 +26,4 @@ + test + + +- +- +- +- +- +- main +- src/main/java +- +- +- test +- src/test/java +- +- +- +- ++ +\ No newline at end of file diff --git a/maven4-build-vs-consumer-pom/output/04-app-and-bom-consumer-poms.txt b/maven4-build-vs-consumer-pom/output/04-app-and-bom-consumer-poms.txt new file mode 100644 index 0000000..012187c --- /dev/null +++ b/maven4-build-vs-consumer-pom/output/04-app-and-bom-consumer-poms.txt @@ -0,0 +1,77 @@ +$ cat m4-app-1.0.0-SNAPSHOT.pom (consumer POM) + + + 4.0.0 + + com.ankurm.m4 + m4-demo + 1.0.0-SNAPSHOT + + m4-app + + + com.ankurm.m4 + m4-lib + 1.0.0-SNAPSHOT + + + + +$ cat m4-bom-1.0.0-SNAPSHOT.pom (consumer POM of the bom-packaged subproject) + + + 4.0.0 + com.ankurm.m4 + m4-bom + 1.0.0-SNAPSHOT + pom + + + + com.ankurm.m4 + m4-lib + 1.0.0-SNAPSHOT + + + + + +$ cat m4-demo-1.0.0-SNAPSHOT.pom (consumer POM of the root: properties and pluginManagement are still there) + + + 4.0.0 + com.ankurm.m4 + m4-demo + 1.0.0-SNAPSHOT + pom + + 21 + UTF-8 + + + + + + maven-compiler-plugin + 3.14.1 + + + maven-surefire-plugin + 3.5.4 + + + maven-jar-plugin + 3.4.2 + + + maven-install-plugin + 3.1.4 + + + maven-resources-plugin + 3.3.1 + + + + + diff --git a/maven4-build-vs-consumer-pom/output/05-maven3-reads-build-pom.txt b/maven4-build-vs-consumer-pom/output/05-maven3-reads-build-pom.txt new file mode 100644 index 0000000..54e24a7 --- /dev/null +++ b/maven4-build-vs-consumer-pom/output/05-maven3-reads-build-pom.txt @@ -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 /reactor/pom.xml: Unknown attribute 'root' for tag 'project' (position: START_TAG seen ...->\n... @3:64) @ /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} (/reactor/pom.xml) has 2 errors +[ERROR] Malformed POM /reactor/pom.xml: Unknown attribute 'root' for tag 'project' (position: START_TAG seen ...->\n... @3:64) @ /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 diff --git a/maven4-build-vs-consumer-pom/output/06-maven3-consumes-consumer-pom.txt b/maven4-build-vs-consumer-pom/output/06-maven3-consumes-consumer-pom.txt new file mode 100644 index 0000000..ea87886 --- /dev/null +++ b/maven4-build-vs-consumer-pom/output/06-maven3-consumes-consumer-pom.txt @@ -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) diff --git a/maven4-build-vs-consumer-pom/output/07-flatten.txt b/maven4-build-vs-consumer-pom/output/07-flatten.txt new file mode 100644 index 0000000..6dfb0cf --- /dev/null +++ b/maven4-build-vs-consumer-pom/output/07-flatten.txt @@ -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) + + + 4.0.0 + com.ankurm.m4 + m4-lib + 1.0.0-SNAPSHOT + + + org.slf4j + slf4j-api + 2.0.17 + compile + + + + +$ 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 diff --git a/maven4-build-vs-consumer-pom/output/08-lifecycle-maven4.txt b/maven4-build-vs-consumer-pom/output/08-lifecycle-maven4.txt new file mode 100644 index 0000000..f5c7ec3 --- /dev/null +++ b/maven4-build-vs-consumer-pom/output/08-lifecycle-maven4.txt @@ -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 diff --git a/maven4-build-vs-consumer-pom/output/09-lifecycle-maven3.txt b/maven4-build-vs-consumer-pom/output/09-lifecycle-maven3.txt new file mode 100644 index 0000000..2ebed5c --- /dev/null +++ b/maven4-build-vs-consumer-pom/output/09-lifecycle-maven3.txt @@ -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 /lifecycle/pom.xml: Unknown attribute 'root' for tag 'project' (position: START_TAG seen ...->\n... @3:64) @ /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 (/lifecycle/pom.xml) has 2 errors +[ERROR] Malformed POM /lifecycle/pom.xml: Unknown attribute 'root' for tag 'project' (position: START_TAG seen ...->\n... @3:64) @ /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 diff --git a/maven4-build-vs-consumer-pom/output/10-legacy-on-maven4.txt b/maven4-build-vs-consumer-pom/output/10-legacy-on-maven4.txt new file mode 100644 index 0000000..705f1f5 --- /dev/null +++ b/maven4-build-vs-consumer-pom/output/10-legacy-on-maven4.txt @@ -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] ------------------------------------------------------------------------ diff --git a/maven4-build-vs-consumer-pom/output/11-fail-on-severity.txt b/maven4-build-vs-consumer-pom/output/11-fail-on-severity.txt new file mode 100644 index 0000000..d4af3d8 --- /dev/null +++ b/maven4-build-vs-consumer-pom/output/11-fail-on-severity.txt @@ -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 diff --git a/maven4-build-vs-consumer-pom/output/12-mvnup-check.txt b/maven4-build-vs-consumer-pom/output/12-mvnup-check.txt new file mode 100644 index 0000000..b6d6af0 --- /dev/null +++ b/maven4-build-vs-consumer-pom/output/12-mvnup-check.txt @@ -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] /.work/legacy-upgraded/pom.xml (current: 4.0.0) +[INFO] ? No inference optimizations needed +[INFO] /.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] /.work/legacy-upgraded/pom.xml (checking for duplicate XML elements) +[INFO] ? No duplicate XML elements found +[INFO] /.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] /.work/legacy-upgraded/pom.xml (checking for Maven 4 compatibility issues) +[INFO] ? No Maven 4 compatibility issues found +[INFO] /.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] /.work/legacy-upgraded/pom.xml (checking for duplicate declarations) +[INFO] ? No duplicate declarations found +[INFO] /.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] /.work/legacy-upgraded/pom.xml (checking for antrun JavaScript usage) +[INFO] ? No antrun JavaScript usage found +[INFO] /.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] /.work/legacy-upgraded/pom.xml (checking for RequireMavenVersion range restrictions) +[INFO] ? No RequireMavenVersion range restrictions found +[INFO] /.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] /.work/legacy-upgraded/pom.xml (checking for resource filtering of binary files) +[INFO] ? No resource filtering issues found +[INFO] /.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] /.work/legacy-upgraded/pom.xml (checking JDK source level compatibility) +[INFO] ? --source 17 is supported by all current JDKs +[INFO] /.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] /.work/legacy-upgraded/pom.xml (checking for HTTP repository URLs) +[INFO] ? No HTTP repository URLs found +[INFO] /.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] /.work/legacy-upgraded/pom.xml (checking Automatic-Module-Name entries) +[INFO] ? No invalid Automatic-Module-Name entries found +[INFO] /.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] /.work/legacy-upgraded/pom.xml (checking for plugin upgrades) +[INFO] ? No plugin upgrades needed +[INFO] /.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 /.work/legacy-upgraded/.mvn diff --git a/maven4-build-vs-consumer-pom/output/13-mvnup-apply.txt b/maven4-build-vs-consumer-pom/output/13-mvnup-apply.txt new file mode 100644 index 0000000..b45dea4 --- /dev/null +++ b/maven4-build-vs-consumer-pom/output/13-mvnup-apply.txt @@ -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 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] /.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 to +[INFO] ? Converted 1 elements to +[INFO] ? Model upgrade completed +[INFO] /.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] /.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] /.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] /.work/legacy-upgraded/pom.xml (checking for duplicate XML elements) +[INFO] ? No duplicate XML elements found +[INFO] /.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] /.work/legacy-upgraded/pom.xml (checking for Maven 4 compatibility issues) +[INFO] ? No Maven 4 compatibility issues found +[INFO] /.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 elements === +[INFO] Migrating source configuration to elements +[INFO] /.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 elements +[INFO] /.work/legacy-upgraded/core/pom.xml (current: 4.1.0) +[INFO] ? No source configuration to migrate +[INFO] +[INFO] Migrating source configuration to 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] /.work/legacy-upgraded/pom.xml (checking for duplicate declarations) +[INFO] ? No duplicate declarations found +[INFO] /.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] /.work/legacy-upgraded/pom.xml (checking for antrun JavaScript usage) +[INFO] ? No antrun JavaScript usage found +[INFO] /.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] /.work/legacy-upgraded/pom.xml (checking for RequireMavenVersion range restrictions) +[INFO] ? No RequireMavenVersion range restrictions found +[INFO] /.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] /.work/legacy-upgraded/pom.xml (checking for resource filtering of binary files) +[INFO] ? No resource filtering issues found +[INFO] /.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] /.work/legacy-upgraded/pom.xml (checking JDK source level compatibility) +[INFO] ? --source 17 is supported by all current JDKs +[INFO] /.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] /.work/legacy-upgraded/pom.xml (checking for HTTP repository URLs) +[INFO] ? No HTTP repository URLs found +[INFO] /.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] /.work/legacy-upgraded/pom.xml (checking Automatic-Module-Name entries) +[INFO] ? No invalid Automatic-Module-Name entries found +[INFO] /.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] /.work/legacy-upgraded/pom.xml (checking for plugin upgrades) +[INFO] ? No plugin upgrades needed +[INFO] /.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 /.work/legacy-upgraded/.mvn +[INFO] +[INFO] Saving modified POMs... +[INFO] ? Saved: /.work/legacy-upgraded/pom.xml +[INFO] ? Saved: /.work/legacy-upgraded/core/pom.xml +[INFO] ? All modifications saved successfully diff --git a/maven4-build-vs-consumer-pom/output/14-mvnup-diff.txt b/maven4-build-vs-consumer-pom/output/14-mvnup-diff.txt new file mode 100644 index 0000000..bbe0833 --- /dev/null +++ b/maven4-build-vs-consumer-pom/output/14-mvnup-diff.txt @@ -0,0 +1,55 @@ +$ diff -u legacy-m3/pom.xml (before) .../pom.xml (after) +@@ -1,9 +1,8 @@ + + +- +- 4.0.0 ++ xsi:schemaLocation="http://maven.apache.org/POM/4.1.0 https://maven.apache.org/xsd/maven-4.1.0.xsd"> + + com.ankurm.legacy + legacy-parent +@@ -11,13 +10,16 @@ + pom + + +- 17 +- 17 + UTF-8 + legacy ${pom.version} + + +- +- core +- ++ ++ ++ ++ 17 ++ ++ ++ ++ + + +$ diff -u core/pom.xml +@@ -1,14 +1,10 @@ + +- +- 4.0.0 ++ xsi:schemaLocation="http://maven.apache.org/POM/4.1.0 https://maven.apache.org/xsd/maven-4.1.0.xsd"> + + +- com.ankurm.legacy +- legacy-parent +- 1.0.0-SNAPSHOT +- ++ + + legacy-core + diff --git a/maven4-build-vs-consumer-pom/output/15-upgraded-build.txt b/maven4-build-vs-consumer-pom/output/15-upgraded-build.txt new file mode 100644 index 0000000..9119e68 --- /dev/null +++ b/maven4-build-vs-consumer-pom/output/15-upgraded-build.txt @@ -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] ------------------------------------------------------------------------ diff --git a/maven4-build-vs-consumer-pom/output/16-mvnd.txt b/maven4-build-vs-consumer-pom/output/16-mvnd.txt new file mode 100644 index 0000000..3362227 --- /dev/null +++ b/maven4-build-vs-consumer-pom/output/16-mvnd.txt @@ -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: /mvn +Java version: 25.0.5.1, vendor: Eclipse Adoptium, runtime: +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 diff --git a/maven4-build-vs-consumer-pom/output/17-mvnup-help.txt b/maven4-build-vs-consumer-pom/output/17-mvnup-help.txt new file mode 100644 index 0000000..3ec40d0 --- /dev/null +++ b/maven4-build-vs-consumer-pom/output/17-mvnup-help.txt @@ -0,0 +1,84 @@ +$ mvnup --help + +usage: mvnup [options] [ ...] + +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 Defines the color mode of the output. + Supported are 'auto', 'always', 'never'. + -D,--define Define a user property + -d,--directory 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 Configure which severity of logging + should cause the build to fail + -gs,--global-settings Alternate path for the + global settings file. + -gt,--global-toolchains Alternate path for the + global toolchains file. + -h,--help Display help information + -i,--infer Use inference when upgrading (remove + redundant information) + -is,--install-settings Alternate path for the installation + settings file + -it,--install-toolchains Alternate path for the installation + toolchains file + -l,--log-file Log file where all build output will go + (disables output color) + -m,--model-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 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 Alternate path for the user settings + file + --shell Launch the Maven Shell tool (script + option). + -t,--toolchains 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 Target POM model version (4.0.0 or 4.1.0) + -d, --directory 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 + diff --git a/maven4-build-vs-consumer-pom/reactor/.mvn/maven.config b/maven4-build-vs-consumer-pom/reactor/.mvn/maven.config new file mode 100644 index 0000000..009da89 --- /dev/null +++ b/maven4-build-vs-consumer-pom/reactor/.mvn/maven.config @@ -0,0 +1 @@ +-Drevision=1.0.0-SNAPSHOT diff --git a/maven4-build-vs-consumer-pom/reactor/app/pom.xml b/maven4-build-vs-consumer-pom/reactor/app/pom.xml new file mode 100644 index 0000000..316257e --- /dev/null +++ b/maven4-build-vs-consumer-pom/reactor/app/pom.xml @@ -0,0 +1,17 @@ + + + 4.1.0 + + + + m4-app + jar + + + + + com.ankurm.m4 + m4-lib + + + diff --git a/maven4-build-vs-consumer-pom/reactor/app/src/main/java/com/ankurm/m4/app/Main.java b/maven4-build-vs-consumer-pom/reactor/app/src/main/java/com/ankurm/m4/app/Main.java new file mode 100644 index 0000000..95eff0f --- /dev/null +++ b/maven4-build-vs-consumer-pom/reactor/app/src/main/java/com/ankurm/m4/app/Main.java @@ -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")); + } +} diff --git a/maven4-build-vs-consumer-pom/reactor/bom/pom.xml b/maven4-build-vs-consumer-pom/reactor/bom/pom.xml new file mode 100644 index 0000000..fcdc461 --- /dev/null +++ b/maven4-build-vs-consumer-pom/reactor/bom/pom.xml @@ -0,0 +1,21 @@ + + + 4.1.0 + + + + + m4-bom + + bom + + + + + com.ankurm.m4 + m4-lib + ${project.version} + + + + diff --git a/maven4-build-vs-consumer-pom/reactor/lib/pom.xml b/maven4-build-vs-consumer-pom/reactor/lib/pom.xml new file mode 100644 index 0000000..2c6c548 --- /dev/null +++ b/maven4-build-vs-consumer-pom/reactor/lib/pom.xml @@ -0,0 +1,43 @@ + + + 4.1.0 + + + + m4-lib + jar + + + + org.slf4j + slf4j-api + 2.0.17 + + + jakarta.servlet + jakarta.servlet-api + 6.1.0 + provided + + + org.junit.jupiter + junit-jupiter + 5.13.4 + test + + + + + + + + main + src/main/java + + + test + src/test/java + + + + diff --git a/maven4-build-vs-consumer-pom/reactor/lib/src/main/java/com/ankurm/m4/Greeter.java b/maven4-build-vs-consumer-pom/reactor/lib/src/main/java/com/ankurm/m4/Greeter.java new file mode 100644 index 0000000..cc3378f --- /dev/null +++ b/maven4-build-vs-consumer-pom/reactor/lib/src/main/java/com/ankurm/m4/Greeter.java @@ -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)"; + } +} diff --git a/maven4-build-vs-consumer-pom/reactor/lib/src/test/java/com/ankurm/m4/GreeterTest.java b/maven4-build-vs-consumer-pom/reactor/lib/src/test/java/com/ankurm/m4/GreeterTest.java new file mode 100644 index 0000000..4d00f2e --- /dev/null +++ b/maven4-build-vs-consumer-pom/reactor/lib/src/test/java/com/ankurm/m4/GreeterTest.java @@ -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")); + } +} diff --git a/maven4-build-vs-consumer-pom/reactor/pom.xml b/maven4-build-vs-consumer-pom/reactor/pom.xml new file mode 100644 index 0000000..fbd83ad --- /dev/null +++ b/maven4-build-vs-consumer-pom/reactor/pom.xml @@ -0,0 +1,49 @@ + + + + 4.1.0 + + com.ankurm.m4 + m4-demo + ${revision} + pom + + + 21 + UTF-8 + + + + + bom + lib + app + + + + + + + maven-compiler-plugin + 3.14.1 + + + maven-surefire-plugin + 3.5.4 + + + maven-jar-plugin + 3.4.2 + + + maven-install-plugin + 3.1.4 + + + maven-resources-plugin + 3.3.1 + + + + + diff --git a/maven4-build-vs-consumer-pom/scripts/env.sh b/maven4-build-vs-consumer-pom/scripts/env.sh new file mode 100755 index 0000000..8de7b89 --- /dev/null +++ b/maven4-build-vs-consumer-pom/scripts/env.sh @@ -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##g" -e "s#$REPO##g" -e "s#$M4_HOME##g" \ + -e "s#$M3_HOME##g" -e "s#$MVND_HOME##g" \ + -e "s#$JAVA_HOME##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 "$@"; } diff --git a/maven4-build-vs-consumer-pom/scripts/run-all.sh b/maven4-build-vs-consumer-pom/scripts/run-all.sh new file mode 100755 index 0000000..cec7432 --- /dev/null +++ b/maven4-build-vs-consumer-pom/scripts/run-all.sh @@ -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 "(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 '(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"