ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nan Null <null....@gmail.com>
Subject Re: AW: Passing a list of files to javac
Date Thu, 11 Mar 2010 14:52:38 GMT
I tried to help out by experimenting with the "src" sub element.  In
the sub element, I tried various settings.

for example:

<src>
     <fileset refid="fileset id goes here" />
</src>

However, I encounter error saying things like srcdir needs to be set,
or .../MyJavaFile.java is not a directory.

So, either I am not doing it right, or it's a bug.  It's best to look
into the source of javac task and see what are the error messages for.
 Then see if you can specify the correct
 syntax.  Else, just modify the task source (it's open source right).
Then submit the bug and the patch.


On Thu, Mar 11, 2010 at 8:34 AM, Matt Benson <gudnabrsam@gmail.com> wrote:
> Have you tried wrapping a refid'd fileset in a <src> (path) element nested
> in <javac>?  That, according to the manual, should work (note that you can
> nest any filesystem-based resource collection into a path).  This presumes
> you're using Ant 1.7+...
>
> HTH,
> Matt
>
> On Mar 11, 2010, at 4:42 AM, Robert Menteer wrote:
>
>> That solves the minor problem of ; vs , but doesn't solve the real
>> problem. The real problem is in getting javac to recognize a
>> filelist/fileset/path. What I'm looking for is something to replace the
>> filelist that javac will accept.
>>
>> On Mar 11, 2010, at 2:23 AM, Jan.Materne@rzf.fin-nrw.de wrote:
>>
>>> -        <filelist dir="." files="@{sourceref}" />  <-- email is
about
>>> this
>>> +        <filelist dir="." refid="@{sourceref}" />  <-- email is
about
>>> this
>>>
>>> Jan
>>>
>>>> -----Ursprüngliche Nachricht-----
>>>> Von: Robert Menteer [mailto:reetnem@me.com]
>>>> Gesendet: Mittwoch, 10. März 2010 21:28
>>>> An: user@ant.apache.org
>>>> Betreff: Passing a list of files to javac
>>>>
>>>> How can I get the javac task to use an existing fileset? In my
>>>> build.xml I have created several filesets to be used in
>>>> multiple places throughout build file. Here is how they have
>>>> been defined:
>>>>
>>>>  <fileset dir = "${src}"
>>>>      id       = "java.source.all">
>>>>    <include name =  "**/*.java" />
>>>>  </fileset>
>>>>
>>>>  <fileset dir = "${src}"
>>>>      id       = "java.source.examples">
>>>>    <include name = "**/Examples/**/*.java" />
>>>>  </fileset>
>>>>
>>>>  <fileset dir = "${src}"
>>>>      id       = "java.source.tests">
>>>>    <include name = "**/Tests/*.java" />
>>>>  </fileset>
>>>>
>>>>  <fileset dir = "${src}"
>>>>      id       = "java.source.project">
>>>>    <include name = "**/*.java"             />
>>>>    <exclude name = "**/Examples/**/*.java" />
>>>>    <exclude name = "**/Tests/**/*.java"    />
>>>>  </fileset>
>>>>
>>>> I have also used macrodef to compile the java files so the
>>>> javac task does not need to be repeated multiple times. The
>>>> macro looks like this:
>>>>
>>>> <macrodef name="compile">
>>>>  <attribute name="sourceref"/>
>>>>  <sequential>
>>>>    <javac srcdir         = "${src}"
>>>>        destdir           = "${build}"
>>>>        classpathref      = "classpath"
>>>>        includeantruntime = "no"
>>>>        debug             = "${debug}">
>>>>      <filelist dir="." files="@{sourceref}" />  <-- email
>>>> is about this
>>>>    </javac>
>>>>  </sequential>
>>>> </macrodef>
>>>>
>>>> What I'm trying to do is compile only the classes that are
>>>> needed for specific targets not all the targets in the source
>>>> tree. And do so without having to specify the files every
>>>> time. Here are how the targets are defined:
>>>>
>>>> <target name = "compile-examples"
>>>>    depends  = "init">
>>>>  <compile sourceref = "${toString:java.source.examples}" />
>>>> </target>
>>>>
>>>> <target name = "compile-project"
>>>>    depends  = "init">
>>>>  <compile sourceref = "${toString:java.source.project}" />
>>>> </target>
>>>>
>>>> <target name = "compile-tests"
>>>>    depends  = "init">
>>>>  <compile sourceref = "${toString:java.source.tests}" />
>>>> </target>
>>>>
>>>> As you can see each target specifies the java files to be
>>>> compiled as a simi-colon separated list of absolute file
>>>> names. The only problem with this is that javac does not
>>>> support filelist. It also does not support fileset, path or
>>>> pathset. I've tried using <include name = "@{sourceref}" />
>>>> but it treats the list as a single file name. Another thing I
>>>> tried is sending the reference directly (not using toString)
>>>> and using <include ref = "@{sourceref}" /> but include does
>>>> not have a ref attribute.
>>>>
>>>> I've done a search of this list and noticed another person
>>>> with a similar problem. But while it was discussed no solution
>>>> was presented.
>>>>
>>>> SO THE QUESTION IS: How do you get the javac task to use a
>>>> reference to a fileset that was defined in another part of the
>>>> build file? I'm not interested in solutions that cause me to
>>>> have multiple javac tasks. Completely re-writting the macro is
>>>> acceptable. Changes to the targets are also acceptable
>>>> provided redundant code between targets is kept to a minimum.
>>>>
>>>> p.s. Another problem is that fileset wants a comma separated
>>>> list. I've only done a brief search for a way to convert
>>>> semi-colons to commas and haven't found a way to do that.
>>>>
>>>> p.p.s. Sorry for the yelling but some people are too quick to
>>>> post responses that don't address the subject.
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>>> For additional commands, e-mail: user-help@ant.apache.org
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>> For additional commands, e-mail: user-help@ant.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message