You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by hb...@apache.org on 2018/11/11 18:02:48 UTC

[maven] branch MNG-6059 updated (11312d5 -> 4d39646)

This is an automated email from the ASF dual-hosted git repository.

hboutemy pushed a change to branch MNG-6059
in repository https://gitbox.apache.org/repos/asf/maven.git.


 discard 11312d5  [MNG-6059] tweaked distributionManagement.site inheritance
     new 4d39646  [MNG-6505] tweaked distributionManagement.site inheritance

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (11312d5)
            \
             N -- N -- N   refs/heads/MNG-6059 (4d39646)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../org/apache/maven/model/merge/MavenModelMerger.java     | 14 ++++++++++++--
 .../model/inheritance/DefaultInheritanceAssemblerTest.java | 12 +++++++++++-
 .../poms/inheritance/no-append-urls2-expected.xml          |  2 --
 .../resources/poms/inheritance/no-append-urls2-parent.xml  |  6 ------
 .../{flat-urls-child.xml => no-append-urls3-child.xml}     |  7 +++++++
 ...end-urls2-expected.xml => no-append-urls3-expected.xml} | 14 ++++++--------
 ...-append-urls2-parent.xml => no-append-urls3-parent.xml} |  6 ------
 7 files changed, 36 insertions(+), 25 deletions(-)
 copy maven-model-builder/src/test/resources/poms/inheritance/{flat-urls-child.xml => no-append-urls3-child.xml} (81%)
 copy maven-model-builder/src/test/resources/poms/inheritance/{no-append-urls2-expected.xml => no-append-urls3-expected.xml} (79%)
 copy maven-model-builder/src/test/resources/poms/inheritance/{no-append-urls2-parent.xml => no-append-urls3-parent.xml} (90%)


[maven] 01/01: [MNG-6505] tweaked distributionManagement.site inheritance

Posted by hb...@apache.org.
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

commit 4d396466d3041b6a5c8444de398fe40ae4b0d526
Author: Hervé Boutemy <hb...@apache.org>
AuthorDate: Sat Nov 10 16:43:43 2018 +0100

    [MNG-6505] tweaked distributionManagement.site inheritance
    
    child.site.url.inherit.append.path is inherited independantly from
    id/name/url
---
 .../apache/maven/model/merge/MavenModelMerger.java | 23 +++++++++-
 .../DefaultInheritanceAssemblerTest.java           | 20 +++++++++
 .../poms/inheritance/no-append-urls2-child.xml     | 43 +++++++++++++++++++
 .../poms/inheritance/no-append-urls2-expected.xml  | 50 ++++++++++++++++++++++
 .../poms/inheritance/no-append-urls2-parent.xml    | 45 +++++++++++++++++++
 .../poms/inheritance/no-append-urls3-child.xml     | 41 ++++++++++++++++++
 .../poms/inheritance/no-append-urls3-expected.xml  | 50 ++++++++++++++++++++++
 .../poms/inheritance/no-append-urls3-parent.xml    | 45 +++++++++++++++++++
 8 files changed, 315 insertions(+), 2 deletions(-)

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..4f4113f 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
@@ -46,6 +46,7 @@ import org.apache.maven.model.Repository;
 import org.apache.maven.model.RepositoryBase;
 import org.apache.maven.model.Scm;
 import org.apache.maven.model.Site;
+import org.codehaus.plexus.util.StringUtils;
 
 /**
  * The domain-specific model merger for the Maven POM, overriding generic code from parent class when necessary with
@@ -443,17 +444,35 @@ public class MavenModelMerger
         if ( src != null )
         {
             Site tgt = target.getSite();
-            if ( sourceDominant || tgt == null )
+            if ( sourceDominant || tgt == null || isSiteEmpty( tgt ) )
             {
-                tgt = new Site();
+                if ( tgt == null )
+                {
+                    tgt = new Site();
+                }
                 tgt.setLocation( "", src.getLocation( "" ) );
                 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 );
+    }
+
+    protected boolean isSiteEmpty( Site site )
+    {
+        return StringUtils.isEmpty( site.getId() ) && StringUtils.isEmpty( site.getName() )
+            && StringUtils.isEmpty( site.getUrl() );
+    }
+
+    @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..07a121a 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,26 @@ public class DefaultInheritanceAssemblerTest
     }
 
     /**
+     * MNG-5951 special case test: inherit with partial override
+     * @throws Exception
+     */
+    public void testNoAppendUrls2()
+        throws Exception
+    {
+        testInheritance( "no-append-urls2" );
+    }
+
+    /**
+     * MNG-5951 special case test: child.x.y.inherit.append.path="true" in child should not reset content
+     * @throws Exception
+     */
+    public void testNoAppendUrls3()
+        throws Exception
+    {
+        testInheritance( "no-append-urls3" );
+    }
+
+    /**
      * 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..4d8e683
--- /dev/null
+++ b/maven-model-builder/src/test/resources/poms/inheritance/no-append-urls2-expected.xml
@@ -0,0 +1,50 @@
+<?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>
+
+  <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..d2e2e71
--- /dev/null
+++ b/maven-model-builder/src/test/resources/poms/inheritance/no-append-urls2-parent.xml
@@ -0,0 +1,45 @@
+<?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>
+
+  <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
diff --git a/maven-model-builder/src/test/resources/poms/inheritance/no-append-urls3-child.xml b/maven-model-builder/src/test/resources/poms/inheritance/no-append-urls3-child.xml
new file mode 100644
index 0000000..ccb2d91
--- /dev/null
+++ b/maven-model-builder/src/test/resources/poms/inheritance/no-append-urls3-child.xml
@@ -0,0 +1,41 @@
+<?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 child.scm.connection.inherit.append.path="true"
+       child.scm.developerConnection.inherit.append.path="true"
+       child.scm.url.inherit.append.path="true" />
+  <distributionManagement>
+    <site child.site.url.inherit.append.path="true" />
+  </distributionManagement>
+</project>
\ No newline at end of file
diff --git a/maven-model-builder/src/test/resources/poms/inheritance/no-append-urls3-expected.xml b/maven-model-builder/src/test/resources/poms/inheritance/no-append-urls3-expected.xml
new file mode 100644
index 0000000..a6a884d
--- /dev/null
+++ b/maven-model-builder/src/test/resources/poms/inheritance/no-append-urls3-expected.xml
@@ -0,0 +1,50 @@
+<?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>
+
+  <scm child.scm.connection.inherit.append.path="true"
+       child.scm.developerConnection.inherit.append.path="true"
+       child.scm.url.inherit.append.path="true">
+    <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="true">
+      <url>scp://scp.domain.org/base/</url>
+    </site>
+  </distributionManagement>
+</project>
diff --git a/maven-model-builder/src/test/resources/poms/inheritance/no-append-urls3-parent.xml b/maven-model-builder/src/test/resources/poms/inheritance/no-append-urls3-parent.xml
new file mode 100644
index 0000000..d2e2e71
--- /dev/null
+++ b/maven-model-builder/src/test/resources/poms/inheritance/no-append-urls3-parent.xml
@@ -0,0 +1,45 @@
+<?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>
+
+  <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