0

I'm wanting use ant to run a class and then the debugger (jdb) or the other way round

Whichever way round I do it I need one to return immediately as the other needs to attach...

here's the two tasks I'm working on at the moment... (where debug is the target run)

<target
    name="run-debug-target"
    depends="compile" >
    <java
        fork="true"
        classname="uk.co.bedroomcoders.ple.desktop.DesktopLauncher"
        classpath="bin:libs/gdx-backend-lwjgl.jar:libs/gdx-backend-lwjgl-natives.jar:libs/gdx.jar:libs/gdx-natives.jar" >
        <jvmarg line="-agentlib:jdwp=transport=dt_socket,address=localhost:6000,server=y,suspend=y" />
    </java>
</target>

<target
    name="debug"
    depends="run-debug-target"
    description="debugs the project compiling if needed" >
    <exec spawn="true" executable="jdb">    
        <arg value="-listen" />
        <arg value="localhost:6000"/> 
    </exec>
</target> 
zx81
  • 41,100
  • 9
  • 89
  • 105
Chris Camacho
  • 1,164
  • 1
  • 9
  • 31
  • what is the problem that u're facing? `I need one to return immediately as the other needs to attach`... u'll need to specify the **error / requirement** clearly. – sunbabaphu Jun 27 '14 at 09:16
  • if one task does not return immediately the other cannot run and the debugger cannot attach to the program to be debugged – Chris Camacho Jun 28 '14 at 09:36
  • possible duplicate of [Can Ant launch two java applications concurrently?](http://stackoverflow.com/questions/2158937/can-ant-launch-two-java-applications-concurrently) – Mark O'Connor Jun 29 '14 at 08:14
  • if they were *both* java applications... – Chris Camacho Jun 30 '14 at 09:04

1 Answers1

0

https://ant.apache.org/manual/Tasks/java.html

See the spawn property:

if enabled allows to start a process which will outlive ant. Requires fork=true, and not compatible with timeout, input, output, error, result attributes.

So..

<java
    fork="true"
    spawn="true"
    classname="uk.co.bedroomcoders.ple.desktop.DesktopLauncher"
    classpath="bin:libs/gdx-backend-lwjgl.jar:libs/gdx-backend-lwjgl-natives.jar:libs/gdx.jar:libs/gdx-natives.jar" >
    <jvmarg line="-agentlib:jdwp=transport=dt_socket,address=localhost:6000,server=y,suspend=y" />
</java>

In this way, <java> task will start a new java process running the java class and return immediately without waiting for the process to return.

Dante WWWW
  • 2,729
  • 1
  • 17
  • 33