Ant Problem

D

David Roden

Hi.

I have a problem with ant (versions 1.5.4, 1.6.0, and 1.6.1). I use a
fileset to identify the files I want to compile, like this:

<fileset id="build.files" dir="${src.dir}">
<include name="com/**/"/>
<exclude name="com/company/application/clients/**/"/>
</fileset>

Later, I reference this fileset within the javac task.

<target name="compile" depends="init">
<javac destdir="${build.dir}" target="1.4" debug="true">
<classpath refid="project.class.path"/>
<src>
<fileset refid="build.files"/>
</src>
</javac>
</target>

Ant bails out with this error:

BUILD FAILED
file:/home/sites/Application/build.xml:181:
/home/sites/Application/server/source/com/company/application/io/IO.java
is not a directory.

Line 181 is the line where the javac task definition starts.

Am I missing something here? Of course ant is correct when stating that
"IO.java" is not a directory, because it really isn't. I just wonder why
ant thinks it should be a directory.

Can anyone hint me in the right direction? This has kept me busy for
several hours now, and I'm clearly out of ideas.

Thanks in advance,
David
 
G

GaryM

<target name="compile" depends="init">
<javac destdir="${build.dir}" target="1.4" debug="true">
<classpath refid="project.class.path"/>
<src>
<fileset refid="build.files"/>
</src>
</javac>
</target>

Regarding the <src> element. I think this element acts like a fileset
when nested like that. Thus I think you can refer to the fileset in the
same way as the classpath element.
 
D

David Roden

GaryM said:
Regarding the <src> element. I think this element acts like a fileset
when nested like that. Thus I think you can refer to the fileset in the
same way as the classpath element.

Hmm, not really:

file:/home/sites/BillingServer/build.xml:184: billingserver.build.files
doesn't denote a path

Changing the fileset to

<path id="build.files">
<fileset dir="${src.dir}">
<include name="com/**"/>
<exclude name="com/company/application/clients/**/"/>
</fileset>
</path>

and referencing it with

<javac ...>
...
<src refid="build.files"/>
</javac>

unfortunately fails with the same error message as before.

Does anyone have a working example for referencing the files that are to
be compiled?

Thanks,
David
 
G

GaryM

Does anyone have a working example for referencing the files that
are to be compiled?

Mmm, Sorry I did not test my theory. I tweaked one of my own build.xml
like yours and get the same error. This does work though not using
explicit filesets. Hope it gets you over the hump.

<javac srcdir="${java.src}"
destdir="${build}"
includes="**/*.java"
excludes="com/test/**"
debug="on">
<classpath refid="project.class.path"/>
</javac>
 
D

David Roden

GaryM said:
Mmm, Sorry I did not test my theory. I tweaked one of my own build.xml
like yours and get the same error. This does work though not using
explicit filesets. Hope it gets you over the hump.

<javac srcdir="${java.src}"
destdir="${build}"
includes="**/*.java"
excludes="com/test/**"
debug="on">
<classpath refid="project.class.path"/>
</javac>

Yes, I used the following to get around that error.

<target name="compile" depends="init">
<javac destdir="${build.dir}" target="1.4" debug="true">
<classpath refid="project.class.path"/>
<src path="${src.dir}"/>
<include name="com/**"/>
<exclude name="com/company/application/clients/**"/>
</javac>
</target>

Though I think that this solution is not very clean at least it is working.

Thanks for your help,
David
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,154
Members
46,702
Latest member
LukasConde

Latest Threads

Top