Ant build.xml正在使用Eclipse。不直接工作
在Eclipse中执行时,我的构建文件似乎正确运行(并生成junit测试报告),但是当我直接使用:Ant build.xml正在使用Eclipse。不直接工作,eclipse,ant,Eclipse,Ant,在Eclipse中执行时,我的构建文件似乎正确运行(并生成junit测试报告),但是当我直接使用:ant-buildfile C:\....\build.xml执行时,不会生成文件,cmd输出表明它没有运行测试 我有两个eclipse项目JUniteT1这是代码JUnitTestTests,其中包含测试代码 我已经按照说明在eclipse中创建了构建文件(仅选择测试项目),并且可以看到这些文件放到junit目录中 当我直接运行ant命令时,不会生成任何文件,而且看起来也不像是在运行我的测试 为什
ant-buildfile C:\....\build.xml执行时,不会生成文件,cmd
输出表明它没有运行测试
我有两个eclipse项目<代码>JUniteT1
这是代码<代码>JUnitTestTests,其中包含测试代码
我已经按照说明在eclipse中创建了构建文件(仅选择测试项目),并且可以看到这些文件放到junit
目录中
当我直接运行ant
命令时,不会生成任何文件,而且看起来也不像是在运行我的测试
为什么通过EclipseGUI所做的更改没有反映在build.xml中?我以为它是自动更新的
我相信我已经解决了这个问题 Eclipse创建您的构建文件,并分别配置您的运行配置。这些运行配置(您在其中指定ant任务的运行顺序)不是持久化的,也不是在实际构建文件中表示的 生成文件的默认目标是target=“build”。。。因此,您需要手动编辑构建文件,并使用dependens=“…”子句将任务的依赖项链接在一起
(阅读示例构建文件并查看最后一行)对depends子句有很好的解释。我相信我已经解决了这个问题 Eclipse创建您的构建文件,并分别配置您的运行配置。这些运行配置(您在其中指定ant任务的运行顺序)不是持久化的,也不是在实际构建文件中表示的 生成文件的默认目标是target=“build”。。。因此,您需要手动编辑构建文件,并使用dependens=“…”子句将任务的依赖项链接在一起 (阅读示例构建文件并查看最后一行)对depends子句有很好的解释
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- WARNING: Eclipse auto-generated file.
Any modifications will be overwritten.
To include a user specific buildfile here, simply create one in the same
directory with the processing instruction <?eclipse.ant.import?>
as the first entry and export the buildfile again. --><project basedir="." default="build" name="JUnitTest1UnitTests">
<property environment="env"/>
<property name="ECLIPSE_HOME" value="../../../../../tools/eclipse-mars/"/>
<property name="junit.output.dir" value="junit"/>
<property name="JUnitTest1.location" value="../JUnitTest1"/>
<property name="debuglevel" value="source,lines,vars"/>
<property name="target" value="1.7"/>
<property name="source" value="1.7"/>
<path id="JUnitTest1.classpath">
<pathelement location="${JUnitTest1.location}/bin"/>
<pathelement location="${JUnitTest1.location}/../../../../../tools/libs/hamcrest-core-1.3.jar"/>
<pathelement location="${JUnitTest1.location}/../../../../../tools/libs/junit-4.12.jar"/>
</path>
<path id="JUnitTest1UnitTests.classpath">
<pathelement location="bin"/>
<pathelement location="../../../../../tools/libs/hamcrest-core-1.3.jar"/>
<pathelement location="../../../../../tools/libs/junit-4.12.jar"/>
<path refid="JUnitTest1.classpath"/>
</path>
<target name="init">
<mkdir dir="bin"/>
<copy includeemptydirs="false" todir="bin">
<fileset dir="src">
<exclude name="**/*.launch"/>
<exclude name="**/*.java"/>
</fileset>
</copy>
</target>
<target name="clean">
<delete dir="bin"/>
</target>
<target depends="clean" name="cleanall">
<ant antfile="build.xml" dir="${JUnitTest1.location}" inheritAll="false" target="clean"/>
</target>
<target depends="build-subprojects,build-project" name="build"/>
<target name="build-subprojects">
<ant antfile="build.xml" dir="${JUnitTest1.location}" inheritAll="false" target="build-project">
<propertyset>
<propertyref name="build.compiler"/>
</propertyset>
</ant>
</target>
<target depends="init" name="build-project">
<echo message="${ant.project.name}: ${ant.file}"/>
<javac debug="true" debuglevel="${debuglevel}" destdir="bin" includeantruntime="false" source="${source}" target="${target}">
<src path="src"/>
<classpath refid="JUnitTest1UnitTests.classpath"/>
</javac>
</target>
<target description="Build all projects which reference this project. Useful to propagate changes." name="build-refprojects"/>
<target description="copy Eclipse compiler jars to ant lib directory" name="init-eclipse-compiler">
<copy todir="${ant.library.dir}">
<fileset dir="${ECLIPSE_HOME}/plugins" includes="org.eclipse.jdt.core_*.jar"/>
</copy>
<unzip dest="${ant.library.dir}">
<patternset includes="jdtCompilerAdapter.jar"/>
<fileset dir="${ECLIPSE_HOME}/plugins" includes="org.eclipse.jdt.core_*.jar"/>
</unzip>
</target>
<target description="compile project with Eclipse compiler" name="build-eclipse-compiler">
<property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/>
<antcall target="build"/>
</target>
<target name="JUnitTest1UnitTests">
<mkdir dir="${junit.output.dir}"/>
<junit fork="yes" printsummary="withOutAndErr">
<formatter type="xml"/>
<test name="com.me.tests.MyTestClass" todir="${junit.output.dir}"/>
<classpath refid="JUnitTest1UnitTests.classpath"/>
</junit>
</target>
<target name="junitreport">
<junitreport todir="${junit.output.dir}">
<fileset dir="${junit.output.dir}">
<include name="TEST-*.xml"/>
</fileset>
<report format="frames" todir="${junit.output.dir}"/>
</junitreport>
</target>