我已经写了一个新的checkstyle检查作为一个文件扫描器。在我在checkstyle代码中找到的代码之后,我模拟了我的junit。联队运行得很好,一切都很好。当checkstyle运行时NoClassDefFoundError
但是,然后,我将检查添加到我的项目。
<module name="TreeWalker">
<property name="tabWidth" value="4" />
<module name="com.onuspride.codetools.checkstyles.DuplicateClassNames"/>
</module>
和我的Ant任务
<taskdef resource="checkstyletask.properties">
<classpath refid="classpath" />
</taskdef>
<property name="checkstyle.suppressions.file" value="checkstyle/suppressions.xml" />
<property name="translation.severity" value="error" />
<target name="checkStyle" description="TestTask to evaluate the checkstyle system.">
<checkstyle config="checkstyle/checkstyle_checks.xml">
<fileset dir="${msg.src}" includes="**/*.java" />
<formatter type="plain" />
<formatter type="xml" toFile="${msg.build.jar}/checkstyle_errors.xml" />
<classpath refid="classpath" />
</checkstyle>
</target>
的duplicateclassnames类调用几个类在同一个瓶子里。出于某种原因,当ant运行它时,ant找到了检查类,但是当它们都在同一个jar文件中时,找不到支持类。这里是我得到的蚂蚁
[checkstyle] [class]:0: Got an exception - java.lang.NoClassDefFoundError: com/onuspride/codetools/common/classpath/criteria/ClassNameCriteriaCollector
Im难倒了。我检查了我的jar的所有依赖项,它们都在类路径中,我不明白它是如何在同一个jar中找到一个类文件但不是另一个类文件。我已经完成了所有我肮脏的小技巧,我只是不明白。
有什么想法?
**我不明白它是如何找到一个类文件,但没有在同一个jar中的另一个** ::你可以告诉你在哪个jar文件下找到了哪个类,哪个类没有。 –
检查类是com.onuspride.codetools.checkstyles.DuplicateClassNames和它找不到的类,它们包含在同一个jar中。 com.onuspride.codetools.common.classpath.criteria.ClassNameCriteriaCollector – scphantm