This is an automated email from the ASF dual-hosted git repository. hboutemy pushed a commit to branch MNG-6059 in repository https://gitbox.apache.org/repos/asf/maven.git
The following commit(s) were added to refs/heads/MNG-6059 by this push: new 11312d5 [MNG-6059] tweaked distributionManagement.site inheritance 11312d5 is described below commit 11312d5b275260fbd2b3ed3294da3ccff5413d42 Author: Hervé Boutemy <hbout...@apache.org> AuthorDate: Sat Nov 10 16:43:43 2018 +0100 [MNG-6059] tweaked distributionManagement.site inheritance child.site.url.inherit.append.path is inherited independantly from id/name/url --- .../apache/maven/model/merge/MavenModelMerger.java | 9 ++++ .../DefaultInheritanceAssemblerTest.java | 10 +++++ .../poms/inheritance/no-append-urls2-child.xml | 43 ++++++++++++++++++ .../poms/inheritance/no-append-urls2-expected.xml | 52 ++++++++++++++++++++++ .../poms/inheritance/no-append-urls2-parent.xml | 51 +++++++++++++++++++++ 5 files changed, 165 insertions(+) diff --git a/maven-model-builder/src/main/java/org/apache/maven/model/merge/MavenModelMerger.java b/maven-model-builder/src/main/java/org/apache/maven/model/merge/MavenModelMerger.java index a1449ac..09f1f77 100644 --- a/maven-model-builder/src/main/java/org/apache/maven/model/merge/MavenModelMerger.java +++ b/maven-model-builder/src/main/java/org/apache/maven/model/merge/MavenModelMerger.java @@ -450,10 +450,19 @@ public class MavenModelMerger target.setSite( tgt ); mergeSite( tgt, src, sourceDominant, context ); } + mergeSite_ChildSiteUrlInheritAppendPath( tgt, src, sourceDominant, context ); } } @Override + protected void mergeSite( Site target, Site source, boolean sourceDominant, Map<Object, Object> context ) + { + mergeSite_Id( target, source, sourceDominant, context ); + mergeSite_Name( target, source, sourceDominant, context ); + mergeSite_Url( target, source, sourceDominant, context ); + } + + @Override protected void mergeSite_Url( Site target, Site source, boolean sourceDominant, Map<Object, Object> context ) { String src = source.getUrl(); diff --git a/maven-model-builder/src/test/java/org/apache/maven/model/inheritance/DefaultInheritanceAssemblerTest.java b/maven-model-builder/src/test/java/org/apache/maven/model/inheritance/DefaultInheritanceAssemblerTest.java index b97f37c..8fcf6ee 100644 --- a/maven-model-builder/src/test/java/org/apache/maven/model/inheritance/DefaultInheritanceAssemblerTest.java +++ b/maven-model-builder/src/test/java/org/apache/maven/model/inheritance/DefaultInheritanceAssemblerTest.java @@ -104,6 +104,16 @@ public class DefaultInheritanceAssemblerTest } /** + * MNG-5951 special case test: inhertid with partial override + * @throws Exception + */ + public void testNoAppendUrls2() + throws Exception + { + testInheritance( "no-append-urls2" ); + } + + /** * Tricky case: flat directory structure, but child directory != artifactId. * Model interpolation does not give same result when calculated from build or from repo... * This is why MNG-5000 fix in code is marked as bad practice (uses file names) diff --git a/maven-model-builder/src/test/resources/poms/inheritance/no-append-urls2-child.xml b/maven-model-builder/src/test/resources/poms/inheritance/no-append-urls2-child.xml new file mode 100644 index 0000000..dbf4dd4 --- /dev/null +++ b/maven-model-builder/src/test/resources/poms/inheritance/no-append-urls2-child.xml @@ -0,0 +1,43 @@ +<?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>inheritance</groupId> + <artifactId>parent</artifactId> + <version>11-SNAPSHOT</version> + </parent> + + <artifactId>inheritance</artifactId><!-- same as directory name --> + <name>Model urls inheritance test child</name> + + <scm> + <url>https://domain.org/override</url><!-- check that this won't impact child.site.url.inherit.append.path attribute inheritance --> + </scm> + <distributionManagement> + <site><!-- overriding 1 element will reset all elements, but not child.site.url.inherit.append.path attribute --> + <name>reset</name> + </site> + </distributionManagement> +</project> \ No newline at end of file diff --git a/maven-model-builder/src/test/resources/poms/inheritance/no-append-urls2-expected.xml b/maven-model-builder/src/test/resources/poms/inheritance/no-append-urls2-expected.xml new file mode 100644 index 0000000..98fbb56 --- /dev/null +++ b/maven-model-builder/src/test/resources/poms/inheritance/no-append-urls2-expected.xml @@ -0,0 +1,52 @@ +<?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" + child.project.url.inherit.append.path="false"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>inheritance</groupId> + <artifactId>parent</artifactId> + <version>11-SNAPSHOT</version> + </parent> + + <groupId>inheritance</groupId> + <artifactId>inheritance</artifactId> + <version>11-SNAPSHOT</version> + <name>Model urls inheritance test child</name> + + <!-- 5 inherited urls without anything added to parent --> + <url>http://www.apache.org/path/to/parent/</url> + <scm child.scm.connection.inherit.append.path="false" + child.scm.developerConnection.inherit.append.path="false" + child.scm.url.inherit.append.path="false"> + <connection>scm:my-scm:http://domain.org/base</connection> + <developerConnection>scm:my-scm:https://domain.org/base/</developerConnection> + <url>https://domain.org/override</url> + </scm> + <distributionManagement> + <site child.site.url.inherit.append.path="false"> + <name>reset</name> + </site> + </distributionManagement> +</project> diff --git a/maven-model-builder/src/test/resources/poms/inheritance/no-append-urls2-parent.xml b/maven-model-builder/src/test/resources/poms/inheritance/no-append-urls2-parent.xml new file mode 100644 index 0000000..f96e52f --- /dev/null +++ b/maven-model-builder/src/test/resources/poms/inheritance/no-append-urls2-parent.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" + child.project.url.inherit.append.path="false"> + <modelVersion>4.0.0</modelVersion> + + <groupId>inheritance</groupId> + <artifactId>parent</artifactId> + <version>11-SNAPSHOT</version> + + <name>Model urls inheritance test parent, with special merge test for mergeSite_ChildSiteUrlInheritAppendPath</name> + + <modules> + <module>../inheritance</module> + </modules> + + <!-- 5 urls in the pom to configure for not adding path --> + <url>http://www.apache.org/path/to/parent/</url> + <scm child.scm.connection.inherit.append.path="false" + child.scm.developerConnection.inherit.append.path="false" + child.scm.url.inherit.append.path="false"> + <connection>scm:my-scm:http://domain.org/base</connection> + <developerConnection>scm:my-scm:https://domain.org/base/</developerConnection> + <url>https://domain.org/base</url> + </scm> + <distributionManagement> + <site child.site.url.inherit.append.path="false"> + <url>scp://scp.domain.org/base/</url> + </site> + </distributionManagement> +</project> \ No newline at end of file