Skip to content

[MSITE-1033] Detect inheritance for SCM site URLs - #1297

Merged
slachiewicz merged 2 commits into
masterfrom
MSITE-1033
Sep 6, 2026
Merged

[MSITE-1033] Detect inheritance for SCM site URLs#1297
slachiewicz merged 2 commits into
masterfrom
MSITE-1033

Conversation

@slachiewicz

@slachiewicz slachiewicz commented Aug 19, 2026

Copy link
Copy Markdown
Member

Fixes #1159. Same approach as #227, rebased onto current master, which #227 no longer merges cleanly against — credit to @kwin for the diagnosis and for the unwrap-then-compare shape.

getTopLevelProject compares distributionManagement.site.url through URIPathDescriptor.sameSite(), which needs a hierarchical URI. An SCM URL such as scm:git:https://github.com/org/repo.git is opaque, so scheme, host and port parse as scm, null and -1: every SCM URL matches every other, and a project inherits a top-level project it shares nothing with.

Two parts, and the second is easy to miss:

  1. Unwrap the provider-specific part through ScmUrlUtils, converting SCP-like git@host:path to ssh://host/path and normalising svn https to http, so the two access schemes of one repository still match.
  2. Compare host and path. Unwrapping alone leaves two repositories on one forge sharing scheme, host and port, so sameSite() still calls them one site. For an SCM URL the path names the repository, so the child path must lie under the parent path, whole segments only, so /foo does not contain /foobar.

Deployment URLs keep sameSite() unchanged. Applying the path rule to every URL breaks the site-inheritance IT, which covers a child sitting at an unrelated path on the same server and still being staged as part of its parent site. That looks deliberate, and this change leaves it alone rather than deciding it.

Six unit tests, including the sibling-repository case that fails with unwrapping alone. All 62 integration tests pass.

Verified: with 3.22.1-SNAPSHOT, plexus-xml — a single-module project whose site URL is an SCM URL — stages into target/staging with 216 files, where 3.22.0 staged into target/staging/../plexus-xml.git with none. That is the downstream report in codehaus-plexus/plexus-pom#333.

This change was created with AI assistance.

@slachiewicz slachiewicz added the enhancement New feature or request label Aug 19, 2026
@slachiewicz
slachiewicz marked this pull request as ready for review August 19, 2026 06:17
@slachiewicz
slachiewicz requested a lite review from Copilot August 19, 2026 06:17

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses MSITE-1033 by fixing how AbstractDeployMojo#getTopLevelProject determines site inheritance when distributionManagement.site.url uses SCM URL formats, avoiding false matches caused by opaque scm:* URIs.

Changes:

  • Unwrap SCM URLs via ScmUrlUtils and compare resulting URIs using host + path containment logic.
  • Add unit tests covering SCM URL inheritance scenarios (including sibling repos on the same host) and SVN scheme normalization.
  • Add maven-scm-api dependency to access ScmUrlUtils.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

File Description
src/main/java/org/apache/maven/plugins/site/deploy/AbstractDeployMojo.java Adds SCM URL unwrapping + new site-comparison logic and uses it in getTopLevelProject.
src/test/java/org/apache/maven/plugins/site/deploy/AbstractDeployMojoTest.java Adds focused unit tests for SCM URL inheritance detection and URL normalization.
pom.xml Adds maven-scm-api dependency required for SCM URL parsing utilities.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/main/java/org/apache/maven/plugins/site/deploy/AbstractDeployMojo.java Outdated
Comment thread src/main/java/org/apache/maven/plugins/site/deploy/AbstractDeployMojo.java Outdated
Comment thread src/main/java/org/apache/maven/plugins/site/deploy/AbstractDeployMojo.java Outdated
getTopLevelProject compares distributionManagement.site.url through
URIPathDescriptor.sameSite(), which needs a hierarchical URI. An SCM URL
such as scm:git:https://github.com/org/repo.git is opaque, so scheme,
host and port all parse as scm, null and -1, every SCM URL matches every
other, and a project inherits a top level project it shares nothing with.

Unwrap the provider specific part first, through ScmUrlUtils, converting
SCP-like git@host:path to ssh://host/path and normalising svn https to
http so the two access schemes of one repository still match.

Unwrapping alone is not enough. Two repositories on one forge share
scheme, host and port, so sameSite() still calls them one site. For SCM
URLs the path names the repository, so require the host to match and the
child path to lie under the parent path, comparing whole segments so that
/foo does not contain /foobar.

Deployment URLs keep sameSite() unchanged. The site-inheritance IT covers
a child that sits at an unrelated path on the same server and is still
staged as part of its parent's site, and that stays true.

Verified: with 3.22.1-SNAPSHOT, plexus-xml, a single module project whose
site URL is an SCM URL, stages into target/staging with 216 files, where
3.22.0 staged into target/staging/../plexus-xml.git with none. All 62
integration tests pass.
@slachiewicz
slachiewicz merged commit e643239 into master Sep 6, 2026
15 checks passed
@slachiewicz
slachiewicz deleted the MSITE-1033 branch September 6, 2026 20:02
@github-actions

github-actions Bot commented Sep 6, 2026

Copy link
Copy Markdown

@slachiewicz The PR can't be associated to a milestone, because there are multiple open milestones. Please add the text "branch: master" to the description to the milestone where this PR belongs to.

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

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[MSITE-1033] AbstractDeployMojo.getTopLevelProject(Project) returns wrong project for SCM URLs

2 participants