You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Jim Clayson <ji...@netcomuk.co.uk> on 2001/12/29 11:37:12 UTC

use of 'includes' attribute in javac

Hi,

Ant version 1.4

I am trying to compile my test java files - one of which refers to .java 
files in a completely seperate package. The compilation fails saying, 
"package org.jboss.docs.cmp.cd.bean does not exist
    [javac] import org.jboss.docs.cmp.cd.bean.*; ..."

My hierarchy is as follows:
(link to /usr/local/dev in home dir)

~/dev/examples/org/jboss/docs/cmp/cd/bean/*.java
~/dev/examples/org/jboss/docs/cmp/cd/interfaces/*.java
~/dev/test/servlets/src/classes/TestServlet.java
~/dev/test/servlets/src/classes/EJBClientServlet.java  (This one 
contains the ejb import stmts)

My ant's compile target looks like this:

         <target name="compile" depends="prepare">
                <javac  srcdir="${src.home}"
                        destdir="/tmp/unwrap/boo"
                        classpath="${classpath}"
                        debug="on">
 
                </javac>
        </target>

The ${src.home} is /usr/local/dev/test/servlets/src/classes. This I know 
because when I rename EJBClientServlet.java to EJBClientServlet.Lava the 
compilation succeeds i.e. only with TestServlet.java.

How do I tell ant where to find the package I want to tap? I have tried 
using the includes attribute but then nothing is compiled at all.
Then I searched the archives and google groups and have so far come up 
empty-handed (so it might be something pretty simple but I can't seem to 
find it.)
I could probably include the package in the nested 'src' tag but then 
what is 'includes' for?

The explanation in the online manual says the following with regard to 
using 'includes' with javac:

'comma-separated list of patterns of files that must be included; all 
files are included when omitted.'

What does 'all files are included when omitted' mean? Does it mean all 
files all over the world are included? If it does, then if I use include 
'org.jboss.docs.cmp.cd.**' and get nothing compiled, by leaving it out I 
should have the package included by leaving it out!

I would really appreciate someone's help on this as I'm running around 
in circles.





--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: use of 'includes' attribute in javac

Posted by Peter Donald <pe...@apache.org>.
On Sun, 30 Dec 2001 21:23, jfc100 wrote:
> whoops! Hang on - sorry, are you sure about the nested includes under
> the src tag?

Ooops - knew I would botch the syntax. The src is actually a "path-like" 
structure so you would have to do something like 


<javac  srcdir="${src.home}"
       destdir="/tmp/unwrap/boo"
       classpath="${classpath}"
       debug="on">
 <src>
   <fileset dir="~/dev/examples">
     <include name="org/jboss/docs/cmp/cd/bean/*.java"/>
     <include name="org/jboss/docs/cmp/cd/interfaces/*.java"/>
   </fileset>
 </src>
</javac>

-- 
Cheers,

Pete

---------------------------------------
Be nice to your friends. If it weren't 
for them, you'd be a complete stranger.
---------------------------------------

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: use of 'includes' attribute in javac

Posted by jfc100 <jf...@btopenworld.com>.
jfc100 wrote:

> Peter Donald wrote:
>
>> Hi
>>
>> On Sat, 29 Dec 2001 21:37, Jim Clayson wrote:
>>
>>> My hierarchy is as follows:
>>> (link to /usr/local/dev in home dir)
>>>
>>> ~/dev/examples/org/jboss/docs/cmp/cd/bean/*.java
>>> ~/dev/examples/org/jboss/docs/cmp/cd/interfaces/*.java
>>> ~/dev/test/servlets/src/classes/TestServlet.java
>>> ~/dev/test/servlets/src/classes/EJBClientServlet.java  (This one
>>> contains the ejb import stmts)
>>>
>>> My ant's compile target looks like this:
>>>
>>>         <target name="compile" depends="prepare">
>>>                <javac  srcdir="${src.home}"
>>>                        destdir="/tmp/unwrap/boo"
>>>                        classpath="${classpath}"
>>>                        debug="on">
>>>
>>>                </javac>
>>>        </target>
>>>
>>
>> The key idea is that each <javac/> task is rooted in a particular 
>> directory (${src.home} in your case) and the includes will then act 
>> on this base directory. So you can not include files outside this 
>> directory. The solution is to add another root and add in the 
>> includes via something like
>>
>> <javac  srcdir="${src.home}"
>>        destdir="/tmp/unwrap/boo"
>>        classpath="${classpath}"
>>        debug="on">
>>  <src path="~/dev/examples">
>>    <include name="org/jboss/docs/cmp/cd/bean/*.java"/>
>>    <include name="org/jboss/docs/cmp/cd/interfaces/*.java"/>
>>  </src>
>> </javac>
>>
> Thanks - got it, now! ;-)
> Jim
>
>
>
> -- 
> To unsubscribe, e-mail:   
> <ma...@jakarta.apache.org>
> For additional commands, e-mail: 
> <ma...@jakarta.apache.org>
>
>
whoops! Hang on - sorry, are you sure about the nested includes under 
the src tag?

The manual says,

  <javac destdir="${build}"
         classpath="xyz.jar"
         debug="on">
    <src path="${src}"/>
    <src path="${src2}"/>
    <include name="mypackage/p1/**"/>
    <include name="mypackage/p2/**"/>
    <exclude name="mypackage/p1/testpackage/**"/>
  </javac>

which seems to indicate that an include can not be defined as 'src' 
element specific.

I tried it with nested include(as you suggested) and it came back 
saying, "The <path> data type doesn't support the nested "include" 
element". If the above extract from the manual is correct, how would I 
associate an include with a src directory?

This is confusing to me. I think it makes sense for each src tag to have 
its own includes excludes elements associated with it.

Cheers
Jim


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: use of 'includes' attribute in javac

Posted by jfc100 <jf...@btopenworld.com>.
Peter Donald wrote:

>Hi
>
>On Sat, 29 Dec 2001 21:37, Jim Clayson wrote:
>
>>My hierarchy is as follows:
>>(link to /usr/local/dev in home dir)
>>
>>~/dev/examples/org/jboss/docs/cmp/cd/bean/*.java
>>~/dev/examples/org/jboss/docs/cmp/cd/interfaces/*.java
>>~/dev/test/servlets/src/classes/TestServlet.java
>>~/dev/test/servlets/src/classes/EJBClientServlet.java  (This one
>>contains the ejb import stmts)
>>
>>My ant's compile target looks like this:
>>
>>         <target name="compile" depends="prepare">
>>                <javac  srcdir="${src.home}"
>>                        destdir="/tmp/unwrap/boo"
>>                        classpath="${classpath}"
>>                        debug="on">
>>
>>                </javac>
>>        </target>
>>
>
>The key idea is that each <javac/> task is rooted in a particular directory 
>(${src.home} in your case) and the includes will then act on this base 
>directory. So you can not include files outside this directory. The solution 
>is to add another root and add in the includes via something like
>
><javac  srcdir="${src.home}"
>        destdir="/tmp/unwrap/boo"
>        classpath="${classpath}"
>        debug="on">
>  <src path="~/dev/examples">
>    <include name="org/jboss/docs/cmp/cd/bean/*.java"/>
>    <include name="org/jboss/docs/cmp/cd/interfaces/*.java"/>
>  </src>
></javac>
>
Thanks - got it, now! ;-)
Jim



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: use of 'includes' attribute in javac

Posted by Peter Donald <pe...@apache.org>.
Hi

On Sat, 29 Dec 2001 21:37, Jim Clayson wrote:
> My hierarchy is as follows:
> (link to /usr/local/dev in home dir)
>
> ~/dev/examples/org/jboss/docs/cmp/cd/bean/*.java
> ~/dev/examples/org/jboss/docs/cmp/cd/interfaces/*.java
> ~/dev/test/servlets/src/classes/TestServlet.java
> ~/dev/test/servlets/src/classes/EJBClientServlet.java  (This one
> contains the ejb import stmts)
>
> My ant's compile target looks like this:
>
>          <target name="compile" depends="prepare">
>                 <javac  srcdir="${src.home}"
>                         destdir="/tmp/unwrap/boo"
>                         classpath="${classpath}"
>                         debug="on">
>
>                 </javac>
>         </target>

The key idea is that each <javac/> task is rooted in a particular directory 
(${src.home} in your case) and the includes will then act on this base 
directory. So you can not include files outside this directory. The solution 
is to add another root and add in the includes via something like

<javac  srcdir="${src.home}"
        destdir="/tmp/unwrap/boo"
        classpath="${classpath}"
        debug="on">
  <src path="~/dev/examples">
    <include name="org/jboss/docs/cmp/cd/bean/*.java"/>
    <include name="org/jboss/docs/cmp/cd/interfaces/*.java"/>
  </src>
</javac>

-- 
Cheers,

Pete

---------------------------------------------------
"If you don't know where you want to go, we'll make 
sure you get taken." 
Microsoft ad slogan, translated into Japanese.
---------------------------------------------------

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: use of 'includes' attribute in javac

Posted by Adam Murdoch <ad...@yahoo.com>.
Hi,

The 'includes' attribute is used to select files from under srcdir.  For
example, in your case,

<javac
  srcdir="~/dev/test/servlets/src/classes"
  includes="EJB*">

would pick up ~/dev/test/servlets/src/classes/EJBClientServlet.java.  Have a
read of the "Concepts and Types" section of the manual (under "Built-in
Tasks") for more info.

Looks like you simply need to add a second srcdir to the <javac> task:

<javac destdir="..." classpath="...">
    <src location="${src.home}"/>
    <src location="~/dev/examples"/>
</javac>


Adam

> -----Original Message-----
> From: Jim Clayson [mailto:jimc@netcomuk.co.uk]
> Sent: Saturday, 29 December 2001 8:37 PM
> To: ant-user@jakarta.apache.org
> Subject: use of 'includes' attribute in javac
>
>
> Hi,
>
> Ant version 1.4
>
> I am trying to compile my test java files - one of which refers to .java
> files in a completely seperate package. The compilation fails saying,
> "package org.jboss.docs.cmp.cd.bean does not exist
>     [javac] import org.jboss.docs.cmp.cd.bean.*; ..."
>
> My hierarchy is as follows:
> (link to /usr/local/dev in home dir)
>
> ~/dev/examples/org/jboss/docs/cmp/cd/bean/*.java
> ~/dev/examples/org/jboss/docs/cmp/cd/interfaces/*.java
> ~/dev/test/servlets/src/classes/TestServlet.java
> ~/dev/test/servlets/src/classes/EJBClientServlet.java  (This one
> contains the ejb import stmts)
>
> My ant's compile target looks like this:
>
>          <target name="compile" depends="prepare">
>                 <javac  srcdir="${src.home}"
>                         destdir="/tmp/unwrap/boo"
>                         classpath="${classpath}"
>                         debug="on">
>
>                 </javac>
>         </target>
>
> The ${src.home} is /usr/local/dev/test/servlets/src/classes. This I know
> because when I rename EJBClientServlet.java to EJBClientServlet.Lava the
> compilation succeeds i.e. only with TestServlet.java.
>
> How do I tell ant where to find the package I want to tap? I have tried
> using the includes attribute but then nothing is compiled at all.
> Then I searched the archives and google groups and have so far come up
> empty-handed (so it might be something pretty simple but I can't seem to
> find it.)
> I could probably include the package in the nested 'src' tag but then
> what is 'includes' for?
>
> The explanation in the online manual says the following with regard to
> using 'includes' with javac:
>
> 'comma-separated list of patterns of files that must be included; all
> files are included when omitted.'
>
> What does 'all files are included when omitted' mean? Does it mean all
> files all over the world are included? If it does, then if I use include
> 'org.jboss.docs.cmp.cd.**' and get nothing compiled, by leaving it out I
> should have the package included by leaving it out!
>
> I would really appreciate someone's help on this as I'm running around
> in circles.
>
>
>
>
>
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>