[MENFORCER-395] Fix NPE in requireReleaseDeps
diff --git a/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireReleaseDeps.java b/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireReleaseDeps.java
index 208f8ac..783ea70 100644
--- a/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireReleaseDeps.java
+++ b/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireReleaseDeps.java
@@ -141,15 +141,17 @@
Set<Artifact> foundSnapshots = new HashSet<>();
Set<Artifact> filteredDependencies = filterArtifacts( dependencies );
-
- for ( Artifact artifact : filteredDependencies )
+
+ if ( filteredDependencies != null )
{
- if ( artifact.isSnapshot() )
+ for ( Artifact artifact : filteredDependencies )
{
- foundSnapshots.add( artifact );
+ if ( artifact.isSnapshot() )
+ {
+ foundSnapshots.add( artifact );
+ }
}
}
-
return foundSnapshots;
}
diff --git a/maven-enforcer-plugin/src/it/projects/MENFORCER-395/pom.xml b/maven-enforcer-plugin/src/it/projects/MENFORCER-395/pom.xml
new file mode 100644
index 0000000..54edc98
--- /dev/null
+++ b/maven-enforcer-plugin/src/it/projects/MENFORCER-395/pom.xml
@@ -0,0 +1,60 @@
+<?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>minimal-test</artifactId>
+ <version>0.0.1</version>
+ <packaging>jar</packaging>
+ <description>Minimal test for NPE in maven-enforcer-plugin:3.0.0</description>
+ <properties>
+ <java.source>1.8</java.source>
+ <java.target>1.8</java.target>
+ </properties>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-enforcer-plugin</artifactId>
+ <version>@project.version@</version>
+ <executions>
+ <execution>
+ <id>enforce-no-snapshots</id>
+ <goals>
+ <goal>enforce</goal>
+ </goals>
+ <configuration>
+ <rules>
+ <requireReleaseDeps>
+ <includes>
+ <include>testgroup:testartifact</include>
+ </includes>
+ </requireReleaseDeps>
+ </rules>
+ <fail>true</fail>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
\ No newline at end of file