You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sl...@apache.org on 2020/07/27 14:29:15 UTC

[maven-enforcer] branch master updated (0124c62 -> 58fa407)

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

slachiewicz pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/maven-enforcer.git.


    from 0124c62  Changed those lines reviewed in the PR.
     new 844c4fc  MENFORCER-301 check dependencyManagement
     new 58fa407  MENFORCER-301 test

The 2 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:
 .../BanDuplicatePomDependencyVersions.java         |  6 ++---
 .../invoker.properties                             |  0
 .../pom.xml                                        | 28 ++++++++++++----------
 .../verify.groovy                                  |  4 ++--
 4 files changed, 21 insertions(+), 17 deletions(-)
 copy maven-enforcer-plugin/src/it/projects/{require-upper-bound-deps_failure => ban-duplicate-dependencies-versions}/invoker.properties (100%)
 copy maven-enforcer-plugin/src/it/projects/{require-active-profile => ban-duplicate-dependencies-versions}/pom.xml (72%)
 copy maven-enforcer-plugin/src/it/projects/{ban-pom-dependency-version-utf8-with-bom => ban-duplicate-dependencies-versions}/verify.groovy (85%)


[maven-enforcer] 02/02: MENFORCER-301 test

Posted by sl...@apache.org.
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-enforcer.git

commit 58fa407051ae40d120e57959f6548e3c4724bc63
Author: Alexander Kudrevatykh <al...@kudrevatykh.com>
AuthorDate: Mon May 25 20:27:24 2020 +0300

    MENFORCER-301 test
---
 .../invoker.properties                             | 18 ++++++
 .../ban-duplicate-dependencies-versions/pom.xml    | 69 ++++++++++++++++++++++
 .../verify.groovy                                  | 26 ++++++++
 3 files changed, 113 insertions(+)

diff --git a/maven-enforcer-plugin/src/it/projects/ban-duplicate-dependencies-versions/invoker.properties b/maven-enforcer-plugin/src/it/projects/ban-duplicate-dependencies-versions/invoker.properties
new file mode 100644
index 0000000..c98ac4c
--- /dev/null
+++ b/maven-enforcer-plugin/src/it/projects/ban-duplicate-dependencies-versions/invoker.properties
@@ -0,0 +1,18 @@
+# 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.buildResult=failure
\ No newline at end of file
diff --git a/maven-enforcer-plugin/src/it/projects/ban-duplicate-dependencies-versions/pom.xml b/maven-enforcer-plugin/src/it/projects/ban-duplicate-dependencies-versions/pom.xml
new file mode 100644
index 0000000..6067e90
--- /dev/null
+++ b/maven-enforcer-plugin/src/it/projects/ban-duplicate-dependencies-versions/pom.xml
@@ -0,0 +1,69 @@
+<?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>
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.maven.its.enforcer</groupId>
+  <artifactId>ban-duplicate-dependencies-versions</artifactId>
+  <version>1.0</version>
+
+  <description>
+  </description>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-enforcer-plugin</artifactId>
+        <version>@project.version@</version>
+        <executions>
+          <execution>
+            <id>test</id>
+            <goals>
+              <goal>enforce</goal>
+            </goals>
+            <configuration>
+              <rules>
+                <banDuplicatePomDependencyVersions/>
+              </rules>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+
+  <dependencyManagement>
+    <dependencies>
+      <dependency>
+        <groupId>org.apache.maven.plugins.enforcer.its</groupId>
+        <artifactId>menforcer128_api</artifactId>
+        <version>1.4.0</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.maven.plugins.enforcer.its</groupId>
+        <artifactId>menforcer128_api</artifactId>
+        <version>1.5.0</version>
+      </dependency>
+    </dependencies>
+  </dependencyManagement>
+</project>
diff --git a/maven-enforcer-plugin/src/it/projects/ban-duplicate-dependencies-versions/verify.groovy b/maven-enforcer-plugin/src/it/projects/ban-duplicate-dependencies-versions/verify.groovy
new file mode 100644
index 0000000..c404745
--- /dev/null
+++ b/maven-enforcer-plugin/src/it/projects/ban-duplicate-dependencies-versions/verify.groovy
@@ -0,0 +1,26 @@
+/*
+ * 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.
+ */
+File buildLog = new File( basedir, 'build.log' )
+assert buildLog.text.contains( '[WARNING] Rule 0: org.apache.maven.plugins.enforcer.BanDuplicatePomDependencyVersions failed with message:' )
+assert buildLog.text.contains( 'Found 1 duplicate dependency declarations in this project:' )
+assert buildLog.text.contains( '- dependencyManagement.dependencies.dependency[org.apache.maven.plugins.enforcer.its:menforcer128_api:jar] ( 2 times )' )
+
+
+
+ 
\ No newline at end of file


[maven-enforcer] 01/02: MENFORCER-301 check dependencyManagement

Posted by sl...@apache.org.
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-enforcer.git

commit 844c4fc44e8cec62a693792761d645b4a13d0c23
Author: kudrevatykh <al...@kudrevatykh.com>
AuthorDate: Mon Apr 16 12:06:35 2018 +0300

    MENFORCER-301 check dependencyManagement
    
    really check dependencyManagement section
---
 .../maven/plugins/enforcer/BanDuplicatePomDependencyVersions.java   | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/BanDuplicatePomDependencyVersions.java b/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/BanDuplicatePomDependencyVersions.java
index 311eea6..ed46d9f 100644
--- a/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/BanDuplicatePomDependencyVersions.java
+++ b/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/BanDuplicatePomDependencyVersions.java
@@ -109,7 +109,7 @@ public class BanDuplicatePomDependencyVersions
 
         if ( model.getDependencyManagement() != null )
         {
-            List<Dependency> managementDependencies = model.getDependencies();
+            List<Dependency> managementDependencies = model.getDependencyManagement().getDependencies();
             Map<String, Integer> duplicateManagementDependencies = validateDependencies( managementDependencies );
             duplicates += duplicateManagementDependencies.size();
 
@@ -128,9 +128,9 @@ public class BanDuplicatePomDependencyVersions
             messageBuilder( duplicateProfileDependencies, "profiles.profile[" + profile.getId()
                 + "].dependencies.dependency", summary );
 
-            if ( model.getDependencyManagement() != null )
+            if ( profile.getDependencyManagement() != null )
             {
-                List<Dependency> profileManagementDependencies = profile.getDependencies();
+                List<Dependency> profileManagementDependencies = profile.getDependencyManagement().getDependencies();
 
                 Map<String, Integer> duplicateProfileManagementDependencies =
                     validateDependencies( profileManagementDependencies );