This is an automated email from the ASF dual-hosted git repository.
slachiewicz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-site-plugin.git
The following commit(s) were added to refs/heads/master by this push:
new e95d99bb [MSITE-948] Respect child.site.url.inherit.append.path when
staging
e95d99bb is described below
commit e95d99bb1f6dba9676ee15f291bd15fae21f27a3
Author: Sylwester Lachiewicz <[email protected]>
AuthorDate: Wed Nov 4 08:59:08 2026 +0000
[MSITE-948] Respect child.site.url.inherit.append.path when staging
A parent that sets child.site.url.inherit.append.path="false" does not host
its children below its own site url, so it is not the top site of a child whose
url lies outside of it. Children that inherit the same url, or declare one
below it, still group with the parent.
---
.../invoker.properties | 19 ++++++++
.../site-sd-parent-no-append-path/parent/pom.xml | 51 ++++++++++++++++++++++
.../projects/site-sd-parent-no-append-path/pom.xml | 46 +++++++++++++++++++
.../site-sd-parent-no-append-path/verify.groovy | 38 ++++++++++++++++
.../plugins/site/deploy/AbstractDeployMojo.java | 8 ++++
.../site/deploy/AbstractDeployMojoTest.java | 44 +++++++++++++++++++
6 files changed, 206 insertions(+)
diff --git a/src/it/projects/site-sd-parent-no-append-path/invoker.properties
b/src/it/projects/site-sd-parent-no-append-path/invoker.properties
new file mode 100644
index 00000000..2d691480
--- /dev/null
+++ b/src/it/projects/site-sd-parent-no-append-path/invoker.properties
@@ -0,0 +1,19 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+invoker.goals.1 = clean
+invoker.goals.2 = site:site site:deploy site:stage site:stage-deploy
diff --git a/src/it/projects/site-sd-parent-no-append-path/parent/pom.xml
b/src/it/projects/site-sd-parent-no-append-path/parent/pom.xml
new file mode 100644
index 00000000..5c9483db
--- /dev/null
+++ b/src/it/projects/site-sd-parent-no-append-path/parent/pom.xml
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.maven.plugins.its.noappendpath</groupId>
+ <artifactId>base-parent</artifactId>
+ <packaging>pom</packaging>
+ <version>1.0-SNAPSHOT</version>
+
+ <name>base-parent</name>
+
+ <distributionManagement>
+ <site child.site.url.inherit.append.path="false">
+ <id>website</id>
+
<url>file://@project.build.directory@/it/site-sd-parent-no-append-path/parent-deploy</url>
+ </site>
+ </distributionManagement>
+
+ <build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-site-plugin</artifactId>
+ <version>@project.version@</version>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+</project>
diff --git a/src/it/projects/site-sd-parent-no-append-path/pom.xml
b/src/it/projects/site-sd-parent-no-append-path/pom.xml
new file mode 100644
index 00000000..cb96d899
--- /dev/null
+++ b/src/it/projects/site-sd-parent-no-append-path/pom.xml
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.maven.plugins.its.noappendpath</groupId>
+ <artifactId>base-parent</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <relativePath>parent/pom.xml</relativePath>
+ </parent>
+
+ <artifactId>unrelated-child</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <packaging>pom</packaging>
+
+ <name>unrelated-child</name>
+ <description>MSITE-948: an unrelated parent with
child.site.url.inherit.append.path="false" is not the top site</description>
+
+ <distributionManagement>
+ <site>
+ <id>website</id>
+
<url>file://@project.build.directory@/it/site-sd-parent-no-append-path/deploy/</url>
+ </site>
+ </distributionManagement>
+</project>
diff --git a/src/it/projects/site-sd-parent-no-append-path/verify.groovy
b/src/it/projects/site-sd-parent-no-append-path/verify.groovy
new file mode 100644
index 00000000..c12f14bd
--- /dev/null
+++ b/src/it/projects/site-sd-parent-no-append-path/verify.groovy
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+// deploy
+deployDirectory = new File( basedir, 'deploy' );
+assert deployDirectory.isDirectory();
+assert new File( deployDirectory, 'index.html' ).isFile();
+
+// stage: directly in target/staging, not in a parent-relative directory
+stageDirectory = new File( basedir, 'target/staging' );
+assert stageDirectory.isDirectory();
+assert new File( stageDirectory, 'index.html' ).isFile();
+assert !new File( basedir, 'target/unrelated-child' ).exists();
+
+// stage deploy
+stageDeployDirectory = new File( deployDirectory, 'staging' );
+assert new File( stageDeployDirectory, 'index.html' ).isFile();
+
+// nothing may land next to the unrelated parent site
+assert !new File( basedir, 'target/parent-deploy' ).exists();
+
+return true;
diff --git
a/src/main/java/org/apache/maven/plugins/site/deploy/AbstractDeployMojo.java
b/src/main/java/org/apache/maven/plugins/site/deploy/AbstractDeployMojo.java
index 4e3119f6..a97cde9d 100644
--- a/src/main/java/org/apache/maven/plugins/site/deploy/AbstractDeployMojo.java
+++ b/src/main/java/org/apache/maven/plugins/site/deploy/AbstractDeployMojo.java
@@ -679,6 +679,14 @@ public abstract class AbstractDeployMojo extends
AbstractSiteMojo {
? isSameRepositoryPath(siteURI.getBaseURI(),
oldSiteURI.getBaseURI())
: siteURI.sameSite(oldSiteURI.getBaseURI());
+ // MSITE-948: a parent declaring
child.site.url.inherit.append.path="false" says its children do not
+ // live below its own site, so a child with a site url outside of
the parent's one is not a part of it
+ if (sameSite
+ && !site.isChildSiteUrlInheritAppendPath()
+ && !isSameRepositoryPath(siteURI.getBaseURI(),
oldSiteURI.getBaseURI())) {
+ sameSite = false;
+ }
+
if (!sameSite) {
return oldProject;
}
diff --git
a/src/test/java/org/apache/maven/plugins/site/deploy/AbstractDeployMojoTest.java
b/src/test/java/org/apache/maven/plugins/site/deploy/AbstractDeployMojoTest.java
index 95d03f3c..451ba15e 100644
---
a/src/test/java/org/apache/maven/plugins/site/deploy/AbstractDeployMojoTest.java
+++
b/src/test/java/org/apache/maven/plugins/site/deploy/AbstractDeployMojoTest.java
@@ -212,6 +212,50 @@ public class AbstractDeployMojoTest {
assertEquals(childProject, topProject, "Projects with different ports
should not share a site");
}
+ /**
+ * MSITE-948: a parent with child.site.url.inherit.append.path="false" is
not the top site of a child whose
+ * site url lies elsewhere on the same host.
+ */
+ @Test
+ public void testGetTopLevelProjectParentWithoutAppendPath() throws
Exception {
+ TestDeployMojo mojo = new TestDeployMojo();
+ MavenProject childProject = createProjectWithSite("child",
"https://example.org/site/child");
+ MavenProject parentProject = createProjectWithSite("parent",
"https://example.org/site/base-parent");
+ getSite(parentProject).setChildSiteUrlInheritAppendPath(false);
+ childProject.setParent(parentProject);
+
+ assertEquals(childProject, mojo.getTopLevelProject(childProject));
+ }
+
+ @Test
+ public void testGetTopLevelProjectWithAppendPathStillGroupsSiblings()
throws Exception {
+ TestDeployMojo mojo = new TestDeployMojo();
+ MavenProject childProject = createProjectWithSite("child",
"https://example.org/site/child");
+ MavenProject parentProject = createProjectWithSite("parent",
"https://example.org/site/base-parent");
+ childProject.setParent(parentProject);
+
+ assertEquals(parentProject, mojo.getTopLevelProject(childProject));
+ }
+
+ @Test
+ public void
testGetTopLevelProjectWithoutAppendPathKeepsInheritedAndNestedUrls() throws
Exception {
+ TestDeployMojo mojo = new TestDeployMojo();
+ MavenProject parentProject = createProjectWithSite("parent",
"https://example.org/site/base-parent");
+ getSite(parentProject).setChildSiteUrlInheritAppendPath(false);
+
+ MavenProject inheritedUrl = createProjectWithSite("inherited",
"https://example.org/site/base-parent");
+ inheritedUrl.setParent(parentProject);
+ assertEquals(parentProject, mojo.getTopLevelProject(inheritedUrl));
+
+ MavenProject nestedUrl = createProjectWithSite("nested",
"https://example.org/site/base-parent/nested");
+ nestedUrl.setParent(parentProject);
+ assertEquals(parentProject, mojo.getTopLevelProject(nestedUrl));
+ }
+
+ private static Site getSite(MavenProject project) {
+ return project.getDistributionManagement().getSite();
+ }
+
private MavenProject createProjectWithSite(String artifactId, String
siteUrl) {
MavenProject project = new MavenProject();
project.setGroupId("org.apache.maven.test");