You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by rf...@apache.org on 2013/06/05 23:03:52 UTC
svn commit: r1490031 - in /maven/enforcer/trunk:
enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/
maven-enforcer-plugin/src/it/projects/require-no-repositories_failure/
Author: rfscholte
Date: Wed Jun 5 21:03:51 2013
New Revision: 1490031
URL: http://svn.apache.org/r1490031
Log:
[MENFORCER-122] Adding repository causes NPE during mvn install
Add IT, can't reproduce issue although found a potential NPE when Repository.getReleases() == null
Added:
maven/enforcer/trunk/maven-enforcer-plugin/src/it/projects/require-no-repositories_failure/
maven/enforcer/trunk/maven-enforcer-plugin/src/it/projects/require-no-repositories_failure/invoker.properties
maven/enforcer/trunk/maven-enforcer-plugin/src/it/projects/require-no-repositories_failure/pom.xml
maven/enforcer/trunk/maven-enforcer-plugin/src/it/projects/require-no-repositories_failure/verify.groovy
Modified:
maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireNoRepositories.java
Modified: maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireNoRepositories.java
URL: http://svn.apache.org/viewvc/maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireNoRepositories.java?rev=1490031&r1=1490030&r2=1490031&view=diff
==============================================================================
--- maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireNoRepositories.java (original)
+++ maven/enforcer/trunk/enforcer-rules/src/main/java/org/apache/maven/plugins/enforcer/RequireNoRepositories.java Wed Jun 5 21:03:51 2013
@@ -171,6 +171,13 @@ public class RequireNoRepositories
}
}
+ /**
+ *
+ * @param repos all repositories, never {@code null}
+ * @param allowedRepos allowed repositories, never {@code null}
+ * @param allowSnapshots
+ * @return
+ */
private static List<String> findBannedRepositories( List<Repository> repos, List<String> allowedRepos, boolean allowSnapshots )
{
List<String> bannedRepos = new ArrayList<String>( allowedRepos.size() );
@@ -178,7 +185,7 @@ public class RequireNoRepositories
{
if ( !allowedRepos.contains( r.getId() ) )
{
- if ( !allowSnapshots || r.getReleases().isEnabled() )
+ if ( !allowSnapshots || r.getReleases() == null || r.getReleases().isEnabled() )
{
// if we are not allowing snapshots and this repo is enabled for releases
// it is banned. We don't care whether it is enabled for snapshots
Added: maven/enforcer/trunk/maven-enforcer-plugin/src/it/projects/require-no-repositories_failure/invoker.properties
URL: http://svn.apache.org/viewvc/maven/enforcer/trunk/maven-enforcer-plugin/src/it/projects/require-no-repositories_failure/invoker.properties?rev=1490031&view=auto
==============================================================================
--- maven/enforcer/trunk/maven-enforcer-plugin/src/it/projects/require-no-repositories_failure/invoker.properties (added)
+++ maven/enforcer/trunk/maven-enforcer-plugin/src/it/projects/require-no-repositories_failure/invoker.properties Wed Jun 5 21:03:51 2013
@@ -0,0 +1 @@
+invoker.buildResult=failure
\ No newline at end of file
Added: maven/enforcer/trunk/maven-enforcer-plugin/src/it/projects/require-no-repositories_failure/pom.xml
URL: http://svn.apache.org/viewvc/maven/enforcer/trunk/maven-enforcer-plugin/src/it/projects/require-no-repositories_failure/pom.xml?rev=1490031&view=auto
==============================================================================
--- maven/enforcer/trunk/maven-enforcer-plugin/src/it/projects/require-no-repositories_failure/pom.xml (added)
+++ maven/enforcer/trunk/maven-enforcer-plugin/src/it/projects/require-no-repositories_failure/pom.xml Wed Jun 5 21:03:51 2013
@@ -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>test</artifactId>
+ <version>1.0</version>
+
+ <repositories>
+ <repository>
+ <id>com.asual.maven.public</id>
+ <name>Asual Public Repository</name>
+ <url>http://localhost</url>
+ </repository>
+ </repositories>
+
+ <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>
+ <requireNoRepositories>
+ </requireNoRepositories>
+ </rules>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
Added: maven/enforcer/trunk/maven-enforcer-plugin/src/it/projects/require-no-repositories_failure/verify.groovy
URL: http://svn.apache.org/viewvc/maven/enforcer/trunk/maven-enforcer-plugin/src/it/projects/require-no-repositories_failure/verify.groovy?rev=1490031&view=auto
==============================================================================
--- maven/enforcer/trunk/maven-enforcer-plugin/src/it/projects/require-no-repositories_failure/verify.groovy (added)
+++ maven/enforcer/trunk/maven-enforcer-plugin/src/it/projects/require-no-repositories_failure/verify.groovy Wed Jun 5 21:03:51 2013
@@ -0,0 +1,22 @@
+/*
+ * 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.RequireNoRepositories failed with message:' )
+assert buildLog.text.contains( 'Some poms have repositories defined:' )
+assert buildLog.text.contains( 'org.apache.maven.its.enforcer:test version:1.0 has repositories [com.asual.maven.public]' )