पर बीएससी जार खोजने से इंकार कर देता है मेरे जीवन के लिए, मैं अपने कमांड लाइन एंट बिल्ड के हिस्से के रूप में चलाने के लिए FindBugs (2.0.1) प्राप्त करने का प्रयास कर रहा हूं। मैं FindBugs JAR डाउनलोड किया है और /home/myuser/java/repo/umd/findbugs/2.0.1/findbugs-2.0.1 करने के लिए इसे निकाले:FindBugs क्लासपाथ
आप स्क्रीनशॉट में देख सकते हैं, के तहत /home/myuser/java/repo/umd/findbugs/2.0.1/findbugs-2.0.1/lib bcel-1.0.jar
नामक एक जार है, और यदि आप इसे खोलते हैं, तो आप देख सकते हैं कि मैंने org.apache.bcel.classfile.ClassFormatException
नामक कक्षा में ड्रिल किया है । वह विचार कायम रखा था।
मैंने फिर /home/myuser/java/repo/umd/findbugs/2.0.1/findbugs-2.0.1/lib/findbugs-ant.jar $ {env.ANT_HOME}/lib को इसे सुलभ बनाने के लिए कॉपी किया चींटी-रेखा से भागने वाली चींटी के संस्करण के लिए (एंटी उदाहरण के बजाय जो ग्रहण में आता है)।
/home/myuser/sandbox/workbench/eclipse/workspace/myapp/
src/
main/
java/
test/
java/
build/
build.xml
build.properties
gen/
bin/
main/ --> where all main Java class files compiled to
test/ --> where all test Java class files compiled to
audits/
qual/
staging/
अंदर build.xml
:
<project name="myapp-build" basedir=".." default="package"
xmlns:fb="antlib:edu.umd.cs.findbugs">
<path id="findbugs.source.path">
<fileset dir="src/main/java">
<include name="**.*java"/>
</fileset>
<fileset dir="src/main/test">
<include name="**.*java"/>
</fileset>
</path>
<taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask"
uri="antlib:edu.umd.cs.findbugs"/>
<!-- Other Ant target omitted for brevity. -->
<target name="run-findbugs">
<!-- Create a temp JAR that FindBugs can use for analysis. -->
<property name="fb.tmp.jar" value="gen/staging/${ant.project.name}-findbugs-temp.jar"/>
<echo message="Creating ${fb.tmp.jar} for FindBugs."/>
<jar destfile="gen/staging/${ant.project.name}-findbugs-temp.jar">
<fileset dir="gen/bin/main" includes="**/*.class"/>
<fileset dir="gen/bin/test" includes="**/*.class"/>
</jar>
<echo message="Conducting code quality tests with FindBugs."/>
<fb:findbugs home="/home/myuser/java/repo/umd/findbugs/2.0.1/findbugs-2.0.1"
output="html" outputFile="gen/audits/qual/findbugs.html" stylesheet="fancy-hist.xsl" failOnError="true">
<sourcePath refid="findbugs.source.path"/>
<class location="${fb.tmp.jar}"/>
</fb:findbugs>
</target>
<target name="echoMsg" depends="run-findbugs">
<echo message="The build is still alive!!!"/>
</target>
</project>
लेकिन जब मैं कमांड लाइन से ant -buildfile build.xml echoMsg
चलाने के लिए, मैं FindBugs में कोई त्रुटि मिलती है:
मेरे परियोजना निर्देशिका संरचना इस प्रकार है
run-findbugs:
[echo] Creating gen/staging/myapp-build-findbugs-temp.jar for FindBugs.
[jar] Building jar: /home/myuser/sandbox/workbench/eclipse/workspace/myapp/gen/staging/myapp-build-findbugs-temp.jar
[echo] Conducting code quality tests with FindBugs.
[fb:findbugs] Executing findbugs from ant task
[fb:findbugs] Running FindBugs...
[fb:findbugs] Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/bcel/classfile/ClassFormatException
[fb:findbugs] Caused by: java.lang.ClassNotFoundException: org.apache.bcel.classfile.ClassFormatException
[fb:findbugs] at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
[fb:findbugs] at java.security.AccessController.doPrivileged(Native Method)
[fb:findbugs] at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
[fb:findbugs] at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
[fb:findbugs] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
[fb:findbugs] at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
[fb:findbugs] Could not find the main class: edu.umd.cs.findbugs.FindBugs2. Program will exit.
[fb:findbugs] Java Result: 1
[fb:findbugs] Output saved to gen/audits/qual/findbugs.html
echoMsg:
[echo] The build is still alive!!!
यहां मुझे क्या है चकित:
- भी
failOnError="true"
साथ, FindBugs का निर्माण भी जब इस क्रम अपवाद - उत्पादन के अंतिम टुकड़ा का सामना करना पड़ा है को रोकने नहीं है "
Output saved to gen/audits/qual/findbugs.html
" एक झूठ है!gen/audits/qual
में कुछ भी नहीं है! bcel-1.0.jar
बिल्कुल libBugs घर के नीचे है, बस lib/निर्देशिका में हर दूसरे JAR की तरह।
कृपया ध्यान दें: findbugs-ant.jar
निश्चित रूप से ANT_HOME/lib में कॉपी किया जाता है; अन्यथा मुझे एक असफल निर्माण मिल रहा होगा शिकायत है कि यह चींटी कार्यों को नहीं मिला। एक सैनिटी चेक के रूप में, मैंने आगे बढ़कर ऐसा किया (मैंने findbugs-ant.jar
को ANT_HOME/lib से हटा दिया और एक असफल निर्माण मिला)। यह निर्माण विफल नहीं होता है (यह सफल होता है!)। यह सिर्फ findbugs नहीं चलाता है।
कोई भी यहां क्या हो रहा है यह पता लगा सकता है? अग्रिम में धन्यवाद!
http://stackoverflow.com/questions/12744819/findbugs-issue-with-ant/ –