gpt4 book ai didi

java - 没有 META-INF 的 Ant 构建 Jar

转载 作者:塔克拉玛干 更新时间:2023-11-02 19:00:48 25 4
gpt4 key购买 nike

如何在没有 META-INF 文件夹的情况下使用 ant 构建 jar?我没有指定任何 list 属性:

<jar destfile="${build}/${jar}/${client}.jar" basedir="${build}/${classes}/${main}">
<fileset file="${src}/${main}/application-context.xml" />
<fileset file="${src}/${main}/log4j.xml" />
</jar>

但包含META-INF 文件夹的jar 文件。有什么方法可以排除此文件夹的创建吗?


编辑:

完整的build.xml是:

<?xml version="1.0" encoding="UTF-8"?>
<!-- ======================================================================
Aug 14, 2011 6:25:15 PM
Tanmoy
====================================================================== -->
<project name="Number">
<description>
Number
</description>

<property name="lib" value="lib" />
<property name="src" value="src" />
<property name="build" value="build" />
<property name="classes" value="classes" />
<property name="jar" value="jar" />
<property name="jarfilename" value="Number" />
<property name="client" value="client" />
<property name="main" value="main" />
<property name="loader" value="loader" />

<target name="clean">
<delete dir="${build}" />
</target>

<path id="classpath">
<fileset dir="${lib}" includes="*.jar" />
</path>

<target name="compile">
<delete dir="${lib}" />
<mkdir dir="${lib}" />
<copy file="C:\Users\Tanmoy\.m2\repository\org\swinglabs\swingx-core\1.6.2-2\swingx-core-1.6.2-2.jar" todir="${lib}" />
<copy file="C:\Users\Tanmoy\.m2\repository\org\springframework\spring-core\3.0.5.RELEASE\spring-core-3.0.5.RELEASE.jar" todir="${lib}" />
<copy file="C:\Users\Tanmoy\.m2\repository\org\springframework\spring-asm\3.0.5.RELEASE\spring-asm-3.0.5.RELEASE.jar" todir="${lib}" />
<copy file="C:\Users\Tanmoy\.m2\repository\commons-logging\commons-logging\1.1.1\commons-logging-1.1.1.jar" todir="${lib}" />
<copy file="C:\Users\Tanmoy\.m2\repository\org\springframework\spring-context\3.0.5.RELEASE\spring-context-3.0.5.RELEASE.jar" todir="${lib}" />
<copy file="C:\Users\Tanmoy\.m2\repository\org\springframework\spring-aop\3.0.5.RELEASE\spring-aop-3.0.5.RELEASE.jar" todir="${lib}" />
<copy file="C:\Users\Tanmoy\.m2\repository\aopalliance\aopalliance\1.0\aopalliance-1.0.jar" todir="${lib}" />
<copy file="C:\Users\Tanmoy\.m2\repository\org\springframework\spring-beans\3.0.5.RELEASE\spring-beans-3.0.5.RELEASE.jar" todir="${lib}" />
<copy file="C:\Users\Tanmoy\.m2\repository\org\springframework\spring-expression\3.0.5.RELEASE\spring-expression-3.0.5.RELEASE.jar" todir="${lib}" />
<copy file="C:\Users\Tanmoy\.m2\repository\log4j\apache-log4j-extras\1.0\apache-log4j-extras-1.0.jar" todir="${lib}" />
<copy file="C:\Users\Tanmoy\.m2\repository\log4j\log4j\1.2.9\log4j-1.2.9.jar" todir="${lib}" />
<copy file="F:\Number\Number\jars\dj-nativeswing-0.9.8.jar" todir="${lib}" />
<copy file="F:\Number\Number\jars\dj-nativeswing-swt-0.9.8.jar" todir="${lib}" />
<copy file="F:\Number\Number\jars\dj-swingsuite-0.9.1.jar" todir="${lib}" />
<copy file="F:\Number\Number\jars\swt-linux32-3.6.2.jar" todir="${lib}" />
<copy file="F:\Number\Number\jars\swt-linux64-3.6.2.jar" todir="${lib}" />
<copy file="F:\Number\Number\jars\swt-osx32-3.6.2.jar" todir="${lib}" />
<copy file="F:\Number\Number\jars\swt-osx64-3.6.2.jar" todir="${lib}" />
<copy file="F:\Number\Number\jars\swt-win32-3.6.2.jar" todir="${lib}" />
<copy file="F:\Number\Number\jars\swt-win64-3.6.2.jar" todir="${lib}" />

<mkdir dir="${build}/${classes}/${main}" />
<javac srcdir="${src}/${main}" destdir="${build}/${classes}/${main}" classpathref="classpath" />

<mkdir dir="${build}/${classes}/${loader}" />
<javac srcdir="${src}/${loader}" destdir="${build}/${classes}/${loader}" />
</target>

<target name="jar" depends="clean, compile">
<mkdir dir="${build}/${jar}" />

<jar destfile="${build}/${jar}/${client}.jar" basedir="${build}/${classes}/${main}">
<fileset file="${src}/${main}/application-context.xml" />
<fileset file="${src}/${main}/log4j.xml" />
</jar>

<jar destfile="${build}/${jar}/${jarfilename}.${jar}" basedir="${build}/${classes}/${loader}">
<manifest>
<attribute name="Main-Class" value="in.res.num.tpb.loader.ClientLoader" />
</manifest>
<fileset dir="${build}/${jar}" includes="${client}.jar" />
<fileset dir="${lib}" includes="*.jar" />
</jar>

<delete file="${build}/${jar}/${client}.jar" />
</target>

<target name="run" depends="clean, compile, jar">
<java jar="${build}/${jar}/${jarfilename}.${jar}" fork="true" />
</target>
</project>

最佳答案

使用 zip 而不是 jar。为什么要避免使用 META-INF 文件夹?

关于java - 没有 META-INF 的 Ant 构建 Jar,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7137818/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com