Skip to content

enable build with Maven 4#1259

Open
hboutemy wants to merge 1 commit into
masterfrom
maven4-enabled
Open

enable build with Maven 4#1259
hboutemy wants to merge 1 commit into
masterfrom
maven4-enabled

Conversation

@hboutemy

@hboutemy hboutemy commented Apr 3, 2026

Copy link
Copy Markdown
Member

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

@Bukama

Bukama commented May 10, 2026

Copy link
Copy Markdown
Contributor

I checked the build and collected some information from the logs

[ERROR] The following builds failed:
[ERROR] *  default-reports\pom.xml
[ERROR] *  inheritance-interpolation\pom.xml
[ERROR] *  inheritedReports\pom.xml
[ERROR] *  site-sd-stagingSiteURL\pom.xml

default-reports

Assertion failed: 

assert new File( sitedir, 'plugin-management.html' ).exists()
       |         |                                   |
       |         |                                   false
       |         D:\Github\Maven\maven-site-plugin\target\it\default-reports\target\site
       D:\Github\Maven\maven-site-plugin\target\it\default-reports\target\site\plugin-management.html

only the following files exists

  • depdency-info.html
  • plugins.html
  • project-info.html
  • summary.html

I have something in mind, that Maven 4 has no pluginManagement section by default? And as the default value for "skip If empty" is true, it would not get generated.

When executed with Maven 3.9.15 the report is generated and contains 4 plugins.

image

inheritance-interpolation

Assertion failed: 

assert childContent.contains( 'project.artifactId = child' )
       |            |
       |            false
       '<!DOCTYPE html>\r\n\r\n\r\n<!--\r\n | Generated by Apache Maven Doxia Site Renderer 2.1.0 from src/site/apt/index.apt at 2026-05-10\r\n | Rendered using Apache Maven Fluido Skin 2.0.0-M9\r\n-->\r\n<html xmlns="http://www.w3.org/1999/xhtml" lang="en">\r\n  <head>\r\n    <meta charset="UTF-8" />\r\n    <meta name="viewport" content="width=device-width, initial-scale=1" />\r\n    <meta name="generator" content="Apache Maven Doxia Site Renderer 2.1.0" />\r\n    <meta name="author" content="Hervé Boutemy" />\r\n    <meta name="date" content="2016-01-10" />\r\n    <title>POMs and Site Model Inheritance and Interpolation – child</title>\r\n    <link rel="stylesheet" href="./css/apache-maven-fluido-2.0.0-M9.min.css" />\r\n    <link rel="stylesheet" href="./css/site.css" />\r\n    <link rel="stylesheet" href="./css/print.css" media="print" />\r\n    <script src="./js/apache-maven-fluido-2.0.0-M9.min.js"></script>\r\n  </head>\r\n  <body>\r\n    <div class="container-fluid container-fluid-top">\r\n      <header>\r\n        <div id="banner">\r\n          <div class="pull-left"><div id="bannerLeft"><h1>child</h1></div></div>\r\n          <div class="pull-right"></div>\r\n          <div class="clear"><hr/></div>\r\n        </div>\r\n\r\n        <div id="breadcrumbs">\r\n          <ul class="breadcrumb">\r\n        <li id="publishDate">Last Published: 1980-02-01<span class="divider">|</span>\r\n</li>\r\n          <li id="projectVersion">Version: 1.0-SNAPSHOT</li>\r\n        <li class="pull-right"><a href="./">child</a></li>\r\n          </ul>\r\n        </div>\r\n      </header>\r\n      <div class="row-fluid">\r\n        <header id="leftColumn" class="span2">\r\n          <nav class="well sidebar-nav">\r\n  <ul class="nav nav-list">\r\n   <li class="nav-header">Parent Project</li>\r\n    <li><a href="../index.html">reactor-parent</a></li>\r\n  </ul>\r\n          </nav>\r\n          <div class="well sidebar-nav">\r\n            <div id="poweredBy">\r\n              <div class="clear"></div>\r\n              <div class="clear"></div>\r\n<a href="https://maven.apache.org/" class="builtBy" target="_blank"><img class="builtBy" alt="Built by Maven" src="./images/logos/maven-feather.png" /></a>\r\n            </div>\r\n          </div>\r\n        </header>\r\n        <main id="bodyColumn" class="span10">\r\n<section><a id="POMs_and_Site_Model_Inheritance_and_Interpolation"></a>\r\n<h1>POMs and Site Model Inheritance and Interpolation</h1>\r\n<ul>\r\n<li><a href="./pom.html"> POM Inheritance and Interpolation</a></li>\r\n<li>Site Model Inheritance and Interpolation: see this page</li></ul></section>\r\n        </main>\r\n      </div>\r\n    </div>\r\n    <hr/>\r\n    <footer>\r\n      <div class="container-fluid">\r\n        <div class="row-fluid">\r\n            <p>©      2026\r\n</p>\r\n        </div>\r\n      </div>\r\n    </footer>\r\n<script>\r\n  if(anchors) {\r\n    anchors.add();\r\n  }\r\n</script>\r\n  </body>\r\n</html>\r\n'

inheritedReports

no index file in parent or is a directory

Means that there should be a index.html be created, but it's not.

site-sd-stagingSiteURL

[ERROR] The build could not read 1 project -> [Help 1]
org.apache.maven.project.ProjectBuildingException: Some problems were encountered while processing the POMs

[ERROR]   The project [inherited]:MSITE-649:jar:[inherited] (D:\Github\Maven\maven-site-plugin\target\it\site-sd-stagingSiteURL\pom.xml) has 1 error
[ERROR]     The parents form a cycle: org.apache.maven.plugins.site.its:MSITE-649-parent:1.0-SNAPSHOT -> D:\Github\Maven\maven-site-plugin\target\it\site-sd-stagingSiteURL\parent\pom.xml -> org.apache:apache:32 -> D:\Github\Maven\maven-site-plugin\target\it\site-sd-stagingSiteURL\pom.xml -> org.apache.maven.plugins.site.its:MSITE-649-parent:1.0-SNAPSHOT

@hboutemy

Copy link
Copy Markdown
Member Author

#1275 fixed 2 ITs

on inheritedReports, I added help:effective-pom to the IT execution and found that with Maven 3 we get

    <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

@Bukama

Bukama commented May 31, 2026

Copy link
Copy Markdown
Contributor

POM inheritance in Maven is the root cause here

due not default plugin management?

@hboutemy

hboutemy commented Jun 1, 2026

Copy link
Copy Markdown
Member Author

look at the XML fragment: this is <reporting>

@hboutemy

hboutemy commented Jun 6, 2026

Copy link
Copy Markdown
Member Author

checked that inheritedReports is fixed bu apache/maven#12245

now only inheritance-interpolation issue remains: need to investigate

@hboutemy

hboutemy commented Jun 6, 2026

Copy link
Copy Markdown
Member Author

@hboutemy

hboutemy commented Jun 6, 2026

Copy link
Copy Markdown
Member Author

Analysis done with AI:

Why inheritance-interpolation IT fails with Maven 4 but passes with Maven 3

Root cause: Maven 4's project-local-repo

Maven 4 introduces a session-scoped project-local-repo (target/project-local-repo/) — a flat repository (groupId as dots, not slashes) that stores consumer POMs for all projects involved in the build, including non-reactor parents.

During Maven 4's reactor initialization, when resolving relative-parent (via relativePath) and then its parent repo-parent (from the local repo), Maven 4 creates a project-local-repo entry for repo-parent and sets MavenProject.getBasedir() to that project-local-repo directory:

target/project-local-repo/org.apache.maven.plugins.site.its.inheritance-interpolation/repo-parent/1.0-SNAPSHOT/

How this breaks doxia-sitetools

In DefaultSiteTool.getSiteModel(), the site descriptor lookup path is chosen based on project.getBasedir():

if (project.getBasedir() == null) {
    // POM is in the repository: resolve site descriptor as artifact
    siteDescriptor = getSiteDescriptorFromRepository(project, repoSession, ...);
} else {
    // POM is in build directory: look for site descriptor as local file
    siteDescriptor = getSiteDescriptor(siteDirectory, locale); // looks for src/site/site.xml
}
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants