You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by us...@apache.org on 2012/07/09 15:54:37 UTC

svn commit: r1359173 - /lucene/dev/branches/lucene4199/lucene/tools/src/java/org/apache/lucene/validation/ForbiddenApisCheckTask.java

Author: uschindler
Date: Mon Jul  9 13:54:37 2012
New Revision: 1359173

URL: http://svn.apache.org/viewvc?rev=1359173&view=rev
Log:
LUCENE-4199: Add some additional checks and better error messages to task, so it fails on empty signature list or empty class file set.

Modified:
    lucene/dev/branches/lucene4199/lucene/tools/src/java/org/apache/lucene/validation/ForbiddenApisCheckTask.java

Modified: lucene/dev/branches/lucene4199/lucene/tools/src/java/org/apache/lucene/validation/ForbiddenApisCheckTask.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4199/lucene/tools/src/java/org/apache/lucene/validation/ForbiddenApisCheckTask.java?rev=1359173&r1=1359172&r2=1359173&view=diff
==============================================================================
--- lucene/dev/branches/lucene4199/lucene/tools/src/java/org/apache/lucene/validation/ForbiddenApisCheckTask.java (original)
+++ lucene/dev/branches/lucene4199/lucene/tools/src/java/org/apache/lucene/validation/ForbiddenApisCheckTask.java Mon Jul  9 13:54:37 2012
@@ -212,14 +212,18 @@ public class ForbiddenApisCheckTask exte
           loader = getProject().createClassLoader(classpath);
       }
       classFiles.setProject(getProject());
+      apiSignatures.setProject(getProject());
       
       try {
         @SuppressWarnings("unchecked")
         Iterator<Resource> iter = (Iterator<Resource>) apiSignatures.iterator();
+        if (!iter.hasNext()) {
+          throw new BuildException("You need to supply at least one API signature definition through apiFile=, <apiFileSet/>, or inner text.");
+        }
         while (iter.hasNext()) {
           final Resource r = iter.next();
           if (!r.isExists()) { 
-            throw new BuildException("Resource does not exist: " + r.getName());
+            throw new BuildException("Resource does not exist: " + r);
           }
           if (r instanceof StringResource) {
             parseApiFile(loader, new StringReader(((StringResource) r).getValue()));
@@ -230,6 +234,9 @@ public class ForbiddenApisCheckTask exte
       } catch (IOException ioe) {
         throw new BuildException("IO problem while reading files with API signatures.", ioe);
       }
+      if (forbiddenMethods.isEmpty() && forbiddenClasses.isEmpty()) {
+        throw new BuildException("No API signatures found; use apiFile=, <apiFileSet/>, or inner text to define those!");
+      }
 
       long start = System.currentTimeMillis();
       
@@ -237,16 +244,19 @@ public class ForbiddenApisCheckTask exte
       int errors = 0;
       @SuppressWarnings("unchecked")
       Iterator<Resource> iter = (Iterator<Resource>) classFiles.iterator();
+      if (!iter.hasNext()) {
+        throw new BuildException("There is no <fileset/> given or the fileset does not contain any class files to check.");
+      }
       while (iter.hasNext()) {
         final Resource r = iter.next();
         if (!r.isExists()) { 
-          throw new BuildException("Class file does not exist: " + r.getName());
+          throw new BuildException("Class file does not exist: " + r);
         }
 
         try {
           errors += checkClass(r);
         } catch (IOException ioe) {
-          throw new BuildException("IO problem while reading class file " + r.getName(), ioe);
+          throw new BuildException("IO problem while reading class file " + r, ioe);
         }
         checked++;
       }