I want to run 2 similar java programs using one (the same) ant file.
I have the follwing build.xml
<project name ="Project" basedir="." default="main">
<property name="src.dir" value="src"/>
<property name="build.dir" value="build"/>
<property name="classes.dir" value="${build.dir}/classes"/>
<property name="jar.dir" value="${build.dir}/jar"/>
<property name="main-class" value="implementation1.Main"/>
<target name="main" depends="clean,zip"/>
<target name="build">
<mkdir dir="build"/>
</target>
<target name="clean">
<delete dir="${build.dir}"/>
<delete file ="${zipname}"/>
</target>
<target name = "compile">
<mkdir dir = "${classes.dir}"/>
<javac srcdir="." destdir="${classes.dir}" includeantruntime="false"/>
</target>
<target name="jar" depends="compile">
<mkdir dir="${jar.dir}"/>
<jar destfile="${jar.dir}/${ant.project.name}.jar" basedir="${classes.dir}">
<manifest>
<attribute name="Main-Class" value="${main-class}"/>
</manifest>
</jar>
</target>
<target name="run" depends="jar">
<java jar="${jar.dir}/${ant.project.name}.jar" fork="true" spawn="true" >
</java>
</target>
In the directory, where my build.xml is located, I have an "src" folder. In the path ./src/implementation1/ I have the .java file for my project and a seperate main file in the folder implementation1. It works when I run ant in my folder.
However, I have another (alternative) implementation of my project, let it be called projectAlt.java and it is stored in the folder ./src/implementation2.
Problem 1: When I run the ant with the folder implementation2 in src, I get lots of errors. If I remove the folder, the ant works normally.
Problem 2: How would I set things up in a way that first implementation1 is run then implementation2 ?
I have made myself somewhat clear. Thanks in advance.
最后,我诉诸于在eclipse中制作类似的包结构,jar现在制作2个jar,每个jar具有2个不同的主类,每个主类分别由相应的运行调用运行。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.