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 2010/07/18 15:25:52 UTC

svn commit: r965226 - in /maven/ant-tasks/trunk: build-tests.xml src/main/java/org/apache/maven/artifact/ant/AbstractArtifactWithRepositoryTask.java

Author: hboutemy
Date: Sun Jul 18 13:25:52 2010
New Revision: 965226

URL: http://svn.apache.org/viewvc?rev=965226&view=rev
Log:
[MANTTASKS-192] display an explicit error message when using a remote repository with a refid which has not been defined instead of NPE

Modified:
    maven/ant-tasks/trunk/build-tests.xml
    maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/AbstractArtifactWithRepositoryTask.java

Modified: maven/ant-tasks/trunk/build-tests.xml
URL: http://svn.apache.org/viewvc/maven/ant-tasks/trunk/build-tests.xml?rev=965226&r1=965225&r2=965226&view=diff
==============================================================================
--- maven/ant-tasks/trunk/build-tests.xml (original)
+++ maven/ant-tasks/trunk/build-tests.xml Sun Jul 18 13:25:52 2010
@@ -71,6 +71,7 @@
         - test-bad-dep
         - test-invalid-pom-ref
     	- test-bad-system-dep
+    	- test-bad-repo-refid
     </echo>
   </target>
 
@@ -677,6 +678,14 @@
     </artifact:dependencies>
   </target>
 
+  <target name="test-bad-repo-refid" depends="initTaskDefs">
+  	<echo>Expected failure: undefined remoteRepository refid</echo>
+    <artifact:dependencies>
+      <remoteRepository refid="not-defined"/>
+      <dependency groupId="commons-logging" artifactId="commons-logging" version="1.1.1"/>
+    </artifact:dependencies>
+  </target>
+
   <macrodef name="check.file.exists">
     <attribute name="file"/>
     <attribute name="type" default="file"/>

Modified: maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/AbstractArtifactWithRepositoryTask.java
URL: http://svn.apache.org/viewvc/maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/AbstractArtifactWithRepositoryTask.java?rev=965226&r1=965225&r2=965226&view=diff
==============================================================================
--- maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/AbstractArtifactWithRepositoryTask.java (original)
+++ maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/AbstractArtifactWithRepositoryTask.java Sun Jul 18 13:25:52 2010
@@ -132,6 +132,15 @@ public abstract class AbstractArtifactWi
      */
     public void addConfiguredRemoteRepository( RemoteRepository remoteRepository )
     {
+        if ( remoteRepository.getRefid() != null )
+        {
+            // check that the refid points to a repository that is properly defined
+            String refid = remoteRepository.getRefid();
+            if ( getProject().getReference( refid ) == null )
+            {
+                throw new BuildException( "Unknown remote repository refid='" + refid + "'." );
+            }
+        }
         // Validate the url and id parameters before adding the repository
         if ( remoteRepository.getUrl() == null )
         {