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 and Ant Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "Eclipse and Ant" Watch "Eclipse and Ant" New topic
Author

Eclipse and Ant

Karthik Veeramani
Ranch Hand

Joined: Dec 22, 2002
Posts: 132
I tried to run an ant script that compiles my project and runs junit cases, and create test reports. The script runs fine as long as I dont use ant's "junitreport" task. When I use it, I get this error -
"BUILD FAILED: java.lang.VerifyError: (class: org/apache/xerces/parsers/IntegratedParserConfiguration, method: configurePipeline signature: ()V) Incompatible type for getting or setting field"
I've copied the xalan.jar file into ant's lib folder. So the script runs fine if I dont use eclipse (just run ant in command line). I've also changed the ANT_HOME in eclipse to point to this folder. Still no luck. Please help.


Thanks<br />Karthik<br />SCJP 1.4, CCNA.<br /> <br />"Success is relative. More the success, more the relatives."
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
This is a symptom of a well-known incompatibility.
The trick is to copy the XML jar files from the eclipse distribution to the ant lib, so that both systems use the same versions.


Read about me at frankcarver.me ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
Karthik Veeramani
Ranch Hand

Joined: Dec 22, 2002
Posts: 132
This was a very urgent issue for me. I did as u said (replacing the files) and it works gr8 now. Thank you so much for ur help !!!
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Is there a quality document out there describing how to use an existing Ant script to its fullest from within Eclipse?


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
Is there something which isn't working for you?
My ant scripts get pretty complicated but they all seem to work with eclipse.
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Originally posted by Frank Carver:
Is there something which isn't working for you?

No, nothing specific. Lazy me was just wondering whether there would be an easy-read somewhere that I could use instead of the trial and error method
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
Well, I have a few "top tips".
  • Make sure ant and eclipse are using the same versions of jar files. If there is a conflict, eclipse is usually the picky one, so copy the jar file from the eclipse distribution
  • Make sure you set the "output folder" for eclipse compilations to be different to the directory where ant places its compiled class files. Both like to think they do incremental compilation, and can get confused if you do both.
    Right click your project in the package explorer and select "properties", then choose "Java build Path" and set the "Default Output Folder" to somewhere ant doesn't care about.
  • Set up ant tasks using

  • Run >> External Tools >> External Tools
    I've found it wise to set up a separate task for each group of targets I commonly use (clean,build), (deploy), etc.
  • Make sure you tell eclipse about any jars your build script needs from ant/lib. Be wary of just adding everything from that directory (see 1, above). Each time you add a jar, run your ant script again from eclipse to see if it has everything it needs.
    menu: Windows >> Preferences

  • Select Ant >> Runtime
    Click the "Add jars" button to add jars.
    Note that the "Add Folder" option is for directories of classes, so adding the ant/lib folder is unlikely to be any use, you need to add all the jars you use individually.
  • Remember that you can click the "man with red box" icon (?) to re-run the most recently reused external command, whch includes Ant scripts.

  • I hope some of the above has been helpful.
    [ July 02, 2003: Message edited by: Frank Carver ]
    Lasse Koskela
    author
    Sheriff

    Joined: Jan 23, 2002
    Posts: 11962
        
        5
    Originally posted by Frank Carver:
    I hope some of the above has been helpful.

    Very. Thanks (again).
    Ilja Preuss
    author
    Sheriff

    Joined: Jul 11, 2001
    Posts: 14112
    Originally posted by Frank Carver:
    Make sure you set the "output folder" for eclipse compilations to be different to the directory where ant places its compiled class files. Both like to think they do incremental compilation, and can get confused if you do both.

    Unless you want to use Ant to *complement* Eclipse (code generation, RMI compiling and similar things), of course...


    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
    Chad McGowan
    Ranch Hand

    Joined: May 10, 2001
    Posts: 265
    Originally posted by Frank Carver:
    This is a symptom of a well-known incompatibility.
    The trick is to copy the XML jar files from the eclipse distribution to the ant lib, so that both systems use the same versions.

    I just happened to run into this same problem today running an Ant script from wsad 5, which is also using Eclipse. I hadn't run into this problem before. Is this problem documented somewhere?
    Frank Carver
    Sheriff

    Joined: Jan 07, 1999
    Posts: 6920
    The problem has been mentioned on several archived mailing lists and bulletin boards. Now it's mentioned here too!
    Unfortunately it's one of those problems which is hard to search for unless you have an idea what the problem is in the first place. Try google for "eclipse incompatible xerces" or something like that.
    Phil Williams
    Greenhorn

    Joined: Mar 24, 2003
    Posts: 6
    I have been having the same problems with 2.1 and ANT 1.5.3. I have copied the xerces jar files that come with eclipse into the ANT lib. Set the preferences to use my ANT_HOME dir (which properly grabs all the jars in the ANT lib dir) but am still having the same problem.
    Any ideas?
    Thanks,
    Phil
    Ed Burnette
    Author
    Ranch Hand

    Joined: Jun 10, 2003
    Posts: 142
    Do you mean 2.1.0 or 2.1.1? The latter comes with a newer and less broken version of Ant.


    Ed Burnette, Author of Hello Android
    Blog: ZDNet's Dev Connection - Twitter: @eburnette
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Eclipse and Ant