| View previous topic :: View next topic |
| Author |
Message |
godot n00b

Joined: 01 Oct 2003 Posts: 4
|
Posted: Wed Oct 01, 2003 2:15 pm Post subject: [JAVA] Portage's ant doesn't behave normally wrt $ANT_LIB |
|
|
I've found that the version of ant 1.5.3 you can install from portage doesn't behave quite like the same version of ant that exists on other platforms (i.e., other Linux distros, OS X fink). Specifically, it doesn't automatically include jars from $ANT_LIB ($ANT_HOME/lib) into the classpath used to invoke ant.
[I'm posting this primarily to provide a reference in case someone else runs into this problem. (I wasn't able to find a mention of it in the forum archives or in the gentoo docs.) I don't yet have enough experience with gentoo's unique java subsystem to say whether this should be considered a bug. I would appreciate comments one way or the other.]
The cause of this behavior seems to be this line in /usr/bin/ant:
| Code: | | LOCALCLASSPATH="${LOCALCLASSPATH}:`java-config --classpath=ant`" |
This gentoo-specific code replaces the following block in a normal ant install:
| Code: | for i in "${ANT_LIB}"/*.jar
do
# if the directory is empty, then it will return the input string
# this is stupid, so case for it
if [ -f "$i" ] ; then
if [ -z "$LOCALCLASSPATH" ] ; then
LOCALCLASSPATH="$i"
else
LOCALCLASSPATH="$i":"$LOCALCLASSPATH"
fi
fi
done
|
( From http://cvs.apache.org/viewcvs/ant/src/script/ant?rev=1.19.2.15&content-type=text/vnd.viewcvs-markup )
As you can see, the normal method adds all the jars in $ANT_LIB to $LOCALCLASSPATH. ($LOCALCLASSPATH is the classpath used to actually invoke the ant executable itself.) The gentoo method will do this, too, so long as you don't add any jars to $ANT_LIB beyond what is installed by ant itself :
| Code: | $ ls /usr/share/ant/lib/
ant.jar junit.jar optional.jar saxon.jar
$ java-config --classpath=ant
/usr/share/ant/lib/ant.jar:/usr/share/ant/lib/optional.jar
|
The reason why this may be a problem is that adding jars to $ANT_LIB is a widely used method to override or supplement ant's default behaviors. I use it to replace the default XSL engine used with the <style> task, for instance. It is also the normal way one integrates JUnit with ant (in fact, I think that portage's junit ebuild puts a symlink to junit.jar in $ANT_LIB).
Workaround:
If the packages you want to load with ant were emerged from portage, you can do something like this before you run ant:
| Code: | | $ java-config --set-user-classpath=saxon |
This will replace your per-user classpath with the jars for the named packages. This appears to be a permanent change, so be careful. You could probably add something to your ~/.antrc (that section of the ant script is intact), but I haven't tried this. |
|
| Back to top |
|
 |
rberber n00b


Joined: 21 Apr 2003 Posts: 5 Location: México
|
Posted: Wed Jan 14, 2004 6:20 pm Post subject: Same probelm with ant 1.5.4-r1 and 1.6.0 |
|
|
The 1.6.0 is masked at this time, but trying it I see that it installs 30 jars (not just the 3 the release version installs) but there remain a big problem:
If you run "ant -diagnostics" you see all the installed tasks are "not available":
------- Ant diagnostics report -------
Apache Ant version 1.6.0 compiled on January 13 2004
-------------------------------------------
Implementation Version (JDK1.2+ only)
-------------------------------------------
core tasks : null
optional tasks : 1.6.0
-------------------------------------------
ANT_HOME/lib jar listing
-------------------------------------------
ant.home: /usr/share/ant
ant.jar (944182 bytes)
junit.jar (186930 bytes)
ant-antlr.jar (353 bytes)
ant-apache-bsf.jar (353 bytes)
ant-apache-resolver.jar (353 bytes)
...
-------------------------------------------
Tasks availability
-------------------------------------------
p4reopen : Not Available
image : Not Available
sshexec : Not Available
wlrun : Not Available
p4label : Not Available
p4revert : Not Available
icontract : Not Available
p4submit : Not Available
scp : Not Available
p4change : Not Available
p4delete : Not Available
p4integrate : Not Available
vajload : Not Available
rexec : Not Available
stlist : Not Available
telnet : Not Available
p4sync : Not Available
p4edit : Not Available
maudit : Not Available
antlr : Not Available
netrexxc : Not Available
ftp : Not Available
p4resolve : Not Available
starteam : Not Available
stylebook : Not Available
stlabel : Not Available
p4have : Not Available
jdepend : Not Available
script : Not Available
stcheckin : Not Available
vajexport : Not Available
stcheckout : Not Available
p4labelsync : Not Available
ejbc : Not Available
vajimport : Not Available
p4fstat : Not Available
wlstop : Not Available
p4counter : Not Available
scriptdef : Not Available
p4add : Not Available
ddcreator : Not Available
...
The script /usr/bin/ant sets ANT_HOME and LOCALCLASSPATH correctly, the later includes all the jars.
I'm using Sun's java 1.4.2_03. _________________ René Berber |
|
| Back to top |
|
 |
striderg2 n00b

Joined: 25 Aug 2002 Posts: 12 Location: Caracas, Venezuela
|
Posted: Tue Jan 20, 2004 4:27 am Post subject: New ant version |
|
|
I recently commited to portage a new ant version ant-1.6.0-r2 its available on ~x86 and amd64, i think it should solve a lot of problems of previous ant versions (Check the use flags this package and ant-optional package has.)
Hope it will help. |
|
| Back to top |
|
 |
rberber n00b


Joined: 21 Apr 2003 Posts: 5 Location: México
|
Posted: Tue Jan 20, 2004 7:44 pm Post subject: Re: New ant version |
|
|
| striderg2 wrote: | I recently commited to portage a new ant version ant-1.6.0-r2 its available on ~x86 and amd64, i think it should solve a lot of problems of previous ant versions (Check the use flags this package and ant-optional package has.)
Hope it will help. |
Thanks, but I see no change except that now I have to install ant-optional to have some tasks besides junit (installed separately).
Dumb question : how do I check the use flags of any given package? I only set use flags on a global basis, in /etc/make.conf and there's nothing there about java.
Since the class path includes all the jars perhaps the problem is with the java version I have 1.4.2 (which was installed without using emerge but I used java-config and changed the files on /etc/env.d to set the correct path to the binary ... and every java application works, Eclipse, PoseidonUML, whatever). _________________ René Berber |
|
| Back to top |
|
 |
olivierva n00b


Joined: 12 Feb 2003 Posts: 58 Location: London (UK)
|
Posted: Wed Feb 04, 2004 2:25 pm Post subject: |
|
|
I'm having the same problem,
emerged ant-optional, everything is installed in /usr/share/ant/lib, but the task (ftp in my case) is not available.
I tought it should be picked up automaticly if it was in this directory? Or should it be defined somewhere specificly?
Olivier |
|
| Back to top |
|
 |
gino_rotormind Tux's lil' helper

Joined: 10 Apr 2003 Posts: 79
|
Posted: Sun Nov 13, 2005 1:37 pm Post subject: Ant LOCALCLASSPATH Problems |
|
|
I have had issues with ant 1.6.2 and ant 1.6.5. It is in regards to the LOCALCLASSPATH included in /usr/bin/ant. The issues arise as a result of trying to use checkstyle. Checkstyle seems to be very picky about what jars are in the classpath. The only solution that enables me to use checkstyle as an ant task is to comment out the following from /usr/bin/ant:
# add in the dependency .jar files
#LOCALCLASSPATH="${LOCALCLASSPATH}:`java-config --classpath=log4j,xerces-2,xalan,junit,antlr,bcel,bsh,commons-beanutils-1.6,commons-collections,commons-logging,commons-net,jakarta-oro-2.0,jdepend,jsch,jakarta-regexp-1.3,rhino-1.5,jython,jta,sun-jaf-bin,sun-javamail-bin 2> /dev/null`"
Becuase I don't have these additional jars in my environment CLASSPATH it works fine from the command line.
I also run FreeBSD and the /usr/bin/ant script does not contain this line. Once commented out I find that checkstyle works fine (no incompatible jar files). I have not experienced any issues after briefly using ant with this change. So I am curious of a) what are the consequences of not including these jars in the LOCALCLASSPATH and b) if there are none why is it included? Is it a consequence of the gentoo approach to java (java-config)? Oh, for those interested the errors with checkstyle were:
[checkstyle] log4j:WARN No appenders could be found for logger (org.apache.commons.beanutils.BeanUtils).
[checkstyle] log4j:WARN Please initialize the log4j system properly.
[checkstyle] Can't find/access AST Node typecom.puppycrawl.tools.checkstyle.api.DetailAST
.
.
.
.
.
Either way, I am curious as to what somebody with greater experience with gentoo, java, ant and checkstyle has to say about the above issue. Thanks in advance. |
|
| Back to top |
|
 |
mslinn Apprentice


Joined: 24 Sep 2004 Posts: 206 Location: Half Moon Bay, CA
|
Posted: Sat Apr 29, 2006 12:39 am Post subject: |
|
|
The ant-tasks package appears to replace the ant-optional package. You also need to make an entry in /etc/portage/package.use to disable any tasks you do not want. If you don't, here is what you see:
| Code: | sudo emerge -av ant-tasks
These are the packages that would be merged, in order:
Calculating [/list]dependencies... done!
[ebuild R ] dev-java/ant-tasks-1.6.2-r9 USE="-javamail -noantlr -nobcel -nobeanutils -nobsh -nocommonslogging -nocommonsnet -nojdepend -nojsch -nojython -nolog4j -nooro -noregexp -norhino -noxalan -noxerces" 0 kB |
Only javamail is not enabled by default. |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|