Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to have Ant print out the classpath for a particular target? If so, how?

I'm trying to get a target to build that has quite a long list of <pathelement location="${xxx}"/> and <path refid="foo.class.path"/> elements in its <path id="bar.class.path"> element (in the build.xml file). I keep getting "package com.somecompany.somepackage does not exist" errors, and I'm having a hard time chasing down these packages and making sure I've synced them from our repository.

I'm new to this team so I'm unfamiliar with the build, but I would prefer to figure this out myself if possible (so I don't bother the other very busy team members). I have very limited experience with Ant.

I think it would save me quite a bit of time if I could have Ant print out the classpath for the target I'm trying to build.

like image 568
Daryl Spitzer Avatar asked Mar 12 '10 04:03

Daryl Spitzer


People also ask

What is classpath in ant?

Ant - Classpaththe location attribute refer to a single file or directory relative to the project's base directory (or an absolute filename) the path attribute accepts colon- or semicolon-separated lists of locations.

How do you list ant targets?

which you can then set as the default, so just typing ant will list the available targets. small suggestion. make "help" target as default. As a result running "ant" will invoke "help" target that will print all available targets.

What is target in Ant build?

An Ant target is a sequence of tasks to be executed to perform a part (or whole) of the build process. Ant targets are defined by the user of Ant. Thus, what tasks an Ant target contains depends on what the user of Ant is trying to do in the build script.

What is the default target in ant?

the default target to use when no target is supplied. No; however, since Ant 1.6. 0, every project includes an implicit target that contains any and all top-level tasks and/or types. This target will always be executed as part of the project's initialization, even when Ant is run with the -projecthelp option.


Video Answer


1 Answers

Use the pathconvert task to convert a path to a property

<path id="classpath"> .... </path>  <pathconvert property="classpathProp" refid="classpath"/>  <echo>Classpath is ${classpathProp}</echo> 

Docs for pathconvert.

like image 186
karoberts Avatar answered Sep 21 '22 01:09

karoberts