You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sj...@apache.org on 2023/01/07 20:19:51 UTC

[maven-enforcer] branch master updated: [MENFORCER-434] Regression bannedDependencies - matching with not existing versions

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 6d2b727  [MENFORCER-434] Regression bannedDependencies - matching with not existing versions
6d2b727 is described below

commit 6d2b7275816c6690f37d735a290b3d465f55e7ca
Author: Slawomir Jaranowski <s....@gmail.com>
AuthorDate: Sat Jan 7 18:26:01 2023 +0100

    [MENFORCER-434] Regression bannedDependencies - matching with not existing versions
---
 .../it/projects/MENFORCER-434/invoker.properties   | 18 +++++
 .../src/it/projects/MENFORCER-434/pom.xml          | 94 ++++++++++++++++++++++
 .../src/it/projects/MENFORCER-434/verify.groovy    | 26 ++++++
 3 files changed, 138 insertions(+)

diff --git a/maven-enforcer-plugin/src/it/projects/MENFORCER-434/invoker.properties b/maven-enforcer-plugin/src/it/projects/MENFORCER-434/invoker.properties
new file mode 100644
index 0000000..58b6526
--- /dev/null
+++ b/maven-enforcer-plugin/src/it/projects/MENFORCER-434/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
diff --git a/maven-enforcer-plugin/src/it/projects/MENFORCER-434/pom.xml b/maven-enforcer-plugin/src/it/projects/MENFORCER-434/pom.xml
new file mode 100644
index 0000000..660213e
--- /dev/null
+++ b/maven-enforcer-plugin/src/it/projects/MENFORCER-434/pom.xml
@@ -0,0 +1,94 @@
+<?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/maven-v4_0_0.xsd">
+
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>maven.sample.issue</groupId>
+  <artifactId>MENFORCER-434</artifactId>
+  <packaging>jar</packaging>
+  <version>1.0.0-SNAPSHOT</version>
+  <name>MENFORCER-434</name>
+  <url>https://issues.apache.org/jira/browse/MENFORCER-434</url>
+  <description>Sample Project to Demo https://issues.apache.org/jira/browse/MENFORCER-434</description>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-enforcer-plugin</artifactId>
+        <version>@project.version@</version>
+        <executions>
+          <execution>
+            <id>enforce-versions</id>
+
+            <goals>
+              <goal>enforce</goal>
+            </goals>
+
+            <configuration>
+              <rules>
+                <bannedDependencies>
+                  <searchTransitive>true</searchTransitive>
+                  <excludes>
+                    <!-- Using non-existent version 3.0.0 to force failure.  Fail if any version less than 3.0.0  -->
+                    <exclude>org.apache.logging.log4j:*:(,3.0.0)</exclude>
+                    <exclude>log4j:log4j</exclude>
+                  </excludes>
+                  <includes>
+                    <!-- allow this one ... in order to see transitive banned -->
+                    <include>org.apache.logging.log4j:log4j-core</include>
+                  </includes>
+                </bannedDependencies>
+              </rules>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+
+    </plugins>
+  </build>
+
+  <dependencies>
+
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-core</artifactId>
+      <version>2.19.0</version>
+      <scope>compile</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-slf4j-impl</artifactId>
+      <version>2.19.0</version>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-jul</artifactId>
+      <version>2.19.0</version>
+      <scope>compile</scope>
+    </dependency>
+
+  </dependencies>
+
+</project>
diff --git a/maven-enforcer-plugin/src/it/projects/MENFORCER-434/verify.groovy b/maven-enforcer-plugin/src/it/projects/MENFORCER-434/verify.groovy
new file mode 100644
index 0000000..6ea93b4
--- /dev/null
+++ b/maven-enforcer-plugin/src/it/projects/MENFORCER-434/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.
+ */
+
+def buildLog = new File(basedir, 'build.log').text
+assert buildLog.contains('[ERROR] Rule 0: org.apache.maven.plugins.enforcer.BannedDependencies failed with message:')
+
+assert buildLog.contains('   org.apache.logging.log4j:log4j-core:jar:2.19.0')
+assert buildLog.contains('      org.apache.logging.log4j:log4j-api:jar:2.19.0 <--- banned via the exclude/include list')
+assert buildLog.contains('   org.apache.logging.log4j:log4j-slf4j-impl:jar:2.19.0 <--- banned via the exclude/include list')
+assert buildLog.contains('   org.apache.logging.log4j:log4j-jul:jar:2.19.0 <--- banned via the exclude/include list')