[MSITE-1033] Detect inheritance for SCM site URLs - #1297
Merged
Conversation
There was a problem hiding this comment.
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
ScmUrlUtilsand 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-apidependency to accessScmUrlUtils.
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.
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
force-pushed
the
MSITE-1033
branch
from
August 19, 2026 06:37
d6f8ef0 to
aa86698
Compare
…keted IPv6, and port check
|
@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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
getTopLevelProjectcomparesdistributionManagement.site.urlthroughURIPathDescriptor.sameSite(), which needs a hierarchical URI. An SCM URL such asscm:git:https://github.com/org/repo.gitis opaque, so scheme, host and port parse asscm,nulland-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:
ScmUrlUtils, converting SCP-likegit@host:pathtossh://host/pathand normalising svnhttpstohttp, so the two access schemes of one repository still match.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/foodoes not contain/foobar.Deployment URLs keep
sameSite()unchanged. Applying the path rule to every URL breaks thesite-inheritanceIT, 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/stagingwith 216 files, where 3.22.0 staged intotarget/staging/../plexus-xml.gitwith none. That is the downstream report in codehaus-plexus/plexus-pom#333.This change was created with AI assistance.