DarkMatter in Cyberspace
  • Home
  • Categories
  • Tags
  • Archives

Add Multiple Classpath Items in One Tag


I have to add many jar files to a "javac" and a "junit" task from command line arguments. The inside tag is suited for this situation.

Ant script:

<javac srcdir="${test.dir}"

destdir="\({test.class.dir}" encoding="UTF-8" debug="true" failonerror="true"> <classpath> <pathelement location="\)"/> \({src.class.dir}"/> <pathelement path="\){pdegen.classpath}"/>

\({cobertura.data.file}" /> <classpath> <pathelement location="\){instrumented.class.dir}"/> \({src.class.dir}"/> <pathelement location="\){test.class.dir}"/> \({src.dir}"/> <pathelement location="\){cobertura.path}"/> \({pdegen.classpath}"/> </classpath> <formatter type="xml"/> <batchtest todir="\){unittest.report.dir}" haltonerror="yes">

The corresponding command line is:

ant -Dpdegen.classpath=/path/to/jar1:/path/to/jar2 target_name

Here is the working Python script:

from subprocess import call

test_cmd = 'ant -buildfile unittest.xml -Drootdir='+ base_dir + \

pkg_name +' -Dcobertura.path=/usr/share/ant/lib/cobertura.jar -Dpdegen.classpath='+classpath[pkg_name]

ret = call(test_cmd.split())



Published

Nov 14, 2013

Last Updated

Nov 14, 2013

Category

Tech

Tags

  • Ant 21
  • classpath 7
  • Java 106

Contact

  • Powered by Pelican. Theme: Elegant by Talha Mansoor