How to delegate all build, run, debug tasks to ant?

How can I make IDEA IGNORE the project's path settings, and ONLY use the ant build settings for building, running, and debugging?

I would like to be able to click on a .java source file with a main() and click the "run" or "debug" menu item, and have IDEA use the build.xml file to locate the classes, libraries, etc. Right now, I can create an ant task to run the application after it is built from within ant, but this is external to IDEA. I can't debug it, nor can I run it within IDEA. I've read the ant how-to about 100 times, and searched these forums for 2 hours now, and I see other people have asked the same type of question but don't seem to get answers.

I don't understand the "Execute On" pop up menu some people have mentioned; how will that help to execute an ant task before, or after I compile in IDEA? I don't want to compile in IDEA at all! Also, selecting the "Before Run/Debug" doesn't seem to solve the problem either, because IDEA can't find the classes, because it's looking in the project paths not the paths in the build.xml file.

Thanks =)

Rob Ross

3 comments
Comment actions Permalink

Well after a lot of searching on the web and in these forums, I have come to the conclusion that what I am trying to do cannot be done in IDEA at this time. I think there is an existing feature request for this item, however.

But the "solution" I have employed is to manually (ick, yea I know!) configure the project paths to look in the directories ant creates. The IDEA editor needs the source path set up to display the source files and correctly parse the source code for display and hyperlinking, etc. This is probably pretty stable over the life of the project.

The output directories are a different matter. Since I will be building exclusively with ant (from IDEA), these directories are more delicate; if the build.xml file re-configures the target directory structure, it will break my output path setting in IDEA and I will have to manually fix that. Also, it only allows for one target configuration, whereas with ant, I could conceivably have multiple target directory structures for each task. But for my simple project there's just one build directory and one place where the class files go, so I'm ok for now.

The real pain though is I also have to manually add all my lib jar files to IDEA's classpath tab. This is the area of pain, since these will surely change much during the evolution of a project as jars are added and removed to the project, renamed, etc. This is a total duplication of effort and it would be great if IDEA could get the classpath info from the build.xml file.

So what I can now do is under the Project Properties-->Run/Debug, make sure the "make project before running/debugging" is NOT checked, so that IDEA won't try to build the project when I run it.

Then, I make sure my compile ant task has been selected to "Execute On-->Before Run/Debug".

Now, the only thing I have to remember is NOT to select compile or make project from the IDEA menus; instead, I can select Run/Debug for a class, and I will be assured that ant will compile the project, then IDEA will run the class file (just compiled by ant). I can also manually build the project from IDEA by going to the Build menu and choosing one of the ant tasks that show up there.

This is a pretty reasonable solution, and is working for my particular case. The only downside really is having to manually add all the lib jar files to the IDEA project. It really would be great if IDEA could have a command to "Import settings from build.xml".

0
Comment actions Permalink

It might help you partially that you can right click an Ant target in the
Ant panel and choose to run it before run/debug.

"Rob Ross" <robross@earthlink.net> wrote in message
news:1942306.1056778854923.JavaMail.itn@is.intellij.net...

How can I make IDEA IGNORE the project's path settings, and ONLY use the

ant build settings for building, running, and debugging?
>

I would like to be able to click on a .java source file with a main() and

click the "run" or "debug" menu item, and have IDEA use the build.xml file
to locate the classes, libraries, etc. Right now, I can create an ant task
to run the application after it is built from within ant, but this is
external to IDEA. I can't debug it, nor can I run it within IDEA. I've read
the ant how-to about 100 times, and searched these forums for 2 hours now,
and I see other people have asked the same type of question but don't seem
to get answers.
>

I don't understand the "Execute On" pop up menu some people have

mentioned; how will that help to execute an ant task before, or after I
compile in IDEA? I don't want to compile in IDEA at all! Also, selecting the
"Before Run/Debug" doesn't seem to solve the problem either, because IDEA
can't find the classes, because it's looking in the project paths not the
paths in the build.xml file.
>

Thanks =)

>

Rob Ross



0
Comment actions Permalink

Or to remap the Ctrl+F9 shortcut to some Ant target.

--
Best regards,
Mike Aizatsky.
-


JetBrains, Inc / IntelliJ Software
http://www.intellij.com
"Develop with pleasure!"


0

Please sign in to leave a comment.