• 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
  • Devaka Cooray
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Jeanne Boyarsky
  • Tim Cooke
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
Bartenders:

Ant build fail, sometimes 'cause ant forgets property

 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

I am getting the following build error, sometimes.

BUILD FAILED
C:\eclipse\workspace\ContinuousTesting\build.xml:55: C:\eclipse\workspace\ContinuousTesting\${lib.dir} not found.



Here is the build.properties file:

src.dir=./src
build.dir=./bin
lib.dir=./lib



I've added some output to check that I am not drunk



This is the whole task


Which I hope proves that I am not completely drunk.

What is my build.classpath? here:


And the thing is... it works sometimes. Sometimes it doesn't.
I am running this through eclipse.

What am I missing?

 
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Exactly where is line 55 in your build.xml? Exactly how did Ant get there? I ask because I have experienced similar things via an 'antcall' (properties set in the build script are not being propagated to the antcall). Try running with the -v option, that might give you a clue as to exactly where the problem is.
 
author & internet detective
Posts: 41775
887
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Note this was cross posted to stack overflow. I think Peter's question is spot on.
 
Azriel Abramovich
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Of course this was cross-posted :-) I use all the best forums...

Line 55 is the javac call
<javac srcdir="${src.dir}" destdir="${build.dir}" listfiles="no" debug="true" classpathref="build.classpath" fork="true" memoryInitialSize="128m" memoryMaximumSize="512m" />

edit:
If I clean the project via eclipse - the compile works. Otherwise, if I delete a class file or even entire bin folder manually - it fails.
The compile task is called from several tasks. In all cases it works fine if I clean the project via eclipse first.


Thanks for helping
 
Peter Johnson
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you running the Ant build from within Eclipse? I ask because Eclipse adds a bunch of settings to the build.

It sounds to me like your Ant build script is not very well written - deleting a class file, or not running a 'clean' should not effect the build's success.

Did you try using -v like I suggested?
 
Azriel Abramovich
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, I am running from eclipse.
edit2: -v option: where shall I add it? I guess the answer is 'from command line' and I'll try it asap. see next message


Sorry, I can write Java and C++ code, I can do a handstand... but ant is a bit of a mis(t)ery still (I can rant for long periods about such tools).

edit:
To make life easier (now that I've realised that in the long time I was gone from this forum - upload is supported :-)) I've uploaded the properties and the build.xml file.
Comments are welcome on other things as well... as I am just starting to grind my teeth against the
cannot upload as any format I choose is ignored


Thanks,
A'z
 
Azriel Abramovich
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
First: Here is the contents of my build.xml file. See how many faults you find :-)



Right, I've ran Ant from command line with the -v option.
Here are some things which ant reports as it starts


So you can see it initially complains about the missing lib.dir, it does load the properties file.
Then I see it is adding all expected classes to the build list
i.e.


And as a prize I get the following ant exception (which I fail to learn anything new from):
 
Azriel Abramovich
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have resolved this by realising that I better not have the build.dir, lib.dir and src.dir properties as properties. This should sit within the build.xml file

Thanks for your time.
 
Peter Johnson
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Suggestion: Do not use back-slashes in paths in Ant - the back-slash is too often taken as an escape character.

The problem is that you load the properties file from within a target, but the classpath is initialized globally. Thus lines 19..26 are performed before lines 6..10. You should either do all initialization within targets (I prefer this for complicated build scripts) or load the properties file globally (not within a target). I usually always load the properties file globally.

However your decision to move the properties into the build script is the correct decision. All project-relative paths should be defined within the build script itself. Use the properties file for external directory locations and other settings that can change from machine to machine or user to user.

By the way, if you are new with Ant, grab Ant in Action - I have the first edition of that book and found it to be invaluable.
 
Azriel Abramovich
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Peter!

I guess I got what I deserve.
I took an Ant build file written by someone else, and just ripped some parts apart.

I'll learn now how to initialize the classpath as part of a task, and load the properties globally.

Thanks for the link !

A'z
 
this llama doesn't want your drama, he just wants this tiny ad for his mama
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic