Java Ant任务参数的顺序
我是Ant新手,昨天在一些帮助下编写了一个简单的build.xml。然而,在查看运行ant-verbose的输出之后,似乎我必须处理许多JUnit测试的类没有被适当地调用Java Ant任务参数的顺序,java,ant,junit,Java,Ant,Junit,我是Ant新手,昨天在一些帮助下编写了一个简单的build.xml。然而,在查看运行ant-verbose的输出之后,似乎我必须处理许多JUnit测试的类没有被适当地调用 <project name="JUnit_tests" default="run" basedir="."> <!-- Define variable properties --> <property name="src" value="${basedir}"/> <property
<project name="JUnit_tests" default="run" basedir=".">
<!-- Define variable properties -->
<property name="src" value="${basedir}"/>
<property name="junit" value="org.junit.runner.JUnitCore"/>
<!--<property name="junit" value="org.junit.runner.JUnitCore"/>-->
<!-- Appends all jars in the current directory to the classpath -->
<path id="compile.classpath">
<fileset dir="./">
<include name="*.jar"/>
</fileset>
</path>
<!-- Compiles all code in the current directory and append to the classpath -->
<target name="compile">
<javac destdir="${src}" srcdir="${src}">
<classpath refid="compile.classpath"/>
</javac>
</target>
<!-- Runs the Test code with junit argument as long as compile was run previously -->
<target name="run" depends="compile">
<java classname="Tests" fork="true">
<arg value="${junit}"/>
</java>
</target>
然而,基于以下输出,我相信它被称为
java Tests org.junit.runner.JUnitCore
Ant-详细输出:
run:
[java] Executing '/usr/lib/jvm/java-6-sun-1.6.0.26/jre/bin/java' with arguments:
[java] 'Tests'
[java] 'org.junit.runner.JUnitCore'
[java]
[java] The ' characters around the executable and arguments are
[java] not part of the command.
[java] Exception in thread "main" java.lang.NoSuchMethodError: main
[java] Java Result: 1
有什么想法吗?我一直在做研究,但找不到太多关于参数顺序的信息,特别是在java调用中。谢谢 您已经放弃了您的论点(即
测试
)和主类(即org.junit.runner.JUnitCore
)
是程序的参数
是JVM的参数
在这两门课之间,你将有一个主课
Java用法:
用法:java[-options]类[args…]
在本例中,您希望执行org.junit.runner.JUnitCore
的main方法,传递给该main方法的参数应该是Tests
考虑使用
run:
[java] Executing '/usr/lib/jvm/java-6-sun-1.6.0.26/jre/bin/java' with arguments:
[java] 'Tests'
[java] 'org.junit.runner.JUnitCore'
[java]
[java] The ' characters around the executable and arguments are
[java] not part of the command.
[java] Exception in thread "main" java.lang.NoSuchMethodError: main
[java] Java Result: 1