Author: hboutemy
Date: Sun Jul 18 11:23:00 2010
New Revision: 965211

URL: http://svn.apache.org/viewvc?rev=965211&view=rev
Log:
[MANTTASKS-189] display an explicit error message when scope="system" without 
systemPath attribute instead of NPE

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

Modified: maven/ant-tasks/trunk/build-tests.xml
URL: 
http://svn.apache.org/viewvc/maven/ant-tasks/trunk/build-tests.xml?rev=965211&r1=965210&r2=965211&view=diff
==============================================================================
--- maven/ant-tasks/trunk/build-tests.xml (original)
+++ maven/ant-tasks/trunk/build-tests.xml Sun Jul 18 11:23:00 2010
@@ -70,6 +70,7 @@
     <echo>Some tests must be run manually, since they are intended to fail:
         - test-bad-dep
         - test-invalid-pom-ref
+       - test-bad-system-dep
     </echo>
   </target>
 
@@ -668,6 +669,14 @@
     <fail if="test.fail">For system scope path should not come from local 
repository.</fail>
   </target>
 
+  <target name="test-bad-system-dep" depends="initTaskDefs">
+       <echo>Expected failure: dependency with scope="system" must define 
systemPath attribute</echo>
+    <artifact:dependencies>
+      <dependency groupId="foo" artifactId="bar" version="1.0" scope="system"/>
+      <localRepository refid="local.repository"/>
+    </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/DependenciesTask.java
URL: 
http://svn.apache.org/viewvc/maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/DependenciesTask.java?rev=965211&r1=965210&r2=965211&view=diff
==============================================================================
--- 
maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/DependenciesTask.java
 (original)
+++ 
maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/DependenciesTask.java
 Sun Jul 18 11:23:00 2010
@@ -195,7 +195,15 @@ public class DependenciesTask
             {
                 String scope = dependency.getScope();
 
-                if ( ( scope != null ) && !SCOPES_SET.contains( scope ) )
+                if ( Artifact.SCOPE_SYSTEM.equals( scope ) )
+                {
+                    if ( StringUtils.isBlank( dependency.getSystemPath() ) )
+                    {
+                        throw new BuildException( dependency.toString()
+                            + " is defined with scope='system': systemPath 
attribute is required." );
+                    }
+                }
+                else if ( ( scope != null ) && !SCOPES_SET.contains( scope ) )
                 {
                     // see MANTTASKS-190
                     log( "Unknown scope='" + scope + "' for " + dependency + 
", supported scopes are: " + SCOPES_SET,


Reply via email to