我有一个jar文件,每个java文件有两个类文件。
Java的:
Foo.java Bar.java类文件:
Foo.class Foo.class Bar.class Bar.class我已经验证每个类只有一个java文件。 java文件不包含任何内部类。 我正在使用ant jar-task来创建jar文件。 在执行任务之前,构建目录中每个类只有一个类文件。
我看到带有jar -tf jarfile.jar的双类文件,或者当我在zip程序中查看它时。 当我解压缩文件时,zip程序会询问它是否应该覆盖现有文件。
怎么会发生这种情况?
I have a jar file which has two class files per java file.
Java:
Foo.java Bar.javaClassfile:
Foo.class Foo.class Bar.class Bar.classI have verified that there is only one java files per class. The java files do not any contain inner classes. I am using the ant jar-task to create the jar file. Before I execute the task, there is only one class file per class in the build directory.
I see the double class files with jar -tf jarfile.jar or when I view it in a zip program. When I unpack the files, the zip program asks if it should overwrite the existing file.
How can this happen?
最满意答案
你在使用Ant Jar任务吗? 如果是这样,那么你绝对可以在同一个jar文件中获得重复文件。 duplicate属性用于停止它。
请注意,zip格式允许在同一个存档中存在多个具有相同完全限定名称的文件。 这已被证明为不知情的用户造成各种问题。 如果您希望避免此行为,则必须将duplicate属性设置为默认值“add”以外的值。
来自Ant手册页: http : //ant.apache.org/manual/Tasks/jar.html
I think I found the problem. This is the jar task:
<jar basedir="${build.class.dir}" jarfile="${dist.dir}/${subproject}.jar"> <fileset dir="${build.class.dir}" /> </jar>As I read in the Ant website
This task forms an implicit FileSet and supports most attributes of (dir becomes >basedir) as well as the nested , and elements.
So it would seem that either the tag or basedir is uneccessary. At least it works.fine if I comment out the fileset tag.
Thanks for your help and pointers!
更多推荐
发布评论