我正在从纯桌面Eclipse开发人员迁移多个项目。构建到构建服务器(Jenkins-CI)环境。对于这个项目,我可以运行build.xml - >运行方式 - > Ant在Eclipse下成功构建,但在构建服务器上运行时失败。我觉得我错过了一些基本的东西,但我花了很多时间看这个。什么缺少什么想法?
<path id="lib-classpath">
<!-- create a path to the lib files used in the javac compilation -->
<fileset dir="${lib.dir}">
<include name="*.jar"/>
</fileset>
</path>
<target name="init">
<mkdir dir="${bin.dir}"/>
<mkdir dir="${lib.dir}"/>
</target>
<target name="check-DatabaseUtil">
<property name="DatabaseUtil.dir" value="../../DatabaseUtil/workspace" />
<property name="DatabaseUtil.jar" value="DatabaseUtil.jar" />
<echo message="checking for ${DatabaseUtil.dir}/${DatabaseUtil.jar}..."/>
<available file="${DatabaseUtil.dir}/${DatabaseUtil.jar}" property="DatabaseUtil.present"/>
</target>
<target name="do-if-DatabaseUtil" depends="check-DatabaseUtil" if="DatabaseUtil.present">
<echo message="copy ${DatabaseUtil.dir}/${DatabaseUtil.jar} into directory ${lib.dir} ..."/>
<copy file="${DatabaseUtil.dir}/${DatabaseUtil.jar}" todir="${lib.dir}" />
</target>
<target name="compile" depends="init, do-if-DatabaseUtil">
<echo message="compile from directory ${source.dir} into directory ${bin.dir} ..." />
<javac srcdir="${source.dir}" destdir="${bin.dir}">
<classpath refid="lib-classpath"/>
</javac>
</target>
<target name="jar" depends="compile">
<property name="jar.name" value="${ant.project.name}.jar"/>
<echo message="create file ${jar.name} ..." />
<jar basedir="${bin.dir}" jarfile="${jar.name}">
<fileset dir="${lib.dir}">
<!-- include the library .jars into the file project .jar file -->
<include name="*.jar"/>
</fileset>
</jar>
<echo message="Done" />
</target>
当我使用Jenkins在buildserver上运行构建时,它显然无法找到lib目录中存在的DatabaseUtil.jar。这是录制的控制台输出:
Ant编译失败:
Started by user anonymous
Building in workspace /var/lib/jenkins/workspace/ClassifyProcessor
Updating svn://10.10.10.194/proficient/ClassifyProcessor/trunk at revision '2014-10-23T11:41:59.153 -0400'
U build.xml
U .classpath
At revision 5181
[ClassifyProcessor] $ ant
Buildfile: /var/lib/jenkins/workspace/ClassifyProcessor/build.xml
[echo] Starting project ClassifyProcessor using Java 1.7 and Apache Ant(TM) version 1.8.2 compiled on September 22 2011
Trying to override old definition of task javac
[echo] Staring project ClassifyProcessor in /var/lib/jenkins/workspace/ClassifyProcessor ...
init:
check-DatabaseUtil:
[echo] checking for ../../DatabaseUtil/workspace/DatabaseUtil.jar...
do-if-DatabaseUtil:
compile:
[echo] compile from directory /var/lib/jenkins/workspace/ClassifyProcessor/src into directory /var/lib/jenkins/workspace/ClassifyProcessor/bin ...
[javac] Compiling 32 source files to /var/lib/jenkins/workspace/ClassifyProcessor/bin
[javac] /var/lib/jenkins/workspace/ClassifyProcessor/src/com/hco/processor/Main.java:81: error: cannot find symbol
[javac] fmsList = DatabaseService.getFaxMessageStatusRecordsByStatus("Converted", "Inbound", props.getFaxSourceList(), db_connection);
[javac] ^
[javac] symbol: method getFaxMessageStatusRecordsByStatus(String,String,String[],Connection)
[javac] location: class DatabaseService
[javac] /var/lib/jenkins/workspace/ClassifyProcessor/src/com/hco/processor/Main.java:107: error: cannot find symbol
[javac] FaxMessageStatus fms = DatabaseService.getFaxMessageStatusRecordByIdAndStatus(fmsId, "Converted", db_connection);
[javac] ^
[javac] symbol: method getFaxMessageStatusRecordByIdAndStatus(int,String,Connection)
[javac] location: class DatabaseService
[javac] /var/lib/jenkins/workspace/ClassifyProcessor/src/com/hco/processor/Main.java:346: error: method insertInErrorLog in class DatabaseService cannot be applied to given types;
[javac] DatabaseService.insertInErrorLog(faxMessageStatus.getHost(), "Classify", "Classify", cte.getMessage(), "WARNING", "", faxJobId, fmsId, db_connection);
[javac] ^
[javac] required: String,String,String,String,String,String,Connection
[javac] found: String,String,String,String,String,String,int,int,Connection
[javac] reason: actual and formal argument lists differ in length
[javac] /var/lib/jenkins/workspace/ClassifyProcessor/src/com/hco/processor/Main.java:359: error: method insertInErrorLog in class DatabaseService cannot be applied to given types;
[javac] DatabaseService.insertInErrorLog(faxMessageStatus.getHost(), "Classify", "Classify", e.getMessage(), "FATAL", "", faxJobId, fmsId, db_connection);
[javac] ^
[javac] required: String,String,String,String,String,String,Connection
[javac] found: String,String,String,String,String,String,int,int,Connection
[javac] reason: actual and formal argument lists differ in length
[javac] 4 errors
BUILD FAILED
/var/lib/jenkins/workspace/ClassifyProcessor/build.xml:46: Compile failed; see the compiler error output for details.
Total time: 2 seconds
Build step 'Invoke Ant' marked build as failure
Sending e-mails to: ktanzer@<mycompany>.com
Finished: FAILURE
答案 0 :(得分:0)
尝试<fileset dir="${lib.dir}">
<include name="**/*.jar"/>
</fileset>
答案 1 :(得分:0)
指向您确切的jar文件目录,其中存在jar
<path id="classpath">
<fileset dir="${main.jar}" includes="**/*.jar"/>
<!-- <pathelement location="${src.dir}" />-->
</path>
----in my case jar files present in ----
<property name="main.jar" value="jar"/>