File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes IDEs, Version Control and other tools and the fly likes Eclipse Ant integration Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "Eclipse Ant integration" Watch "Eclipse Ant integration" New topic
Author

Eclipse Ant integration

Po-yu Chien
Ranch Hand

Joined: Nov 01, 2001
Posts: 45
I currently use both eclipse and netbeans, and found that they behave slightly different on how they integrate with Ant. For example, I tried to use eclipse to run build.xml of several open source projects, all fail at point of javac task. Such task runs well under netbeans. Can someone give me a hint on how to get Ant work right on eclipse? Otherwise I have to code in eclipse, and build and debug using netbeans......
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Originally posted by Po-yu Chien:
I currently use both eclipse and netbeans, and found that they behave slightly different on how they integrate with Ant. For example, I tried to use eclipse to run build.xml of several open source projects, all fail at point of javac task. Such task runs well under netbeans. Can someone give me a hint on how to get Ant work right on eclipse? Otherwise I have to code in eclipse, and build and debug using netbeans......

How does javac fail? Do you get some kind of message?


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Kyle Brown
author
Ranch Hand

Joined: Aug 10, 2001
Posts: 3892
    
    5
(From an internal IBM newsgroup)
There is a problem in WebSphere Studio Application Developer and Eclipse 1.0, when you compile java code via an ant build. The symptom is an error message stating "Cannot use Classic Compiler" The solution is to tell the ANT build the compiler that WSAD wants to use. This can be passed as a command line argument when invoking ant. Or you can add the tag below, which looks to see if we're inside of WSAD (eclipse) and sets the compiler property.
The error is:
BuildException: [path]\build.xml:27: Cannot use classic compiler, as it is not available A common solution is to set the environment variable JAVA_HOME to your jdk directory.
The tag to put in your ant build.(In the compile target.)
< available <br /> classname="org.eclipse.core.launcher.Main" <br /> property="build.compiler" <br /> value="org.eclipse.pde.internal.core.JDTCompilerAdapter" <br /> classpath="${java.class.path}"/>
Kyle
[ April 10, 2002: Message edited by: Kyle Brown ]

Kyle Brown, Author of Persistence in the Enterprise and Enterprise Java Programming with IBM Websphere, 2nd Edition
See my homepage at http://www.kyle-brown.com/ for other WebSphere information.
Thomas Smets
Ranch Hand

Joined: Dec 11, 2001
Posts: 111


<available <br /> classname="org.eclipse.core.launcher.Main" <br /> property="build.compiler" <br /> value="org.eclipse.pde.internal.core.JDTCompilerAdapter" <br /> classpath="${java.class.path}"/>

But the default ant version of WSAD 4.0.2 does not accept the [i]available
element.
Thomas,
[/I]
Can some one tell me why the WSAD (Websphere Application Studio) has a parameter missing in the console, you just nee to add :
[B]

[/B]
Like shown, here :


Regards,
[ September 27, 2002: Message edited by: Thomas SMETS ]


Thomas Smets
Just another developper
Dave P
Greenhorn

Joined: Jun 05, 2001
Posts: 8
1. You need to download ANT version 1.5 if you haven't already.
2. Change Eclipse to use 1.5 via windows->preferences->External Tools->Ant
3. AddJar pointing to ANT 1.5 ant.jar and optional.jar
4. Remove the eclipse 1.4 ant.jar and optional.jar.
5. Hard code the path to your jdk1.4.1 javac executable:
<javac debug="true" deprecation="false" destdir="classes" srcdir="source" fork="yes" executable="/j2sdk1.4.1/bin/javac">
You have to hardcode the path and not use environment variables. If you Look at Eclipse->Help->About Eclipse->Configuration Details, you'll note that Eclipse is ignoring your environment variable JAVA_HOME and using it's own. I'll see if I make it use the right one.
Good luck.
D
Dave P
Greenhorn

Joined: Jun 05, 2001
Posts: 8
Hmm... for some reason my reply lost my < javac.
< javac debug="true" deprecation="false" destdir="classes" srcdir="source" fork="yes" executable="/j2sdk1.4.1/bin/javac">
I'll add a couple of spaces in front of javac to see if that works to get this posted properly.
David Turkel
Greenhorn

Joined: Aug 01, 2002
Posts: 4
I found the simple solution for this issue is to ensure that the JAVA_HOME variable points to the JDK or JRE, and most importantly, ensure that the tools.jar is included in the Ant classpath (Windows->Preferences->External Tools->Ant->Classpath tab.
Then, everything worked fine in Ant 1.4.1 and Ant 1.5.1 with any JDK I used.
Thomas Smets
Ranch Hand

Joined: Dec 11, 2001
Posts: 111
I now keep on having the following error :

(I did the line wrapping myself)
This occurs, thought I put the in the argument list passed to ANT

Can someone point me some reference or give me some ideas to solve these ?
David Turkel's answer is fine but ... I can't see the external tool tab in my Windows --> Preferences .... Dialog !
Are you working with WSAD 4.0.2 David ?
Dave P's answer is also fine but doesn't work in WASD w/o the ANT upgrade. Unfortunately the upgrade is not a usable solution in our case (problem with the XSALAN library). The default Ant version doesn't accept neither the fork, nor the compiler option for the javac task.
Tx,
Thomas,
[ January 10, 2003: Message edited by: Thomas SMETS ]
Santiago Arriaga
Greenhorn

Joined: Jan 14, 2003
Posts: 4
I used to have the same problem and no external tool tab in my Windows --> Preferences dialog. I believe that the best option is migrate to a newer WSAD version but until that's an option I found the following hack worked, AT LEAST FOR ME.
I copied the JDK1.2.2 tools.jar file into the $WSAD_HOME/plugins/org.eclipse.ant.core/ directory. Sorry, the JDK1.4 didn't work. I did not test other SDKs.
Then I edited manually the plugin.xml file in this same directory, and added:
< library name="tools.jar" >
< export name="*"/ >
</ library >
That did the trick.
I also found that replacing the ant jar files manually in this directory for a newer version ( ant 1.5.1 ) also worked. This may help in WSAD versions where the GUI menu isn't available.
hope this helps
santiago
Andre Mermegas
Ranch Hand

Joined: Jun 20, 2001
Posts: 158
Is there an update to this, im running WSAD 5.01 and getting this error.
Arguments: -Dbuild.compiler=org.eclipse.pde.internal.core.JDTCompilerAdapter
Compiling 120 source files to C:\projects\wsad\Shopping Cart\build
Build exception: file:C:/projects/wsad/Shopping Cart/build.xml:68: Compiler Adapter 'org.eclipse.pde.internal.core.JDTCompilerAdapter' can't be found.
Build exception: file:C:/projects/wsad/Shopping Cart/build.xml:68: Compiler Adapter 'org.eclipse.pde.internal.core.JDTCompilerAdapter' can't be found.
file:C:/projects/wsad/Shopping Cart/build.xml:68: Compiler Adapter 'org.eclipse.pde.internal.core.JDTCompilerAdapter' can't be found.
at org.apache.tools.ant.taskdefs.compilers.CompilerAdapterFactory.resolveClassName(CompilerAdapterFactory.java:195)
at org.apache.tools.ant.taskdefs.compilers.CompilerAdapterFactory.getCompiler(CompilerAdapterFactory.java:164)
at org.apache.tools.ant.taskdefs.Javac.compile(Javac.java:835)
at org.apache.tools.ant.taskdefs.Javac.execute(Javac.java:682)
at org.apache.tools.ant.Task.perform(Task.java:341)
at org.apache.tools.ant.Target.execute(Target.java:309)
at org.apache.tools.ant.Target.performTasks(Target.java:336)
at org.apache.tools.ant.Project.executeTarget(Project.java:1339)
at org.apache.tools.ant.Project.executeTargets(Project.java:1255)
at org.eclipse.ant.internal.core.ant.InternalAntRunner.run(InternalAntRunner.java:262)
at java.lang.reflect.Method.invoke(Native Method)
at org.eclipse.ant.core.AntRunner.run(AntRunner.java:234)
at org.eclipse.ui.externaltools.internal.core.AntFileRunner.execute(AntFileRunner.java:56)
at org.eclipse.ui.externaltools.internal.core.DefaultRunnerContext.executeRunner(DefaultRunnerContext.java:428)
at org.eclipse.ui.externaltools.internal.core.DefaultRunnerContext.run(DefaultRunnerContext.java:479)
at org.eclipse.ui.externaltools.internal.ui.AntLaunchWizard$1.run(AntLaunchWizard.java:117)
at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:98)
--- Nested Exception ---
java.lang.ClassNotFoundException: org.eclipse.pde.internal.core.JDTCompilerAdapter
at org.eclipse.ant.internal.core.AntClassLoader.loadClass(AntClassLoader.java(Compiled Code))
at java.lang.Class.forName1(Native Method)
at java.lang.Class.forName(Class.java(Compiled Code))
at org.apache.tools.ant.taskdefs.compilers.CompilerAdapterFactory.resolveClassName(CompilerAdapterFactory.java:191)
at org.apache.tools.ant.taskdefs.compilers.CompilerAdapterFactory.getCompiler(CompilerAdapterFactory.java:164)
at org.apache.tools.ant.taskdefs.Javac.compile(Javac.java:835)
at org.apache.tools.ant.taskdefs.Javac.execute(Javac.java:682)
at org.apache.tools.ant.Task.perform(Task.java:341)
at org.apache.tools.ant.Target.execute(Target.java:309)
at org.apache.tools.ant.Target.performTasks(Target.java:336)
at org.apache.tools.ant.Project.executeTarget(Project.java:1339)
at org.apache.tools.ant.Project.executeTargets(Project.java:1255)
at org.eclipse.ant.internal.core.ant.InternalAntRunner.run(InternalAntRunner.java:262)
at java.lang.reflect.Method.invoke(Native Method)
at org.eclipse.ant.core.AntRunner.run(AntRunner.java:234)
at org.eclipse.ui.externaltools.internal.core.AntFileRunner.execute(AntFileRunner.java:56)
at org.eclipse.ui.externaltools.internal.core.DefaultRunnerContext.executeRunner(DefaultRunnerContext.java:428)
at org.eclipse.ui.externaltools.internal.core.DefaultRunnerContext.run(DefaultRunnerContext.java:479)
at org.eclipse.ui.externaltools.internal.ui.AntLaunchWizard$1.run(AntLaunchWizard.java:117)
at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:98)
Build exception: file:C:/projects/wsad/Shopping Cart/build.xml:68: Compiler Adapter 'org.eclipse.pde.internal.core.JDTCompilerAdapter' can't be found.


--=( Andre Mermegas )=--
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Eclipse Ant integration