KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > edu > umd > cs > findbugs > anttask > FindBugsTask


1 /*
2  * The Apache Software License, Version 1.1
3  *
4  * Copyright (c) 2000-2002 The Apache Software Foundation. All rights
5  * reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * 1. Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  *
14  * 2. Redistributions in binary form must reproduce the above copyright
15  * notice, this list of conditions and the following disclaimer in
16  * the documentation and/or other materials provided with the
17  * distribution.
18  *
19  * 3. The end-user documentation included with the redistribution, if
20  * any, must include the following acknowlegement:
21  * "This product includes software developed by the
22  * Apache Software Foundation (http://www.apache.org/)."
23  * Alternately, this acknowlegement may appear in the software itself,
24  * if and wherever such third-party acknowlegements normally appear.
25  *
26  * 4. The names "Ant" and "Apache Software
27  * Foundation" must not be used to endorse or promote products derived
28  * from this software without prior written permission. For written
29  * permission, please contact apache@apache.org.
30  *
31  * 5. Products derived from this software may not be called "Apache"
32  * nor may "Apache" appear in their names without prior written
33  * permission of the Apache Group.
34  *
35  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
36  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
37  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
38  * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
39  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
40  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
41  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
42  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
43  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
44  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
45  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
46  * SUCH DAMAGE.
47  * ====================================================================
48  *
49  * This software consists of voluntary contributions made by many
50  * individuals on behalf of the Apache Software Foundation. For more
51  * information on the Apache Software Foundation, please see
52  * <http://www.apache.org/>.
53  */

54
55 package edu.umd.cs.findbugs.anttask;
56
57 import java.io.File JavaDoc;
58 import java.util.ArrayList JavaDoc;
59 import java.util.List JavaDoc;
60 import java.util.Properties JavaDoc;
61
62 import org.apache.tools.ant.BuildException;
63 import org.apache.tools.ant.Task;
64 import org.apache.tools.ant.taskdefs.Java;
65 import org.apache.tools.ant.types.Path;
66 import org.apache.tools.ant.types.Reference;
67
68 import edu.umd.cs.findbugs.ExitCodes;
69
70
71 /**
72  * FindBugs in Java class files. This task can take the following
73  * arguments:
74  * <ul>
75  * <li>adjustExperimental (boolean default false)
76  * <li>auxAnalyzepath (class, jar, zip files or directories containing classes to analyze)
77  * <li>auxClasspath (classpath or classpathRef)
78  * <li>class (class, jar, zip or directory containing classes to analyze)
79  * <li>classpath (classpath for running FindBugs)
80  * <li>conserveSpace (boolean - default false)</li>
81  * <li>debug (boolean default false)
82  * <li>effort (enum min|default|max)</li>
83  * <li>excludeFilter (filter filename)
84  * <li>failOnError (boolean - default false)
85  * <li>home (findbugs install dir)
86  * <li>includeFilter (filter filename)
87  * <li>jvmargs (any additional jvm arguments)
88  * <li>omitVisitors (collection - comma seperated)
89  * <li>output (enum text|xml|xml:withMessages|html - default xml)
90  * <li>outputFile (name of output file to create)
91  * <li>pluginList (list of plugin Jar files to load)
92  * <li>projectFile (project filename)
93  * <li>quietErrors (boolean - default false)
94  * <li>relaxed (boolean - default false)
95  * <li>reportLevel (enum experimental|low|medium|high)
96  * <li>sort (boolean default true)
97  * <li>stylesheet (name of stylesheet to generate HTML: default is "default.xsl")
98  * <li>systemProperty (a system property to set)
99  * <li>timestampNow (boolean - default false)
100  * <li>visitors (collection - comma seperated)
101  * <li>workHard (boolean default false)
102  * </ul>
103  * Of these arguments, the <b>home</b> is required.
104  * <b>projectFile</b> is required if nested &lt;class&gt; or
105  * &lt;auxAnalyzepath&gt elements are not specified. the
106  * &lt;class&gt; tag defines the location of either a
107  * class, jar file, zip file, or directory containing classes.
108  * <p>
109  *
110  * @author Mike Fagan <a HREF="mailto:mfagan@tde.com">mfagan@tde.com</a>
111  * @author Michael Tamm <a HREF="mailto:mail@michaeltamm.de">mail@michaeltamm.de</a>
112  *
113  * @version $Revision: 1.42 $
114  *
115  * @since Ant 1.5
116  *
117  * @ant.task category="utility"
118  */

119
120 public class FindBugsTask extends Task {
121
122     private static final String JavaDoc FINDBUGS_JAR = "findbugs.jar";
123     private static final long DEFAULT_TIMEOUT = 600000; // ten minutes
124

125     private boolean debug = false;
126     private String JavaDoc effort;
127     private boolean conserveSpace = false;
128     private boolean sorted = true;
129     private boolean timestampNow = true;
130     private boolean quietErrors = false;
131     private boolean failOnError = false;
132     private String JavaDoc errorProperty = null;
133     private String JavaDoc warningsProperty = null;
134     private boolean workHard = false;
135     private boolean relaxed = false;
136     private boolean adjustExperimental = false;
137     private File JavaDoc homeDir = null;
138     private File JavaDoc projectFile = null;
139     private File JavaDoc excludeFile = null;
140     private File JavaDoc includeFile = null;
141     private Path auxClasspath = null;
142     private Path auxAnalyzepath = null;
143     private Path sourcePath = null;
144     private String JavaDoc outputFormat = "xml";
145     private String JavaDoc reportLevel = null;
146     private String JavaDoc jvmargs = "";
147     private String JavaDoc visitors = null;
148     private String JavaDoc omitVisitors = null;
149     private String JavaDoc outputFileName = null;
150     private String JavaDoc stylesheet = null;
151     private List JavaDoc<ClassLocation> classLocations = new ArrayList JavaDoc<ClassLocation>();
152     private long timeout = DEFAULT_TIMEOUT;
153     private Path classpath = null;
154     private Path pluginList = null;
155     private List JavaDoc<SystemProperty> systemPropertyList = new ArrayList JavaDoc<SystemProperty>();
156
157     private Java findbugsEngine = null;
158
159     //define the inner class to store class locations
160
public static class ClassLocation {
161         File JavaDoc classLocation = null;
162
163         public void setLocation( File JavaDoc location ) {
164             classLocation = location;
165         }
166
167         public File JavaDoc getLocation( ) {
168             return classLocation;
169         }
170       
171         @Override JavaDoc
172         public String JavaDoc toString( ) {
173            return classLocation!=null?classLocation.toString():"";
174         }
175  
176     }
177
178     // A System property to set when FindBugs is run
179
public static class SystemProperty {
180         private String JavaDoc name;
181         private String JavaDoc value;
182
183         public SystemProperty() {
184         }
185
186         public void setName(String JavaDoc name) { this.name = name; }
187         public void setValue(String JavaDoc value) { this.value = value; }
188
189         public String JavaDoc getName() { return name; }
190         public String JavaDoc getValue() { return value; }
191     }
192
193     /**
194      * Set any specific jvm args
195      */

196     public void setJvmargs(String JavaDoc args) {
197         this.jvmargs = args;
198     }
199
200     /**
201      * Set the workHard flag.
202      *
203      * @param workHard true if we want findbugs to run with workHard option enabled
204      */

205     public void setWorkHard(boolean workHard){
206         this.workHard = workHard;
207     }
208
209     /**
210      * Set the relaxed flag.
211      *
212      * @param relaxed true if we want findbugs to run with relaxed option enabled
213      */

214     public void setRelaxed(boolean relaxed) {
215         this.relaxed = relaxed;
216     }
217     
218     /**
219      * Set the adjustExperimental flag
220      *
221      * @param adjustExperimental true if we want experimental bug patterns to have lower priority
222      */

223     public void setAdjustExperimental(boolean adjustExperimental){
224         this.adjustExperimental = adjustExperimental;
225     }
226     
227     /**
228      * Set the specific visitors to use
229      */

230     public void setVisitors(String JavaDoc commaSeperatedString) {
231         this.visitors = commaSeperatedString;
232     }
233
234     /**
235      * Set the specific visitors to use
236      */

237     public void setOmitVisitors(String JavaDoc commaSeperatedString) {
238         this.omitVisitors = commaSeperatedString;
239     }
240
241     /**
242      * Set the home directory into which findbugs was installed
243      */

244     public void setHome(File JavaDoc homeDir) {
245         this.homeDir = homeDir;
246     }
247
248     /**
249      * Set the output format
250      */

251     public void setOutput(String JavaDoc format) {
252         this.outputFormat = format;
253     }
254
255     /**
256      * Set the stylesheet filename for HTML generation.
257      */

258     public void setStylesheet(String JavaDoc stylesheet) {
259         this.stylesheet = stylesheet;
260     }
261
262     /**
263      * Set the report level
264      */

265     public void setReportLevel(String JavaDoc level) {
266         this.reportLevel = level;
267     }
268
269     /**
270      * Set the sorted flag
271      */

272     public void setSort(boolean flag) {
273         this.sorted = flag;
274     }
275     /**
276      * Set the timestampNow flag
277      */

278     public void setTimestampNow(boolean flag) {
279         this.timestampNow = flag;
280     }
281
282     /**
283      * Set the quietErrors flag
284      */

285     public void setQuietErrors(boolean flag) {
286         this.quietErrors = flag;
287     }
288
289     /**
290      * Set the failOnError flag
291      */

292     public void setFailOnError(boolean flag) {
293         this.failOnError = flag;
294     }
295
296     /**
297      * Tells this task to set the property with the
298      * given name to "true" when there were errors.
299      */

300     public void setErrorProperty(String JavaDoc name) {
301         this.errorProperty = name;
302     }
303     
304     /**
305      * Tells this task to set the property with the
306      * given name to "true" when bugs were found.
307      */

308     public void setWarningsProperty(String JavaDoc name) {
309         this.warningsProperty = name;
310     }
311
312     /**
313      * Set the debug flag
314      */

315     public void setDebug(boolean flag) {
316         this.debug = flag;
317     }
318
319     /**
320      * Set effort level.
321      *
322      * @param effort the effort level
323      */

324     public void setEffort(String JavaDoc effort) {
325         this.effort = effort;
326     }
327
328     /**
329      * Set the conserveSpace flag.
330      */

331     public void setConserveSpace(boolean flag) {
332         this.conserveSpace = flag;
333     }
334
335     /**
336      * Set the exclude filter file
337      */

338     public void setExcludeFilter(File JavaDoc filterFile) {
339         this.excludeFile = filterFile;
340     }
341
342     /**
343      * Set the exclude filter file
344      */

345     public void setIncludeFilter(File JavaDoc filterFile) {
346         this.includeFile = filterFile;
347     }
348
349     /**
350      * Set the project file
351      */

352     public void setProjectFile(File JavaDoc projectFile) {
353         this.projectFile = projectFile;
354     }
355
356     /**
357      * the auxclasspath to use.
358      */

359     public void setAuxClasspath(Path src) {
360         boolean nonEmpty = false;
361         
362         String JavaDoc[] elementList = src.list();
363         for (String JavaDoc anElementList : elementList) {
364             if (!anElementList.equals("")) {
365                 nonEmpty = true;
366                 break;
367             }
368         }
369         
370         if (nonEmpty) {
371             if (auxClasspath == null) {
372                 auxClasspath = src;
373             } else {
374                 auxClasspath.append(src);
375             }
376         }
377     }
378
379     /**
380      * Path to use for auxclasspath.
381      */

382     public Path createAuxClasspath() {
383         if (auxClasspath == null) {
384             auxClasspath = new Path(getProject());
385         }
386         return auxClasspath.createPath();
387     }
388
389     /**
390      * Adds a reference to a sourcepath defined elsewhere.
391      */

392     public void setAuxClasspathRef(Reference r) {
393         createAuxClasspath().setRefid(r);
394     }
395
396     /**
397      * the auxAnalyzepath to use.
398      */

399     public void setAuxAnalyzepath(Path src) {
400         boolean nonEmpty = false;
401         
402         String JavaDoc[] elementList = src.list();
403         for (String JavaDoc anElementList : elementList) {
404             if (!anElementList.equals("")) {
405                 nonEmpty = true;
406                 break;
407             }
408         }
409         
410         if (nonEmpty) {
411             if (auxAnalyzepath == null) {
412                 auxAnalyzepath = src;
413             } else {
414                 auxAnalyzepath.append(src);
415             }
416         }
417     }
418
419     /**
420      * Path to use for auxAnalyzepath.
421      */

422     public Path createAuxAnalyzepath() {
423         if (auxAnalyzepath == null) {
424             auxAnalyzepath = new Path(getProject());
425         }
426         return auxAnalyzepath.createPath();
427     }
428
429     /**
430      * Adds a reference to a sourcepath defined elsewhere.
431      */

432     public void setAuxAnalyzepathRef(Reference r) {
433         createAuxAnalyzepath().setRefid(r);
434     }
435
436     /**
437      * the sourcepath to use.
438      */

439     public void setSourcePath(Path src) {
440         if (sourcePath == null) {
441             sourcePath = src;
442         } else {
443             sourcePath.append(src);
444         }
445     }
446
447     /**
448      * Path to use for sourcepath.
449      */

450     public Path createSourcePath() {
451         if (sourcePath == null) {
452             sourcePath = new Path(getProject());
453         }
454         return sourcePath.createPath();
455     }
456
457     /**
458      * Adds a reference to a source path defined elsewhere.
459      */

460     public void setSourcePathRef(Reference r) {
461         createSourcePath().setRefid(r);
462     }
463
464     /**
465      * Add a class location
466      */

467     public ClassLocation createClass() {
468         ClassLocation cl = new ClassLocation();
469         classLocations.add( cl );
470         return cl;
471     }
472
473     /**
474      * Set name of output file.
475      */

476     public void setOutputFile(String JavaDoc outputFileName) {
477         this.outputFileName = outputFileName;
478     }
479
480     /**
481      * Set timeout in milliseconds.
482      * @param timeout the timeout
483      */

484     public void setTimeout(long timeout) {
485         this.timeout = timeout;
486     }
487
488     @Override JavaDoc
489     public void execute() throws BuildException {
490         checkParameters();
491         try {
492             execFindbugs();
493         } catch (BuildException e) {
494             if (errorProperty != null) {
495                 getProject().setProperty(errorProperty, "true");
496             }
497             if (failOnError) {
498                 throw e;
499             }
500         }
501     }
502
503     /**
504      * the classpath to use.
505      */

506     public void setClasspath(Path src) {
507         if (classpath == null) {
508             classpath = src;
509         } else {
510             classpath.append(src);
511         }
512     }
513
514     /**
515      * Path to use for classpath.
516      */

517     public Path createClasspath() {
518         if (classpath == null) {
519             classpath = new Path(getProject());
520         }
521         return classpath.createPath();
522     }
523
524     /**
525      * Adds a reference to a classpath defined elsewhere.
526      */

527     public void setClasspathRef(Reference r) {
528         createClasspath().setRefid(r);
529     }
530
531     /**
532      * the plugin list to use.
533      */

534     public void setPluginList(Path src) {
535         if (pluginList == null) {
536             pluginList = src;
537         } else {
538             pluginList.append(src);
539         }
540     }
541
542     /**
543      * Path to use for plugin list.
544      */

545     public Path createPluginList() {
546         if (pluginList == null) {
547             pluginList = new Path(getProject());
548         }
549         return pluginList.createPath();
550     }
551
552     /**
553      * Adds a reference to a plugin list defined elsewhere.
554      */

555     public void setPluginListRef(Reference r) {
556         createPluginList().setRefid(r);
557     }
558
559     /**
560      * Create a SystemProperty (to handle &lt;systemProperty&gt; elements).
561      */

562     public SystemProperty createSystemProperty() {
563         SystemProperty systemProperty = new SystemProperty();
564         systemPropertyList.add(systemProperty);
565         return systemProperty;
566     }
567
568     /**
569      * Check that all required attributes have been set
570      *
571      * @since Ant 1.5
572      */

573     private void checkParameters() {
574         if ( homeDir == null && (classpath == null || pluginList == null) ) {
575             throw new BuildException( "either home attribute or " +
576                                       "classpath and pluginList attributes " +
577                                       " must be defined for task <"
578                                         + getTaskName() + "/>",
579                                       getLocation() );
580         }
581
582         if (pluginList != null) {
583             // Make sure that all plugins are actually Jar files.
584
String JavaDoc[] pluginFileList = pluginList.list();
585             for (String JavaDoc pluginFile : pluginFileList) {
586                 if (!pluginFile.endsWith(".jar")) {
587                     throw new BuildException("plugin file " + pluginFile + " is not a Jar file " +
588                             "in task <" + getTaskName() + "/>",
589                             getLocation());
590                 }
591             }
592         }
593
594         if ( projectFile == null && classLocations.size() == 0 && auxAnalyzepath == null) {
595             throw new BuildException( "either projectfile, <class/> or <auxAnalyzepath/> child " +
596                                       "elements must be defined for task <"
597                                         + getTaskName() + "/>",
598                                       getLocation() );
599         }
600  
601         if ( outputFormat != null &&
602             !( outputFormat.trim().equalsIgnoreCase("xml" ) ||
603                outputFormat.trim().equalsIgnoreCase("xml:withMessages" ) ||
604                outputFormat.trim().equalsIgnoreCase("html" ) ||
605                outputFormat.trim().equalsIgnoreCase("text" ) ||
606                outputFormat.trim().equalsIgnoreCase("xdocs" ) ||
607                outputFormat.trim().equalsIgnoreCase("emacs") ) ) {
608             throw new BuildException( "output attribute must be either " +
609                                       "'text', 'xml', 'html', 'xdocs' or 'emacs' for task <"
610                                         + getTaskName() + "/>",
611                                       getLocation() );
612         }
613     
614         if ( reportLevel != null &&
615             !( reportLevel.trim().equalsIgnoreCase("experimental" ) ||
616                reportLevel.trim().equalsIgnoreCase("low" ) ||
617                reportLevel.trim().equalsIgnoreCase("medium" ) ||
618                reportLevel.trim().equalsIgnoreCase("high" ) ) ) {
619             throw new BuildException( "reportlevel attribute must be either " +
620                                       "'experimental' or 'low' or 'medium' or 'high' for task <" +
621                                         getTaskName() + "/>",
622                                       getLocation() );
623         }
624
625         if ( excludeFile != null && includeFile != null ) {
626             throw new BuildException("only one of excludeFile and includeFile " +
627                 " attributes may be used in task <" + getTaskName() + "/>",
628                 getLocation());
629         }
630
631         for (SystemProperty aSystemPropertyList : systemPropertyList) {
632             SystemProperty systemProperty = (SystemProperty) aSystemPropertyList;
633             if (systemProperty.getName() == null || systemProperty.getValue() == null)
634                 throw new BuildException("systemProperty elements must have name and value attributes");
635         }
636         
637         if (effort != null && !effort.equals("min") && !effort.equals("default") && !effort.equals("max")) {
638             throw new BuildException("effort attribute must be one of 'min', 'default', or 'max'");
639         }
640     }
641
642     /**
643      * Add an argument to the JVM used to execute FindBugs.
644      * @param arg the argument
645      */

646     private void addArg(String JavaDoc arg) {
647         findbugsEngine.createArg().setValue(arg);
648     }
649
650     /**
651      * Create a new JVM to do the work.
652      *
653      * @since Ant 1.5
654      */

655     private void execFindbugs() throws BuildException {
656         findbugsEngine = (Java) getProject().createTask("java");
657
658         findbugsEngine.setTaskName( getTaskName() );
659         findbugsEngine.setFork( true );
660         findbugsEngine.setTimeout( timeout );
661
662         if ( debug )
663             jvmargs = jvmargs + " -Dfindbugs.debug=true";
664         findbugsEngine.createJvmarg().setLine( jvmargs );
665
666         // Add JVM arguments for system properties
667
for (SystemProperty aSystemPropertyList : systemPropertyList) {
668             SystemProperty systemProperty = (SystemProperty) aSystemPropertyList;
669             String JavaDoc jvmArg = "-D" + systemProperty.getName() + "=" + systemProperty.getValue();
670             findbugsEngine.createJvmarg().setValue(jvmArg);
671         }
672
673         if (homeDir != null) {
674             // Use findbugs.home to locate findbugs.jar and the standard
675
// plugins. This is the usual means of initialization.
676

677             findbugsEngine.setJar( new File JavaDoc( homeDir + File.separator + "lib" +
678                                          File.separator + FINDBUGS_JAR ) );
679
680             addArg("-home");
681             addArg(homeDir.getPath());
682         } else {
683             // Use an explicitly specified classpath and list of plugin Jars
684
// to initialize. This is useful for other tools which may have
685
// FindBugs installed using a non-standard directory layout.
686

687             findbugsEngine.setClasspath(classpath);
688             findbugsEngine.setClassname("edu.umd.cs.findbugs.FindBugs2");
689
690             addArg("-pluginList");
691             addArg(pluginList.toString());
692         }
693         
694         if (adjustExperimental) {
695             addArg("-adjustExperimental");
696         }
697
698         if ( conserveSpace ) {
699             addArg("-conserveSpace");
700         }
701         if ( workHard ){
702             addArg("-workHard");
703         }
704         if ( effort != null ) {
705             addArg("-effort:" + effort);
706         }
707
708         if ( sorted ) addArg("-sortByClass");
709         if ( timestampNow ) addArg("-timestampNow");
710         
711         if ( outputFormat != null && !outputFormat.trim().equalsIgnoreCase("text") ) {
712             outputFormat = outputFormat.trim();
713             String JavaDoc outputArg = "-";
714             int colon = outputFormat.indexOf(':');
715             if (colon >= 0) {
716                 outputArg += outputFormat.substring(0, colon).toLowerCase();
717                 outputArg += ":";
718                 outputArg += outputFormat.substring(colon + 1);
719             } else {
720                 outputArg += outputFormat.toLowerCase();
721                 if (stylesheet != null) {
722                     outputArg += ":";
723                     outputArg += stylesheet.trim();
724                 }
725             }
726             addArg(outputArg);
727         }
728         if ( quietErrors ) addArg("-quiet");
729         if ( reportLevel != null ) addArg("-" + reportLevel.trim().toLowerCase());
730         if ( projectFile != null ) {
731             addArg("-project");
732             addArg(projectFile.getPath());
733         }
734         if ( excludeFile != null ) {
735             addArg("-exclude");
736             addArg(excludeFile.getPath());
737         }
738         if ( includeFile != null) {
739             addArg("-include");
740             addArg(includeFile.getPath());
741         }
742         if ( visitors != null) {
743             addArg("-visitors");
744             addArg(visitors);
745         }
746         if ( omitVisitors != null ) {
747             addArg("-omitVisitors");
748             addArg(omitVisitors);
749         }
750         if ( auxClasspath != null ) {
751             addArg("-auxclasspath");
752             addArg(auxClasspath.toString());
753         }
754         if ( sourcePath != null) {
755             addArg("-sourcepath");
756             addArg(sourcePath.toString());
757         }
758         if ( outputFileName != null ) {
759             addArg("-outputFile");
760             addArg(outputFileName);
761         }
762         if ( relaxed ) {
763             addArg("-relaxed");
764         }
765         
766         addArg("-exitcode");
767         for (ClassLocation classLocation : classLocations) {
768             addArg(classLocation.toString());
769         }
770
771         if (auxAnalyzepath != null) {
772             String JavaDoc[] result = auxAnalyzepath.toString().split(java.io.File.pathSeparator);
773             for (int x=0; x<result.length; x++) {
774                 addArg(result[x]);
775             }
776         }
777
778         log("Running FindBugs...");
779
780         int rc = findbugsEngine.executeJava();
781
782         if ((rc & ExitCodes.ERROR_FLAG) != 0) {
783             throw new BuildException("Execution of findbugs failed.");
784         }
785         if ((rc & ExitCodes.MISSING_CLASS_FLAG) != 0) {
786             log("Classes needed for analysis were missing");
787         }
788         if (warningsProperty != null && (rc & ExitCodes.BUGS_FOUND_FLAG) != 0) {
789             getProject().setProperty(warningsProperty, "true");
790         }
791         
792         if (outputFileName != null) {
793             log("Output saved to " + outputFileName);
794         }
795     }
796
797 }
798
799 // vim:ts=4
800
Popular Tags