我正在尝试构建一个jar文件,并得到错误构建失败。
创建jar:归档包含超过65535个条目的问题。(存档可能损坏了,但我不能删除它)
我使用的是Eclipse Neon Release 1和JDK 1.8.0_101, Eclipse中的Ant版本是1.9.6。
是我的ant构建文件:-
<property name="jar.name" value="ABC.jar" />
<property name="source.root" value="src" />
<property name="class.root" value="bin" />
<property name="lib.dir" value="lib" />
<property name="jar.dir" value="C:DABC-Exe" />
<property name="Main-Class" value="com.abc.xxx.main.ABCEval" />
<property name="conf.pkj" value="com/abc/xxx/business/configurations" />
<property name="img.pkj" value="com/abc/xxx/business/images" />
<path id="project.class.path">
<pathelement location="${class.root}" />
<fileset dir="${lib.dir}">
<include name="*.jar" />
</fileset>
</path>
<target name="clean" description="cleans up build structures">
<delete dir="${class.root}" />
<delete file="${jar.dir}/${jar.name}" />
</target>
<target name="prepare" description="sets up build structures">
<mkdir dir="${class.root}" />
</target>
<target name="compile" depends="prepare" description="Compiles all java classes">
<javac srcdir="${source.root}" destdir="${class.root}" debug="on" optimize="off" deprecation="on" source="1.8" target="1.8" includeantruntime = "false">
<classpath refid="project.class.path" />
</javac>
<mkdir dir="${class.root}/${conf.pkj}" />
<mkdir dir="${class.root}/${imwg.pkj}" />
<copy todir="${class.root}/${conf.pkj}">
<fileset dir="${source.root}/${conf.pkj}" />
</copy>
<copy todir="${class.root}/${img.pkj}">
<fileset dir="${source.root}/${img.pkj}" />
</copy>
</target>
<target name="jar" depends="compile">
<delete file="${jar.dir}/${jar.name}" quiet="true" failonerror="false" />
<jar destfile="${jar.dir}/${jar.name}">
<fileset dir="${class.root}" includes="**/*.*" />
<fileset dir="${source.root}" includes="**/api/*.java,**/api/vo/*.java"/>
<zipgroupfileset dir="${lib.dir}" />
<manifest>
<attribute name="Main-Class" value="${Main-Class}" />
<attribute name="Class-Path" value="." />
</manifest>
</jar>
</target>
<target name="run">
<java fork="true" classname="${Main-Class}">
<classpath>
<path location="./${jar.name}" />
</classpath>
</java>
</target>
在jar
任务上指定zip64Mode
参数,表示需要使用大的'zip64'格式:
<jar destfile="${jar.dir}/${jar.name}" zip64Mode="always">