• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

An Ant Rant

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's Friday afternoon, and I have spent most of the week trying to adapt my perfectly good WSAD 5.1.0(Eclipse) project to Ant (1.6.2). I have most of the online Ant Manual and Pragmatic Project Automation and Java Extreme Programming Cookbook.
1. I couldn't get it to use the modern compiler.
It does, for now.
2. I couldn't get it to find JUnit.
It does, for now.
3. I set up the JUnit test modules in a seperate folder, and now it can't find the class its testing.
4. What works in WSAD doesn't seem to work in Windows command line.
5. I count something like four or five different CLASSPATHs, depending on where you are at the moment. Couldn't anyone come up with any other keywords? And of course, they interfere with each other. And the documentation tends to be fairly cryptic.

I understand that Ant is essentially a volunteer effort, and having used MS make, I am thrilled that Ant is as good as it is. But it was obviously written by Unix/C gurus.
(After 10 years working in Unix and C, off and on, I stand by my original impression that Unix is user-hostile [the opposite of user-friendly.])
And guys, whatever you did to junit needs to fixed.

It may be that any non-trivial tool will have these problems, but someone needs to devote some effort to making it a little less fragile.

Thanks for the chance to vent. I'm going home to finish my taxes.

Dana
[ April 08, 2005: Message edited by: DK Taylor ]
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by DK Taylor:
2. I couldn't get it to find JUnit.



Isn't that as simple as putting junit.jar into the lib folder?


3. I set up the JUnit test modules in a seperate folder, and now it can't find the class its testing.



What does your classpath for the junit task look like?


4. What works in WSAD doesn't seem to work in Windows command line.



Perhaps because of different working directories?


5. I count something like four or five different CLASSPATHs, depending on where you are at the moment. Couldn't anyone come up with any other keywords?



I don't understand that at all. Anyway, you can define classpaths and give them an id, later reference them using refid, if that helps.

And of course, they interfere with each other. And the documentation tends to be fairly cryptic.



Don't understand what you are talking about.


I understand that Ant is essentially a volunteer effort, and having used MS make, I am thrilled that Ant is as good as it is. But it was obviously written by Unix/C gurus.



Not at all obvious to me. I'm not at all a Unix/C guru, but I found Ant to be rather straight forward. Make much more looks like a typical Unix/C tool to me...
 
DK Taylor
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
posted April 08, 2005 03:25 PM
2. I couldn't get it to find JUnit.
Isn't that as simple as putting junit.jar into the lib folder?
--------------------------------------------------------------------------------
No, it is as simple as moving the jar to it OWN folder. But it took a while to find that on the web (Ryan's Blog), and find the setting in WSAD.

quote:
--------------------------------------------------------------------------------

3. I set up the JUnit test modules in a seperate folder, and now it can't find the class its testing.

What does your classpath for the junit task look like?
<path id="project.classpath">
<pathelement path="${bld.prod.dir}" />
<pathelement path="${bld.test.dir}" />
<pathelement path="c:/Ant_JUnit" />
<fileset dir="${vendor.lib.dir}"> <include name="**/*.jar" />
</fileset>
<fileset dir="c:/iText"> <include name="**/*.jar" /> </fileset>
<fileset dir="c:/JUnit"> <include name="**/*.jar" /> </fileset>
</path>
<junit>
...
<classpath refid="project.classpath" />
...
</junit>

5. I count something like four or five different CLASSPATHs, depending on where you are at the moment. Couldn't anyone come up with any other keywords?

I don't understand that at all. Anyway, you can define classpaths and give them an id, later reference them using refid, if that helps.

--------------------------------------------------------------------------------

Which classpath? (In Windows/WSAD,) there is
1. the environment variable CLASSPATH,
2. the WASD Ant/Runtime/Classpath (Runtime & Additional),
3. the WSAD Java/Classpath Variables,
4. the build.xml propertyname classpath,
5. the path/pathelement,
6. the javac classpath, and
7. the junit classpath
(did I miss one?)
How do they interact? This is probably worth an article for newbies. As with so much in programming, its obvious once you understand it.

quote:
--------------------------------------------------------------------------------

4. What works in WSAD doesn't seem to work in Windows command line.

--------------------------------------------------------------------------------

Perhaps because of different working directories?

Isn't that defined by the "basedir" of the Ant project?
<project name="Problem ReportWeb" default="compile" basedir=".">

I'm sure all my problems are solvable, and as I said, it is much better than make. But if it were as clear as you imply, I wouldn't have spent such a frustrating week, and we wouldn't need multiple books about how to use it.

Thanks for listening.
Dana
[ April 11, 2005: Message edited by: DK Taylor ]
 
drifter
Posts: 1364
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Done ranting yet? Want help?

Why are you creating an ant build? To have a build that is independent of the way the IDE is set up? Then the classpaths in ant would be totally independent of what you are using in WSAD.

Ant 1.6.x seems to run best when it starts up with no set classpath. Define whatever classpaths you need in the build file. If you need to reuse or extend classpaths, try out the path/classpath ref ID as describe in Ant manual "using ant" sample build file:



What have you got so far? Are you stuck somewhere?
 
Saloon Keeper
Posts: 28402
210
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
From the Ant docs on JUnit:


This task runs tests from the JUnit testing framework. The latest version of the framework can be found at http://www.junit.org. This task has been tested with JUnit 3.0 up to JUnit 3.8.1; it won't work with versions prior to JUnit 3.0.

Note: This task depends on external libraries not included in the Ant distribution. See Library Dependencies for more information.

Note: You must have junit.jar and the class files for the <junit> task in the same classpath. You can do one of:

1. Put both junit.jar and the optional tasks jar file in ANT_HOME/lib.
2. Do not put either in ANT_HOME/lib, and instead include their locations in your CLASSPATH environment variable.
3. Do neither of the above, and instead, specify their locations using a <classpath> element in the build file. See the FAQ for details.

Tests are defined by nested test or batchtest tags (see nested elements).



IMHO, Ant's docs are generally above average. For one thing, they carry more example than most docs, if less sometimes than I'd like.

However, without meaning to be inflammatory, I would say that the minute you started to work directly with Ant, you moved into a higher league. You're moving from DDD (drag, drop, n' drool) design into an area where you're going to have to RTFM rather than get everything from autocomplete menus and popups. Ant is as rich and complex as a programming language, and - at least until someone designs some suitable IDE functionality - it'll probably be more trouble to code in than Java.

OTOH, remember the motto of JavaRanch's IDE forum (Real Programmers use Notepad (^H^H^H^H^H^ emacs ^H^H^H^H vi). You're moving into a more elite cognoscenti, rubbing elbows with the holders of Secret Knowledge and empowered to sneer at the ignorant masses and flame them in online forums.

Except, of course for Javaranch. We're supposed to be flame-free!

[changed code to quote tag, for more browser friendly formatting - Ilja]
[ April 11, 2005: Message edited by: Ilja Preuss ]
 
Ilja Preuss
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dana,

as far as I can tell, most of your problems are more related to the Ant integration of WSAD. I'd advice to *first* try to get your Ant script working from the command line, and *then* try to use it from WSAD.
 
DK Taylor
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Carol,
Thank you. I guess I'm done ranting, mainly because it doesn't get things done. It was mainly to remind the cognoscenti that a lot of this stuff is not clear until you grasp it.
========= Actual Solution ==================
OTOH, when I read your quote, I realized that the javac task wanted a seperate classpath, not the javac parameter.
(I was saying <javac ... classpath=xxx>, not <javac ...><classpath=xxx />
==============================================
And this is a good example of my complaint: there are several ways to say it, and only one works. Which means you need to understand everything before you can do anything. (Not really, but ...)
So thanks. Your answer fixed it.

======== Actual Problem ======================
Tim, OTOH, your quote hasn't helped so far. I created an /Ant_JUnit folder into which I MOVED ant-junit.jar and copied junit.jar (because it looked like it might want them in the same place) and put Ant_Junit on my project.classpath path. The junit task still complains that it can't find junit. (Could not create task or type of type: junit.)
=============================================
Incidentally, I don't take your DDD comment to heart, because it doesn't apply. I've been programming for over 30 years, in COBOL, RPG (II, III & IV), C, awk, Perl, C++ and now Java; on 360/370/30xx/3/32/34/38/PC with MSDOS/Unix/AIX/Windows using TSO/SPF/notepad/vi.

And BTW, I am self-taught in most/all of these. So I don't have a problem with digging into the manuals. And the Web is a Godsend!
I don't need it spoon-fed. But the more examples, and the more GENERALIZED they are, the better.

Thanks to both of you for your efforts. I can't find anyone else in my department using these tools, so I have to depend on the kindness of strangers.

Dana
 
Carol Enderlin
drifter
Posts: 1364
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK, I can deal with an actual problem.

Originally posted by DK Taylor:

======== Actual Problem ======================
...
I created an /Ant_JUnit folder into which I MOVED ant-junit.jar and copied junit.jar (because it looked like it might want them in the same place) and put Ant_Junit on my project.classpath path. The junit task still complains that it can't find junit. (Could not create task or type of type: junit.)
=============================================


In your previous post project.classpath looked like this:


You don't reference the jars here, try adding those:
<pathelement path="c:/Ant_JUnit" />

You do include jars here (not sure what is in this directory, presumably just junit.jar and not ant-junit.jar):
<fileset dir="c:/JUnit"> <include name="**/*.jar" /> </fileset>


(I've never done it quite like you are. We drop a copy of junit.jar into ant_home/lib so ant can find it and then include junit.jar in something like your project.classpath so the application and compiler can find it.)
 
DK Taylor
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

You don't reference the jars here, try adding those:
<pathelement path="c:/Ant_JUnit" />

You do include jars here (not sure what is in this directory, presumably just junit.jar and not ant-junit.jar):
<fileset dir="c:/JUnit"> <include name="**/*.jar" /> </fileset>


(I've never done it quite like you are. We drop a copy of junit.jar into ant_home/lib so ant can find it and then include junit.jar in something like your project.classpath so the application and compiler can find it.)
--------------------------------------------------------------------------------



The problem is that in the latest version of Ant, you can't have ant-junit.jar in ANT_HOME/lib.
Oh, but you have them both in both ant_home/lib AND the classpath.
.....
That works!
Thank you!
Dana
 
DK Taylor
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ilja,
Actually, I got it to work in WSAD first.
 
Today's lesson is that you can't wear a jetpack AND a cape. I should have read this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic