I build an OSGi application with an Ant build script in IntelliJ IDEA 11. It contains one target that, after compiling and packaging in a JAR my application, starts it with the Ant <java> task (using the "fork" and "spawn" options that allow the build script to end and the program to start independently). I have no problem connecting the IntelliJ debugger in this case. My IntelliJ "debug configuration" has the option checked to run this target before starting the debugger.
However, I also have various "test" targets that invoke JUnit via a wrapper that starts the OSGi framework (Apache Felix) via the <java> task but WITHOUT fork/spawn (the tests run within the Ant script, returning control to the script at the end). And I can't see an option or a way to tell IntelliJ to connect its debugger when the target starts the <java> task. In other words, how can I start the debugger when junit tests are running?