build.xml 中包含的 jar 文件未按照声明的顺序进入类路径
jar files included in build.xml is not taken in the classpath in the declared order
这是我的 build.xml 文件。我已经按照我需要的特定顺序包含了 jar 文件(这很重要。否则我将得到 package is sealed 异常)。但是我得到的类路径是:
[echo] Classpath is C:\Users\aswathy_krishnan\eclipse-workspace\MerckDemo\lib\iwats-scripting-library-v1.9.jar;C:\Users\aswathy_krishnan\eclipse-workspace\MerckDemo\lib\jcommander-1.27.jar;C:\Users\aswathy_krishnan\eclipse-workspace\MerckDemo\lib\json-20160810.jar;C:\Users\aswathy_krishnan\eclipse-workspace\MerckDemo\lib\tessract-wrapper.jar;C:\Users\aswathy_krishnan\eclipse-workspace\MerckDemo\lib\testng-6.11.jar
What am I doing wrong? How can I make sure my tesseract wrapper is always the first jar to be included? I am a beginner in ANT.
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project basedir="." default="main" name="MerckDemo">
<property environment="env" />
<property name="debuglevel" value="source,lines,vars" />
<property name="target" value="1.8" />
<property name="source" value="1.8" />
<property name="src.dir" location="src" />
<property name="build.dir" location="bin" />
<property name="dist.dir" location="dist" />
<property name="resources" location="resources" />
<property name="jardest" location="jardest" />
<property name="docs.dir" location="docs" />
<property name="lib" location="lib" />
<path id="build.classpath">
<fileset dir="${lib}">
<include name="tessract-wrapper.jar" />
<include name="testng-6.11.jar" />
<include name="iwats-scripting-library-v1.9.jar" />
<include name="json-20160810.jar" />
<include name="jcommander-1.27.jar" />
</fileset>
</path>
<pathconvert property="classpathProp" refid="build.classpath" />
<echo>Classpath is ${classpathProp}</echo>
<target name="clean">
<delete dir="${build.dir}" />
<delete dir="${dist.dir}" />
<delete dir="${docs.dir}" />
</target>
<target name="init">
<mkdir dir="bin" />
<mkdir dir="dist" />
<mkdir dir="docs" />
</target>
<target name="compile" depends="clean,init">
<javac srcdir="${src.dir}" destdir="${build.dir}" classpathref="build.classpath" includeantruntime="false">
</javac>
</target>
<target name="docs">
<javadoc sourcepath="${src.dir}" destdir="${docs.dir}">
<fileset dir="${src.dir}">
<include name="**" />
</fileset>
</javadoc>
</target>
<target name="setproperties">
<copy file="testproperties.templete" tofile="test.properties" overwrite="true">
<filterset begintoken="@" endtoken="@">
<filter token="application_type" value="${application_type}" />
<filter token="remote_host" value="${remote_host}" />
<filter token="remote_port" value="${remote_port}" />
<filter token="testng_group" value="${testng_group}" />
<filter token="testng_package" value="${testng_package}" />
</filterset>
</copy>
</target>
<target depends="compile,setproperties" name="main">
<java classname="merck.trigger.Trigger" classpath="${build.dir}" classpathref="build.classpath" fork="true">
</java>
</target>
<target description="Build all projects which reference this project. Useful to propagate changes." name="build-refprojects" />
</project>
我尝试 运行 通过 testNG 进行测试并且它有效 fine.This 是因为我优先考虑我的 tesseract jar 的顺序和构建路径的导出选项卡。请帮忙。
fileset
不会生成有序集合。要对类路径定义中的元素进行排序,您应该使用多个 <pathelement ...>
代替:
<path id="build.classpath">
<pathelement location="${lib}/tessract-wrapper.jar"/>
<pathelement location="${lib}/testng-6.11.jar"/>
<pathelement location="${lib}/iwats-scripting-library-v1.9.jar"/>
<pathelement location="${lib}/json-20160810.jar"/>
<pathelement location="${lib}/jcommander-1.27.jar"/>
</path>
这是我的 build.xml 文件。我已经按照我需要的特定顺序包含了 jar 文件(这很重要。否则我将得到 package is sealed 异常)。但是我得到的类路径是:
[echo] Classpath is C:\Users\aswathy_krishnan\eclipse-workspace\MerckDemo\lib\iwats-scripting-library-v1.9.jar;C:\Users\aswathy_krishnan\eclipse-workspace\MerckDemo\lib\jcommander-1.27.jar;C:\Users\aswathy_krishnan\eclipse-workspace\MerckDemo\lib\json-20160810.jar;C:\Users\aswathy_krishnan\eclipse-workspace\MerckDemo\lib\tessract-wrapper.jar;C:\Users\aswathy_krishnan\eclipse-workspace\MerckDemo\lib\testng-6.11.jar
What am I doing wrong? How can I make sure my tesseract wrapper is always the first jar to be included? I am a beginner in ANT.
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project basedir="." default="main" name="MerckDemo">
<property environment="env" />
<property name="debuglevel" value="source,lines,vars" />
<property name="target" value="1.8" />
<property name="source" value="1.8" />
<property name="src.dir" location="src" />
<property name="build.dir" location="bin" />
<property name="dist.dir" location="dist" />
<property name="resources" location="resources" />
<property name="jardest" location="jardest" />
<property name="docs.dir" location="docs" />
<property name="lib" location="lib" />
<path id="build.classpath">
<fileset dir="${lib}">
<include name="tessract-wrapper.jar" />
<include name="testng-6.11.jar" />
<include name="iwats-scripting-library-v1.9.jar" />
<include name="json-20160810.jar" />
<include name="jcommander-1.27.jar" />
</fileset>
</path>
<pathconvert property="classpathProp" refid="build.classpath" />
<echo>Classpath is ${classpathProp}</echo>
<target name="clean">
<delete dir="${build.dir}" />
<delete dir="${dist.dir}" />
<delete dir="${docs.dir}" />
</target>
<target name="init">
<mkdir dir="bin" />
<mkdir dir="dist" />
<mkdir dir="docs" />
</target>
<target name="compile" depends="clean,init">
<javac srcdir="${src.dir}" destdir="${build.dir}" classpathref="build.classpath" includeantruntime="false">
</javac>
</target>
<target name="docs">
<javadoc sourcepath="${src.dir}" destdir="${docs.dir}">
<fileset dir="${src.dir}">
<include name="**" />
</fileset>
</javadoc>
</target>
<target name="setproperties">
<copy file="testproperties.templete" tofile="test.properties" overwrite="true">
<filterset begintoken="@" endtoken="@">
<filter token="application_type" value="${application_type}" />
<filter token="remote_host" value="${remote_host}" />
<filter token="remote_port" value="${remote_port}" />
<filter token="testng_group" value="${testng_group}" />
<filter token="testng_package" value="${testng_package}" />
</filterset>
</copy>
</target>
<target depends="compile,setproperties" name="main">
<java classname="merck.trigger.Trigger" classpath="${build.dir}" classpathref="build.classpath" fork="true">
</java>
</target>
<target description="Build all projects which reference this project. Useful to propagate changes." name="build-refprojects" />
</project>
我尝试 运行 通过 testNG 进行测试并且它有效 fine.This 是因为我优先考虑我的 tesseract jar 的顺序和构建路径的导出选项卡。请帮忙。
fileset
不会生成有序集合。要对类路径定义中的元素进行排序,您应该使用多个 <pathelement ...>
代替:
<path id="build.classpath">
<pathelement location="${lib}/tessract-wrapper.jar"/>
<pathelement location="${lib}/testng-6.11.jar"/>
<pathelement location="${lib}/iwats-scripting-library-v1.9.jar"/>
<pathelement location="${lib}/json-20160810.jar"/>
<pathelement location="${lib}/jcommander-1.27.jar"/>
</path>