Changing ant build script arguments?

I currently have a build script set up that can compile my programs however I have multiple programs in my project and do not wish to have a new build script for each of them or a very bloated script with a lot of repeated targets for each program.

Here is the build.xml contents:
Here is the contents:

I want to be able to have multiple different run configurations in IntelliJ that can each have different values for "main.class" and "output.basename" in

I did a little research and from what I can understand, in the console commands for ant I can use -Dmain.class=foo.class to pass different parameters but I can't figure out how to do that for run configurations in IntelliJ.

Any help would be appreciated since currently I'm having to manually change and it's slowing down my work.

Comment actions Permalink

It's not possible to configure this in IntelliJ IDEA. However, what you can do instead is have multiple files or targets for each of your programs that all delegate to your main build script. For example:

<target name="MyProgram1">
  <ant antfile="mainbuild.xml">     <property name="main.class" value="MyMainClass"/>     <property name="output.basename" value="..."/>   </ant>
Comment actions Permalink

Fantastic! That's exactly what I need.

How would I do this for running another target in the same file rather than a seperate one?

Comment actions Permalink

You can use the <antcall> task for this purpose.


Please sign in to leave a comment.