You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Jason Rosenberg <ja...@squaretrade.com> on 2000/11/28 19:21:49 UTC

Difference between file and resource in property task

Hello,

I have been playing with ant all of 1 day, so far.  I am using 1.2,
running on NT 4.0.

I am wondering if there is any difference between the file attribute
and the resource attribute for the property task.  The documentation
seems to describe each one identically.

I had hoped that the resource version would behave as a properties
file does within a java app, that is, if a named .properties file exists
within the current CLASSPATH, it should be enough just to refer
to the properties file name (without any absolute path info).

I can't seem to get it to work this way, however.

That would make it easier for configuring global properties, since
there would be no need to supply a command-line to ant with the
-D flag, just to specify a default global props directory, etc.

Much better to just have the properties file in the CLASSPATH.

What am I missing here?

Jason

Re: Difference between file and resource in property task

Posted by Stefan Bodewig <bo...@apache.org>.
Jason Rosenberg <ja...@squaretrade.com> wrote:

> I am wondering if there is any difference between the file attribute
> and the resource attribute for the property task.  The documentation
> seems to describe each one identically.

file will load the properties from a file. Its value is a filename,
either absolute or relative to the project's basedir. resource will
try to load the properties from the CLASSPATH, you could specify
org/apache/tools/ant/taskdefs/defaults.properties to load that file
from the ant.jar archive for example.

Is this clearer?
 
> I had hoped that the resource version would behave as a properties
> file does within a java app, that is, if a named .properties file
> exists within the current CLASSPATH, it should be enough just to
> refer to the properties file name (without any absolute path info).

It is supposed to work exactly that way, don't using any qualifier
will only work for files you'd find in the "unnamed" package space of
your CLASSPATH though.
 
> I can't seem to get it to work this way, however.

Could you please send an example (build file snippet + ant -verbose)?

Stefan