gpt4 book ai didi

java - Ant 构建文件和库

转载 作者:行者123 更新时间:2023-12-02 00:31:31 25 4
gpt4 key购买 nike

我尝试了多种方法来尝试包含依赖库。

我的项目取决于:

appframework-1.03.jar、swing-worker.jar 和 swing-layout jar

这是我的构建文件:

         <?xml version="1.0" encoding="UTF-8"?>
<project name="IvleFileSync" default="dist" basedir=".">
<description>
simple example build file
</description>
<!-- set global properties for this build -->
<property name="src" location="src"/>
<property name="build" location="build"/>
<property name="dist" location="dist"/>

<path id="files-classpath">
<fileset dir="/usr/lib" >
<include name="*.jar"/>
</fileset>
</path>

<target name="init">
<!-- Create the time stamp -->
<tstamp/>
<!-- Create the build directory structure used by compile -->
<mkdir dir="${build}"/>
</target>

<target name="compile" depends="init"
description="compile the source " >
<!-- Compile the java code from ${src} into ${build} -->
<javac srcdir="${src}" destdir="${build}"/>
<classpath>
<path refid="files-classpath" />
<path location="/usr/lib/swing-layout-1.0.3.jar"/>
<path location="/usr/lib/swing-worker-1.1.jar"/>
<path location="/usr/lib/appframework-1.03.jar"/>
</classpath>

</target>

<target name="dist" depends="compile"
description="generate the distribution" >
<!-- Create the distribution directory -->
<mkdir dir="${dist}/lib"/>

<!-- Put everything in ${build} into the MyProject-${DSTAMP}.jar file -->
<jar jarfile="${dist}/lib/IvleFileSync-${DSTAMP}.jar" basedir="${build}"/>
</target>

<target name="clean"
description="clean up" >
<!-- Delete the ${build} and ${dist} directory trees -->
<delete dir="${build}"/>

但是我无法编译源

它总是抛出包org.jdesktop.application不存在错误。

我已将所有 jar 放在“/usr/lib”下

最佳答案

您在定义其类路径之前关闭了 javac 任务:

 <javac srcdir="${src}" destdir="${build}"/>
<classpath>...
^-- javac is closed here.

替换为

<javac srcdir="${src}" destdir="${build}">
<classpath>...</classpath>
</javac>

并且无需将 jar 添加到类路径中两次。您可以使用 <path refid= 包含它们一次,然后第二次列出 jars。

关于java - Ant 构建文件和库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8953169/

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