我使用 ant 构建文件打开了一个现有项目。我收到很多关于 import x 无法解决的错误。我的项目文件夹中没有这些文件的 src 文件,但我有他们编译的 jar 文件。所以我去了 java build path -> libraries 并使用添加外部 JAR 将它们添加到我的项目中,我项目中的所有错误都消失了。
但是,现在当我通过运行 ant 文件构建项目时,我得到了
[javac] Compiling 149 source files to X:\swt\documation\build
[javac] X:\swt\documation\src\swt\documation\bookshelf\objectmodel\Trans.java:20: package utilities does not exist
[javac] import utilities.StringUtils;
因此,给我错误但我修复的相同文件再次给我错误。我究竟做错了什么?我将jar文件添加到java构建路径库中,为什么eclipse找不到这些包?
这是 build.xml 文件。
<?xml version="1.0"?>
<project name="documation" basedir="." default="packageApplication">
<condition property="vob.prefix" value="/cm_data" else="X:">
<os family="unix" />
</condition>
<property name="jar.keystore" value="${vob.prefix}/swt/cots/signJarKey"/>
<property name="oracle.cots.dir" value="${vob.prefix}/swt/cots/oracle/oracle/9.2.0"/>
<property name="utilities.dir" value="${vob.prefix}/swt/utilities/lib"/>
<property name="swt.mailer.dir" value="${vob.prefix}/swt/mailer/lib"/>
<property name="swt.logger.dir" value="${vob.prefix}/swt/logger/lib"/>
<property name="userprofile.dir" value="${vob.prefix}/swt/ups/lib"/>
<property name="apache.dir" value="${vob.prefix}/swt/cots/apache/apache/1.3.12"/>
<property name="jakarta.dir" value="${vob.prefix}/swt/cots/apache/jakarta"/>
<property name="frameworks.dir" value="${vob.prefix}/swt/cots/frameworks"/>
<property name="spring.dir" value="${frameworks.dir}/spring"/>
<property name="zk.dir" value="${frameworks.dir}/zk"/>
<property name="junit.dir" value="${vob.prefix}/swt/cots/junit"/>
<property name="vob.dir" value="."/>
<property name="webapp.name" value="documation"/>
<property name="src.dir" value="${vob.dir}/src"/>
<property name="bin.dir" value="${vob.dir}/bin"/>
<!-- This directory must be created view-private -->
<property name="build.dir" value="${vob.dir}/build"/>
<property name="web.dir" value="${vob.dir}/webapps"/>
<property name="dist.web.dir" value="${build.dir}/webapps"/>
<property name="lib.dir" value="${web.dir}/WEB-INF/lib"/>
<property name="tomcat.home" value="${vob.prefix}/swt/cots/apache/tomcat/6.0.28"/>
<property name="dist.dir" value="${vob.dir}/dist"/>
<property name="tmp.dir" value="${vob.dir}/temp"/>
<property name="report.dir" value="${vob.dir}/webapps/reports"/>
<path id="classpath">
<fileset dir="${junit.dir}">
<include name="*.jar"/>
</fileset>
<fileset dir="${jakarta.dir}">
<include name="*.jar"/>
</fileset>
<fileset dir="${apache.dir}">
<include name="*.jar"/>
</fileset>
<fileset dir="${swt.logger.dir}">
<include name="*.jar"/>
</fileset>
<fileset dir="${oracle.cots.dir}">
<include name="*.jar"/>
</fileset>
<fileset dir="${utilities.dir}">
<include name="*.jar"/>
</fileset>
<fileset dir="${swt.mailer.dir}">
<include name="*.jar"/>
</fileset>
<fileset dir="${userprofile.dir}">
<include name="*.jar"/>
</fileset>
<fileset dir="${tomcat.home}">
<include name="servlet*.jar"/>
</fileset>
<fileset dir="${frameworks.dir}">
<include name="*.jar"/>
</fileset>
<fileset dir="${spring.dir}">
<include name="*.jar"/>
</fileset>
<fileset dir="${zk.dir}">
<include name="*.jar"/>
</fileset>
<fileset dir="${web.dir}/WEB-INF/lib">
<include name="*.jar"/>
</fileset>
<pathelement path="${build.dir}"/>
</path>
<target name="packageApplication" description="tar all application files"
depends="signJars" >
<tar destfile="${dist.dir}/documation.tar"
basedir="${tmp.dir}/webapp"
includes="**"
/>
</target>
<target name="signJars" depends="appletJar">
<signjar jar="${tmp.dir}/${webapp.name}-applet.jar"
alias="dmsKey"
keystore="${jar.keystore}"
storepass="dmsKey"
signedjar="${tmp.dir}/webapp/jsp/${webapp.name}-signed-applet.jar"
/>
<signjar jar="${vob.prefix}/swt/logger/lib/logger.jar"
alias="dmsKey"
keystore="${jar.keystore}"
storepass="dmsKey"
signedjar="${tmp.dir}/webapp/jsp/logger-signed.jar"
/>
<signjar jar="${vob.prefix}/swt/cots/apache/jakarta/commons-httpclient-3.0.1.jar"
alias="dmsKey"
keystore="${jar.keystore}"
storepass="dmsKey"
signedjar="${tmp.dir}/webapp/jsp/httpclient-signed.jar"
/>
<signjar jar="${vob.prefix}/swt/cots/apache/jakarta/commons-logging-api.jar"
alias="dmsKey"
keystore="${jar.keystore}"
storepass="dmsKey"
signedjar="${tmp.dir}/webapp/jsp/commonlogging-signed.jar"
/>
<signjar jar="${vob.prefix}/swt/cots/apache/jakarta/commons-codec-1.3.jar"
alias="dmsKey"
keystore="${jar.keystore}"
storepass="dmsKey"
signedjar="${tmp.dir}/webapp/jsp/commoncodec-signed.jar"
/>
</target>
<target name="appletJar" depends="documationJar">
<jar destfile="${tmp.dir}/${webapp.name}-applet.jar"
basedir="${build.dir}"
includes="swt/documation/dms/webdocs/client/*.class"
/>
</target>
<target name="documationJar" depends="zkStyleJar">
<jar destfile="${tmp.dir}/webapp/WEB-INF/lib/${webapp.name}.jar"
basedir="${build.dir}"
includes="swt/documation/bookshelf/**, swt/documation/dms/** swt/documation/objectmodel/** swt/documation/servlets/**"
excludes="swt/documation/dms/webdocs/client/*.class"
/>
</target>
<target name="zkStyleJar" depends="documationNGJar">
<jar destfile="${tmp.dir}/webapp/WEB-INF/lib/${webapp.name}-ZkStyle.jar"
basedir="${web.dir}/zkStyle"
includes="**"
/>
</target>
<target name="documationNGJar" depends="compileBuildDir">
<jar destfile="${tmp.dir}/webapp/WEB-INF/lib/${webapp.name}NG.jar"
basedir="${build.dir}"
includes="swt/documation/ng/** swt/documation/service/** swt/documation/web/**" />
</target>
<target name="compileBuildDir" description="Compile main source tree java files" depends="copyToTmp">
<javac destdir="${build.dir}" target="1.5" debug="true"
deprecation="false" optimize="true" failonerror="true">
<src path="${src.dir}"/>
<exclude name="test/swt/documation/service/**/*.java"/>
<classpath refid="classpath"/>
</javac>
</target>
<target name="copyToTmp" depends="cleanTmpDir">
<copy todir="${tmp.dir}/webapp">
<fileset dir="${web.dir}">
<exclude name="**/classes/**"/>
<exclude name="**/lib/*.jar"/>
<exclude name="**/zkStyle/**"/>
</fileset>
</copy>
</target>
<target name="cleanTmpDir">
<delete>
<fileset dir="${build.dir}" />
</delete>
<delete>
<fileset dir="${dist.dir}" />
</delete>
<delete>
<fileset dir="${tmp.dir}" />
</delete>
<mkdir dir="${tmp.dir}/webapp"/>
<mkdir dir="${tmp.dir}/webapp/lib"/>
</target>
<target name="reports" description="Compiles all the XML report designs and produces the .jasper files.">
<taskdef name="jrc" classname="net.sf.jasperreports.ant.JRAntCompileTask">
<classpath refid="classpath"/>
</taskdef>
<jrc destdir="${report.dir}">
<src>
<fileset dir="${report.dir}">
<include name="**/*.jrxml"/>
</fileset>
</src>
<classpath refid="classpath"/>
</jrc>
</target>
</project>