This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes IDEs, Version Control and other tools and the fly likes Ant integration in Eclipse Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "Ant integration in Eclipse" Watch "Ant integration in Eclipse" New topic
Author

Ant integration in Eclipse

Anders Olsen
Greenhorn

Joined: Apr 17, 2003
Posts: 13
As I wrote in another topic, I'm trying to get Eclipse to work on an existing development project.
In this project, we have an Ant build.xml script, that I would like to use in Eclipse. In our project, we have some scripts that sets up the CLASSPATH environment, and we use this in the build.xml by setting the attribute classpath="${env.CLASSPATH}" in e.g. the rmic target.
Is it possible to set this environment variable from Eclipse when running the Ant script? I have tried adding jars and folders in Windows->Preferences->Ant->Runtime, but if I add an echo target to my build.xml script, it doesn't seem to work. Example: I have added the following line to one of my targets:
<echo message="${env.CLASSPATH}" />
When I run the target from Eclipse, it prints out:
[echo] ${env.CLASSPATH}
If I run it from a command prompt with CLASSPATH setup, it echos the classpath as I would expect.
I'm running Eclipse on Windows 2000 if that makes a difference.
I hope that some of you can help me. I would really love to use Eclipse with out project, but so far, I have run into a lot of troubles adapting it to our project.
Regards
Anders
Charles Hasegawa
Ranch Hand

Joined: May 22, 2003
Posts: 117
Did you add

to your ANT script (we just add this at the top)? I believe you need to do this to include system environmental values. If you do this and still get the same [echo] value, then "CLASSPATH" isn't recognized as an environmental variable on your system.
[ July 08, 2003: Message edited by: Charles Hasegawa ]
[ July 08, 2003: Message edited by: Charles Hasegawa ]
Anders Olsen
Greenhorn

Joined: Apr 17, 2003
Posts: 13
Thank you, that worked.
I also had to set the CLASSPATH environment before starting Eclipse. I tried to use the properties that I could set through Eclipse, but that didn't seem to work.
Regards
Anders
David Hibbs
Ranch Hand

Joined: Dec 19, 2002
Posts: 374
Here's another handy trick I've picked up... you can check if the script is being run from inside Eclipse/WSAD and do things like match the compiler...

If you need to adjust your classpath when running in eclipse vs. running from the command line, you can do so!


"Write beautiful code; then profile that beautiful code and make little bits of it uglier but faster." --The JavaPerformanceTuning.com team, Newsletter 039.
 
Don't get me started about those stupid light bulbs.
 
subject: Ant integration in Eclipse
 
Similar Threads
Trouble understanding Ant('s classpath)
Running WebLogic sh script that sets environment variables from ANT
Coexistence between IDE builds and automated
ClassPath
invoking java task from ant