Grokbase Groups Ant user May 2001
FAQ
Hi folks-

I'm at my wits end here. I'm trying to adapt Ant to work with our Apex
development environment. I've already had to hack the Ant code to get
compilations to work (they work beautifully now). I'm trying to get the
creation of jar files to work. I've included a *manually* constructed ant
XML file below that creates a jar file with the appropriate content. You
will notice that I have quite a number of filesets; each represents one of
the Apex import directories. My probably is that for any Apex view, this
list is arbitrary. In other words, my list of "dir" values that I need to
process are
"/nif/code/Framework_Templates/GUI.ss/fisher_java.wrk/Links/Imported_Views/*
/classes" (you can see I've created n fileset entries to match this
pattern). How the heck can I generate these n filesets automatically,
without some sort of XML generation preprocessor?

Thanks,
John





<project name="mytest" default="dist" basedir=".">

<patternset id="jarable"
includes="**/*.class,**/*.gif,**/*.xml,**/*.jlx,**/*.dtd"
excludes="**/Links,**/.Makefile.rtnl" />

<target name="main">
<delete
file="/nif/code/Framework_Templates/GUI.ss/fisher_java.wrk/classes/myapp.jar
" />
<jar
jarfile="/nif/code/Framework_Templates/GUI.ss/fisher_java.wrk/classes/myapp.
jar">
<fileset
dir="/nif/code/Framework_Templates/GUI.ss/fisher_java.wrk/Links/Imported_Vie
ws/Application/classes">
<patternset refid="jarable" />
</fileset>
<fileset
dir="/nif/code/Framework_Templates/GUI.ss/fisher_java.wrk/Links/Imported_Vie
ws/Configuration/classes">
<patternset refid="jarable" />
</fileset>
<fileset
dir="/nif/code/Framework_Templates/GUI.ss/fisher_java.wrk/Links/Imported_Vie
ws/GUI/classes">
<patternset refid="jarable" />
</fileset>
<fileset
dir="/nif/code/Framework_Templates/GUI.ss/fisher_java.wrk/Links/Imported_Vie
ws/GUI_Images/classes">
<patternset refid="jarable" />
</fileset>
<fileset
dir="/nif/code/Framework_Templates/GUI.ss/fisher_java.wrk/Links/Imported_Vie
ws/Hardware/classes">
<patternset refid="jarable" />
</fileset>
<fileset
dir="/nif/code/Framework_Templates/GUI.ss/fisher_java.wrk/Links/Imported_Vie
ws/ICCS_Types/classes">
<patternset refid="jarable" />
</fileset>
<fileset
dir="/nif/code/Framework_Templates/GUI.ss/fisher_java.wrk/Links/Imported_Vie
ws/Oracle/classes">
<patternset refid="jarable" />
</fileset>
<fileset
dir="/nif/code/Framework_Templates/GUI.ss/fisher_java.wrk/Links/Imported_Vie
ws/Reservation/classes">
<patternset refid="jarable" />
</fileset>
<fileset
dir="/nif/code/Framework_Templates/GUI.ss/fisher_java.wrk/Links/Imported_Vie
ws/Status_Monitor/classes">
<patternset refid="jarable" />
</fileset>
<fileset
dir="/nif/code/Framework_Templates/GUI.ss/fisher_java.wrk/Links/Imported_Vie
ws/System_Manager/classes">
<patternset refid="jarable" />
</fileset>
<fileset
dir="/nif/code/Framework_Templates/GUI.ss/fisher_java.wrk/Links/Imported_Vie
ws/Utilities/classes">
<patternset refid="jarable" />
</fileset>
</jar>

</target>
</project>

Search Discussions

  • Diane Holt at May 4, 2001 at 2:24 am

    --- John Fisher wrote:
    My probably is that for any Apex view, this
    list is arbitrary. In other words, my list of "dir" values that I need
    to process are
    "/nif/code/Framework_Templates/GUI.ss/fisher_java.wrk/Links/Imported_Views/*
    /classes" (you can see I've created n fileset entries to match this
    pattern). How the heck can I generate these n filesets automatically,
    without some sort of XML generation preprocessor?
    Unless you have some kind of inclusion and/or exclusion pattern for the
    subdirs to include/exclude, I can't think of any way to do it without
    explicitly listing the dirs you want/don't want. But you could at least
    shrink down the way you've currently got it:

    <property name="top.dir" value="/nif/code/Framework_Templates/GUI.ss"/>
    <property name="work.dir" value="${top.dir}/fisher_java.wrk"/>

    <property name="links.dir" value="${work.dir}/Links/Imported_View"/>

    <patternset id="jarable"
    includes="**/*.class,**/*.gif,**/*.xml,**/*.jlx,**/*.dtd"
    excludes="**/Links,**/.Makefile.rtnl"/>

    <target name="main">
    <delete file="${work.dir}/classes/myapp.jar"/>
    <jar jarfile="${work.dir}/classes/myapp.jar">
    <fileset dir="${work.dir}">
    <patternset refid="jarable" />
    <include name="${links.dir}/Application/classes"/>
    <include name="${links.dir}/Configuration/classes"/>
    <include name="${links.dir}/GUI/classes"/>
    <include name="${links.dir}/GUI_Images/classes"/>
    <include name="${links.dir}/Hardware/classes"/>
    <include name="${links.dir}/ICCS_Types/classes"/>
    <include name="${links.dir}/Oracle/classes"/>
    <include name="${links.dir}/Reservation/classes"/>
    <include name="${links.dir}/Status_Monitor/classes"/>
    <include name="${links.dir}/System_Manager/classes"/>
    <include name="${links.dir}/Utilities/classes"/>
    </fileset>
    </jar>
    </target>

    If you could say "${links.dir}/*/classes" (with an excludes, if you need
    to exclude stuff), all the better -- then all you'd need is:
    <fileset dir="${work.dir}">
    <patternset refid="jarable" />
    <include name="${links.dir}/*/classes"/>
    <exclude name="whatever_you_need_excluded"/>
    </fileset>

    Diane

    =====
    (holtdl@yahoo.com)



    __________________________________________________
    Do You Yahoo!?
    Yahoo! Auctions - buy the things you want at great prices
    http://auctions.yahoo.com/
  • Jeff Turner at May 4, 2001 at 11:01 am
    The inventor of the regexp <mapper> type deserves a medal for providing
    a solution to this problem.

    Let's assume we have this structure:

    src/dir1/classes/
    src/dir2/classes/
    src/dir3/classes/
    src/../classes/

    We want to jar the contents of all the classes together, but do not know
    until runtime the names or number of directories under src/.

    One almost-solution is to use the "flatten" attribute as follows:

    <copy todir="${allclasses}" flatten="true">
    <fileset dir="src">
    <include name="*/classes/**"/>
    </fileset>
    </copy>

    Ie, move the wildcard to the include, instead of the dir. This will get
    the files in the jar, but unfortunately will lose any structure below
    the classes/ directory. Eg if you have:
    src/dir1/classes/com/foo/A.class
    src/dir2/classes/com/bar/B.class

    In your jar, you'll just get "A.class" and "B.class" in the root.
    However, this flatten trick is useful for things that don't require
    directories, eg if we wanted to copy src/*/lib/*.jar

    The best solution is, as mentioned, to use the regexp <mapper> type,
    found in recent (1.3?) releases of Ant:

    <copy todir="dest/">
    <fileset dir="src"/>
    <mapper type="regexp" from=".*/classes/(.*)" to="\1"/>
    </copy>

    This will do what we want, and preserve the structure below classes/.

    To use the regexp mapper type, you need optional.jar and
    jakarta-regexp.jar in your $ANT_HOME/lib directory. The docs describe
    this adequately.

    I've put together a small demo of the above at
    http://kenny.socialchange.net.au/~jeff/ant/ant-wildcard.zip

    HTH,

    --Jeff

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupuser @
categoriesant
postedMay 4, '01 at 1:08a
activeMay 4, '01 at 11:01a
posts3
users3
websiteant.apache.org

People

Translate

site design / logo © 2018 Grokbase