我有一個包含ant任務的jar。我的COM/mebigfatguy/stringliterals/antlib.xml是通過antlib.xml暴露自定義的ant任務
<antlib xmlns:stringliterals="ant:com.mebigfatguy.stringliterals">
<taskdef name="stringliterals" classname="com.mebigfatguy.stringliterals.StringLiteralsTask"/>
</antlib>
運行罐子TF stringliterals.jar我得到
META-INF/
META-INF/MANIFEST.MF
com/
com/mebigfatguy/
com/mebigfatguy/stringliterals/
com/mebigfatguy/stringliterals/antlib.xml
com/mebigfatguy/stringliterals/SLClassVisitor.class
com/mebigfatguy/stringliterals/StringLiteralsTask.class
com/mebigfatguy/stringliterals/SLMethodVisitor.class
com/mebigfatguy/stringliterals/Literal.class
META-INF/maven/
META-INF/maven/com.mebigfatguy.stringliterals/
META-INF/maven/com.mebigfatguy.stringliterals/stringliterals/
META-INF/maven/com.mebigfatguy.stringliterals/stringliterals/pom.xml
META-INF/maven/com.mebigfatguy.stringliterals/stringliterals/pom.properties
com/mebigfatguy/org/
com/mebigfatguy/org/objectweb/
com/mebigfatguy/org/objectweb/asm/
com/mebigfatguy/org/objectweb/asm/AnnotationVisitor.class
com/mebigfatguy/org/objectweb/asm/AnnotationWriter.class
com/mebigfatguy/org/objectweb/asm/Attribute.class
com/mebigfatguy/org/objectweb/asm/ByteVector.class
com/mebigfatguy/org/objectweb/asm/ClassReader.class
com/mebigfatguy/org/objectweb/asm/ClassVisitor.class
com/mebigfatguy/org/objectweb/asm/ClassWriter.class
com/mebigfatguy/org/objectweb/asm/Context.class
com/mebigfatguy/org/objectweb/asm/Edge.class
com/mebigfatguy/org/objectweb/asm/FieldVisitor.class
com/mebigfatguy/org/objectweb/asm/FieldWriter.class
com/mebigfatguy/org/objectweb/asm/Frame.class
com/mebigfatguy/org/objectweb/asm/Handle.class
com/mebigfatguy/org/objectweb/asm/Handler.class
com/mebigfatguy/org/objectweb/asm/Item.class
com/mebigfatguy/org/objectweb/asm/Label.class
com/mebigfatguy/org/objectweb/asm/MethodVisitor.class
com/mebigfatguy/org/objectweb/asm/MethodWriter.class
com/mebigfatguy/org/objectweb/asm/Opcodes.class
com/mebigfatguy/org/objectweb/asm/Type.class
com/mebigfatguy/org/objectweb/asm/TypePath.class
com/mebigfatguy/org/objectweb/asm/TypeReference.class
com/mebigfatguy/org/objectweb/asm/signature/
com/mebigfatguy/org/objectweb/asm/signature/SignatureReader.class
com/mebigfatguy/org/objectweb/asm/signature/SignatureVisitor.class
com/mebigfatguy/org/objectweb/asm/signature/SignatureWriter.class
正如你所看到的任務類是有
我把罐子在〜/ .ant/lib中,當我嘗試運行這樣的任務時引用它:
<target name="literals" xmlns:stringliterals="antlib:com.mebigfatguy.stringliterals" description="generate report of string literals used in code">
<stringliterals:stringliterals>
<classpath refid="fb-contrib.classpath"/>
</stringliterals:stringliterals>
</target>
我得到
種文字:
解析生成文件的jar:文件:/home/dave/.ant/lib/stringliterals-0.2.0.jar與URI =罐子/com/mebigfatguy/stringliterals/antlib.xml! :文件:從zip文件 查找類com.mebigfatguy.stringliterals.StringLiteralsTask
BUILD /home/dave/.ant/lib/stringliterals-0.2.0.jar /com/mebigfatguy/stringliterals/antlib.xml! 的jar:文件:執行此線時出現以下錯誤:未能 /home/dave/dev/fb-contrib/build.xml:245 /home/dave/.ant/lib/stringliterals-0.2.0.jar !/ COM/mebigfa tguy/stringliterals/antlib.xml:2:taskdef類com.mebigfatguy.stringliterals.StringLiteralsTask無法找到 使用類加載器AntClassLoader [] at org.apache.tools.ant.taskdefs.Definer.addDefinition(Definer.java:607 ) at org.apache.tools.ant.taskdefs.Definer.execute(Definer.java:237) at org.apache.tools.ant.taskdefs.Antlib.execute(Antlib.java:177) at org.apache .tools.ant.taskdefs.Definer.loadAntlib(Definer.java:428) 在org.apache.tools.ant.taskdefs.Definer.execute(Definer.java:277) 在org.apache.tools.ant.ComponentHelper .checkNamespace(ComponentHelper.java:874) 在org.apache.tools.ant.ComponentHelper.getDefinition(ComponentHelper.java:307) 在org.apache.tools.ant.ComponentHelper.createCo mponent(ComponentHelper.java:284) at org.apache.tools.ant.ComponentHelper.createComponent(ComponentHelper.java:263) at org.apache.tools.ant.UnknownElement.makeObject(UnknownElement.java:429) at org.apache.tools.ant.UnknownElement.maybeConfigure(UnknownElement.java:163) 在org.apache.tools.ant.Task.perform(Task.java:347) 在org.apache.tools.ant.Target。執行(Target.java:435) at org.apache.tools.ant.Target.performTasks(Target.java:456) at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1393) at org.apache.tools.ant.Project.executeTarget(Project.java:1364) 在org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41) 的組織。 apache.tools.ant.Project.executeTargets(Project.java:1248) 在org.apache.tools.ant.Main.runBuild(Main.java:851) 在org.apache.tools.ant.Main.startAnt( Main.java:235) 在org.apache.tools.ant.launch.Launcher.run(Launcher.java:280) 在org.apache.tools.ant.launch.Launcher.main(Launcher.java:109) 所致:拋出java.lang.ClassNotFoundException:com.mebigfatguy.stringliterals.StringLiteralsTask 在org.apache.tools.ant.AntClassLoader.findClassInComponents(AntClassLoader.java:1366) 在org.apache.tools.ant.AntClassLoader.findClass (AntClassLoader.java:1315) at org.apache.tools.ant。Ant類ClassLoader.loadClass(AntClassLoader.java:1068) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class的.java:348) 在org.apache.tools.ant.taskdefs.Definer.addDefinition(Definer.java:579) ...... 21多個
我已經沒有問題,以前做過幾次,但是這次我沒有看到我出錯的地方。任何方式來調試這個類加載器的問題?這裏https://github.com/mebigfatguy/stringliterals