enable build with Maven 4#1259
Conversation
|
#1275 fixed 2 ITs on <reporting>
<outputDirectory>/home/herve/dev/maven/sources/plugins/core/maven-site-plugin/target/it/inheritedReports/child/target/site</outputDirectory>
<plugins>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.9.0</version>
<reportSets>
<reportSet>
<reports>
<report>summary</report>
<report>index</report>
</reports>
</reportSet>
</reportSets>
</plugin>
</plugins>
</reporting>but with Maven 4.0.0-SNAPSHOT: <reporting>
<outputDirectory>/home/herve/dev/maven/sources/plugins/core/maven-site-plugin/target/it/inheritedReports/child/target/site</outputDirectory>
<plugins>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.9.0</version>
<reportSets>
<reportSet>
<reports>
<report>summary</report>
</reports>
</reportSet>
</reportSets>
</plugin>
</plugins>
</reporting>POM inheritance in Maven is the root cause here |
due not default plugin management? |
|
look at the XML fragment: this is |
|
checked that now only |
|
on now, need to dive into https://github.com/apache/maven-doxia-sitetools/blob/master/doxia-site-model/src/main/java/org/apache/maven/doxia/site/inheritance/DefaultSiteModelInheritanceAssembler.java |
|
Analysis done with AI: Why
|
repo-parent.getBasedir() |
Code path taken | Result | |
|---|---|---|---|
| Maven 3 | null |
repository artifact lookup | finds repo-parent-1.0-SNAPSHOT-site.xml in target/local-repo/ ✅ |
| Maven 4 | target/project-local-repo/.../repo-parent/1.0-SNAPSHOT/ |
filesystem lookup | looks for .../src/site/site.xml — not found ❌ |
The site.xml was present in project-local-repo/ as repo-parent-1.0-SNAPSHOT-site.xml (the build log shows it gets deleted at the end of the build by the root reactor's clean phase), but the artifact-based resolution is never attempted — the code only looks for src/site/site.xml under the basedir.
This is confirmed by the build log: [DEBUG] No parent level 3 site descriptor appears immediately after [DEBUG] Looking for site descriptor of level 3 parent project: repo-parent, with no artifact resolution attempt in between.
Cascade of effects
Since repo-parent's site.xml is never read, the entire parent chain returns null site models. getSiteModel() falls back to default-site.xml:
<bannerLeft name="${project.name}" />Late interpolation resolves ${project.name} to just child because Maven 4 no longer inherits <name> from parent POMs (consumer POMs do not propagate the <name> template), so project.name defaults to the artifactId.
Expected vs actual
| Check | Expected (Maven 3) | Actual (Maven 4) |
|---|---|---|
bannerLeft name for child |
bannerLeft project.artifactId = child |
child |
bannerLeft name for reactor-parent |
bannerLeft project.artifactId = reactor-parent |
reactor-parent |
| Source of site model | repo-parent/src/site/site.xml (via repository lookup) |
default-site.xml (fallback) |
Where to fix
The issue is in doxia-sitetools DefaultSiteTool.getSiteModel(): when project.getBasedir() != null but the filesystem lookup finds no site descriptor, it should fall back to the artifact-based repository lookup. That would correctly handle Maven 4's project-local-repo case, where a non-reactor parent has a non-null basedir pointing to a repository directory rather than a real source tree.

build with Maven 4 in CI, to check that maven-site-plugin works with Maven 4
and complete the table on https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=406620656#Maven4.0.0GAchecklist-Maven4API