Ant not excluding on javac task

Discussion in 'Java' started by sowbug, Jan 21, 2004.

  1. sowbug

    sowbug Guest

    My script will exclude whole directories in the javac task, but it
    will not exclude individual files from being compiled. Can someone
    please have a look and tell me what I'm doing wrong?


    <?xml version="1.0" encoding="UTF-8"?>
    <project basedir="../../java/" default="all" name="BuildProject">

    <target name="init">
    <property name="hello" value="world"/>
    <property name="project_dir" value="/Project/"/>
    <property name="java_dir" value="/home/Jack/cvs/ascii/java/"/>
    </target>

    <target depends="init" name="clean" description="Clean all build
    products">
    <delete failonerror="false">
    <fileset dir="${project_dir}">
    <exclude name="j2sdk1.4.1"/>
    </fileset>
    </delete>
    </target>

    <target depends="init,clean" name="checkout">
    <!--<exec dir="/home/Jack" executable="./cvs_commit.sh"/>
    <exec dir="/home/Jack" executable="./checkout.sh"/>
    <exec dir="/home/Jack" executable="./cvs_edit.sh"/>-->
    </target>

    <target name="XmlValidate">
    <property name="xml_dir" value="../xml"/>
    <xmlvalidate failonerror="no" warn="no" >
    <fileset dir="${xml_dir}/docs" includes="**/*.xml"/>
    <fileset dir="${xml_dir}/programs" includes="**/*.xml" />
    <fileset dir="${xml_dir}/reports" includes="**/*.xml"/>
    </xmlvalidate>
    </target>

    <target depends="init,clean,checkout" name="compile">
    <javac nowarn="true" debug="true" verbose="false"
    deprecation="true" destdir="${project_dir}" srcdir="${java_dir}"
    failonerror="false" fork="yes" memoryMaximumSize="512m">
    <classpath><pathelement
    location="${java_dir}"/></classpath>
    <classpath><pathelement
    location="${project_dir}j2sdk1.4.1/lib/ext/AbsoluteLayout.jar"/></classpath>
    <include name="com/"/>
    </javac>
    <javac nowarn="true" debug="true" verbose="false"
    deprecation="true" destdir="${project_dir}" srcdir="${java_dir}"
    failonerror="false" fork="yes" memoryMaximumSize="512m">
    <classpath><pathelement
    location="${java_dir}"/></classpath>
    <classpath><pathelement
    location="${project_dir}j2sdk1.4.1/lib/ext/AbsoluteLayout.jar"/></classpath>
    <classpath><pathelement
    location="${project_dir}j2sdk1.4.1/lib/ext/junit-ext.jar"/></classpath>
    <classpath><pathelement
    location="${project_dir}j2sdk1.4.1/lib/ext/junit.jar"/></classpath>
    <classpath><pathelement
    location="${project_dir}j2sdk1.4.1/lib/ext/TimerBean.jar"/></classpath>
    <classpath><pathelement
    location="${project_dir}j2sdk1.4.1/lib/ext/DataVision.jar"/></classpath>
    <include name="ar/"/>
    <exclude name="ar/client/project/ext/"/>
    <exclude name="ar/client/dp/ext/"/>
    <exclude name="ar/client/dp/server/ServerUBP.java"/>
    <exclude name="ar/client/dp/server/ServerURL.java"/>
    <exclude name="ar/client/project/server/ServerUSH.java"/>
    <exclude name="ar/client/project/server/ServerUQY.java"/>
    <exclude
    name="ar/client/project/junit/generated/bp/BP7901Test.java"/>
    <exclude name="ar/client/project/server/ServerUUT.java"/>
    <exclude
    name="ar/client/project/server/ServerR7018.java"/>
    <exclude
    name="ar/client/project/server/ServerR7153.java"/>
    <exclude
    name="ar/client/project/server/ServerR7240.java"/>
    <exclude
    name="ar/client/project/server/ServerR7285.java"/>
    <exclude
    name="ar/client/dp/server/ServerSysDeviceProf.java"/>
    <exclude
    name="ar/client/dp/server/ServerSysUserProf.java"/>
    <exclude
    name="ar/client/project/server/ServerDataDictionary.java"/>
    <exclude
    name="ar/client/project/server/ServerDialogCheckSheet.java"/>
    </javac>
    </target>


    <target depends="init,clean,checkout,compile,XmlValidate"
    description="Build everything" name="all">
    <echo message="Application built. Hello ${hello}!"/>
    </target>

    </project>
     
    sowbug, Jan 21, 2004
    #1
    1. Advertising

  2. sowbug

    sowbug Guest

    I know the code got kind of jumbled, but if someone will just please
    have a look at this simple problem, I know it would be easily fixed
    and I will go away. Thanks.

    brian


    (sowbug) wrote in message news:<>...
    > My script will exclude whole directories in the javac task, but it
    > will not exclude individual files from being compiled. Can someone
    > please have a look and tell me what I'm doing wrong?
    >
    >
    > <?xml version="1.0" encoding="UTF-8"?>
    > <project basedir="../../java/" default="all" name="BuildProject">
    >
    > <target name="init">
    > <property name="hello" value="world"/>
    > <property name="project_dir" value="/Project/"/>
    > <property name="java_dir" value="/home/Jack/cvs/ascii/java/"/>
    > </target>
    >
    > <target depends="init" name="clean" description="Clean all build
    > products">
    > <delete failonerror="false">
    > <fileset dir="${project_dir}">
    > <exclude name="j2sdk1.4.1"/>
    > </fileset>
    > </delete>
    > </target>
    >
    > <target depends="init,clean" name="checkout">
    > <!--<exec dir="/home/Jack" executable="./cvs_commit.sh"/>
    > <exec dir="/home/Jack" executable="./checkout.sh"/>
    > <exec dir="/home/Jack" executable="./cvs_edit.sh"/>-->
    > </target>
    >
    > <target name="XmlValidate">
    > <property name="xml_dir" value="../xml"/>
    > <xmlvalidate failonerror="no" warn="no" >
    > <fileset dir="${xml_dir}/docs" includes="**/*.xml"/>
    > <fileset dir="${xml_dir}/programs" includes="**/*.xml" />
    > <fileset dir="${xml_dir}/reports" includes="**/*.xml"/>
    > </xmlvalidate>
    > </target>
    >
    > <target depends="init,clean,checkout" name="compile">
    > <javac nowarn="true" debug="true" verbose="false"
    > deprecation="true" destdir="${project_dir}" srcdir="${java_dir}"
    > failonerror="false" fork="yes" memoryMaximumSize="512m">
    > <classpath><pathelement
    > location="${java_dir}"/></classpath>
    > <classpath><pathelement
    > location="${project_dir}j2sdk1.4.1/lib/ext/AbsoluteLayout.jar"/></classpath>
    > <include name="com/"/>
    > </javac>
    > <javac nowarn="true" debug="true" verbose="false"
    > deprecation="true" destdir="${project_dir}" srcdir="${java_dir}"
    > failonerror="false" fork="yes" memoryMaximumSize="512m">
    > <classpath><pathelement
    > location="${java_dir}"/></classpath>
    > <classpath><pathelement
    > location="${project_dir}j2sdk1.4.1/lib/ext/AbsoluteLayout.jar"/></classpath>
    > <classpath><pathelement
    > location="${project_dir}j2sdk1.4.1/lib/ext/junit-ext.jar"/></classpath>
    > <classpath><pathelement
    > location="${project_dir}j2sdk1.4.1/lib/ext/junit.jar"/></classpath>
    > <classpath><pathelement
    > location="${project_dir}j2sdk1.4.1/lib/ext/TimerBean.jar"/></classpath>
    > <classpath><pathelement
    > location="${project_dir}j2sdk1.4.1/lib/ext/DataVision.jar"/></classpath>
    > <include name="ar/"/>
    > <exclude name="ar/client/project/ext/"/>
    > <exclude name="ar/client/dp/ext/"/>
    > <exclude name="ar/client/dp/server/ServerUBP.java"/>
    > <exclude name="ar/client/dp/server/ServerURL.java"/>
    > <exclude name="ar/client/project/server/ServerUSH.java"/>
    > <exclude name="ar/client/project/server/ServerUQY.java"/>
    > <exclude
    > name="ar/client/project/junit/generated/bp/BP7901Test.java"/>
    > <exclude name="ar/client/project/server/ServerUUT.java"/>
    > <exclude
    > name="ar/client/project/server/ServerR7018.java"/>
    > <exclude
    > name="ar/client/project/server/ServerR7153.java"/>
    > <exclude
    > name="ar/client/project/server/ServerR7240.java"/>
    > <exclude
    > name="ar/client/project/server/ServerR7285.java"/>
    > <exclude
    > name="ar/client/dp/server/ServerSysDeviceProf.java"/>
    > <exclude
    > name="ar/client/dp/server/ServerSysUserProf.java"/>
    > <exclude
    > name="ar/client/project/server/ServerDataDictionary.java"/>
    > <exclude
    > name="ar/client/project/server/ServerDialogCheckSheet.java"/>
    > </javac>
    > </target>
    >
    >
    > <target depends="init,clean,checkout,compile,XmlValidate"
    > description="Build everything" name="all">
    > <echo message="Application built. Hello ${hello}!"/>
    > </target>
    >
    > </project>
     
    sowbug, Jan 22, 2004
    #2
    1. Advertising

  3. sowbug

    Tony Morris Guest

    Use a <fileset>
    http://ant.apache.org/manual/CoreTypes/fileset.html

    --
    Tony Morris
    (BInfTech, Cert 3 I.T., SCJP[1.4], SCJD)
    Software Engineer
    IBM Australia - Tivoli Security Software
    (2003 VTR1000F)


    "sowbug" <> wrote in message
    news:...
    > I know the code got kind of jumbled, but if someone will just please
    > have a look at this simple problem, I know it would be easily fixed
    > and I will go away. Thanks.
    >
    > brian
    >
    >
    > (sowbug) wrote in message

    news:<>...
    > > My script will exclude whole directories in the javac task, but it
    > > will not exclude individual files from being compiled. Can someone
    > > please have a look and tell me what I'm doing wrong?
    > >
    > >
    > > <?xml version="1.0" encoding="UTF-8"?>
    > > <project basedir="../../java/" default="all" name="BuildProject">
    > >
    > > <target name="init">
    > > <property name="hello" value="world"/>
    > > <property name="project_dir" value="/Project/"/>
    > > <property name="java_dir" value="/home/Jack/cvs/ascii/java/"/>
    > > </target>
    > >
    > > <target depends="init" name="clean" description="Clean all build
    > > products">
    > > <delete failonerror="false">
    > > <fileset dir="${project_dir}">
    > > <exclude name="j2sdk1.4.1"/>
    > > </fileset>
    > > </delete>
    > > </target>
    > >
    > > <target depends="init,clean" name="checkout">
    > > <!--<exec dir="/home/Jack" executable="./cvs_commit.sh"/>
    > > <exec dir="/home/Jack" executable="./checkout.sh"/>
    > > <exec dir="/home/Jack" executable="./cvs_edit.sh"/>-->
    > > </target>
    > >
    > > <target name="XmlValidate">
    > > <property name="xml_dir" value="../xml"/>
    > > <xmlvalidate failonerror="no" warn="no" >
    > > <fileset dir="${xml_dir}/docs" includes="**/*.xml"/>
    > > <fileset dir="${xml_dir}/programs" includes="**/*.xml" />
    > > <fileset dir="${xml_dir}/reports" includes="**/*.xml"/>
    > > </xmlvalidate>
    > > </target>
    > >
    > > <target depends="init,clean,checkout" name="compile">
    > > <javac nowarn="true" debug="true" verbose="false"
    > > deprecation="true" destdir="${project_dir}" srcdir="${java_dir}"
    > > failonerror="false" fork="yes" memoryMaximumSize="512m">
    > > <classpath><pathelement
    > > location="${java_dir}"/></classpath>
    > > <classpath><pathelement
    > >

    location="${project_dir}j2sdk1.4.1/lib/ext/AbsoluteLayout.jar"/></classpath>
    > > <include name="com/"/>
    > > </javac>
    > > <javac nowarn="true" debug="true" verbose="false"
    > > deprecation="true" destdir="${project_dir}" srcdir="${java_dir}"
    > > failonerror="false" fork="yes" memoryMaximumSize="512m">
    > > <classpath><pathelement
    > > location="${java_dir}"/></classpath>
    > > <classpath><pathelement
    > >

    location="${project_dir}j2sdk1.4.1/lib/ext/AbsoluteLayout.jar"/></classpath>
    > > <classpath><pathelement
    > > location="${project_dir}j2sdk1.4.1/lib/ext/junit-ext.jar"/></classpath>
    > > <classpath><pathelement
    > > location="${project_dir}j2sdk1.4.1/lib/ext/junit.jar"/></classpath>
    > > <classpath><pathelement
    > > location="${project_dir}j2sdk1.4.1/lib/ext/TimerBean.jar"/></classpath>
    > > <classpath><pathelement
    > > location="${project_dir}j2sdk1.4.1/lib/ext/DataVision.jar"/></classpath>
    > > <include name="ar/"/>
    > > <exclude name="ar/client/project/ext/"/>
    > > <exclude name="ar/client/dp/ext/"/>
    > > <exclude name="ar/client/dp/server/ServerUBP.java"/>
    > > <exclude name="ar/client/dp/server/ServerURL.java"/>
    > > <exclude name="ar/client/project/server/ServerUSH.java"/>
    > > <exclude name="ar/client/project/server/ServerUQY.java"/>
    > > <exclude
    > > name="ar/client/project/junit/generated/bp/BP7901Test.java"/>
    > > <exclude name="ar/client/project/server/ServerUUT.java"/>
    > > <exclude
    > > name="ar/client/project/server/ServerR7018.java"/>
    > > <exclude
    > > name="ar/client/project/server/ServerR7153.java"/>
    > > <exclude
    > > name="ar/client/project/server/ServerR7240.java"/>
    > > <exclude
    > > name="ar/client/project/server/ServerR7285.java"/>
    > > <exclude
    > > name="ar/client/dp/server/ServerSysDeviceProf.java"/>
    > > <exclude
    > > name="ar/client/dp/server/ServerSysUserProf.java"/>
    > > <exclude
    > > name="ar/client/project/server/ServerDataDictionary.java"/>
    > > <exclude
    > > name="ar/client/project/server/ServerDialogCheckSheet.java"/>
    > > </javac>
    > > </target>
    > >
    > >
    > > <target depends="init,clean,checkout,compile,XmlValidate"
    > > description="Build everything" name="all">
    > > <echo message="Application built. Hello ${hello}!"/>
    > > </target>
    > >
    > > </project>
     
    Tony Morris, Jan 22, 2004
    #3
  4. sowbug

    sowbug Guest

    Thanks for responding Tony, but the javac task doesn't support the
    nested <fileset> element. Not even with the new version(1.6).



    "Tony Morris" <> wrote in message news:<bupimt$a58$>...
    > Use a <fileset>
    > http://ant.apache.org/manual/CoreTypes/fileset.html
    >
    > --
    > Tony Morris
    > (BInfTech, Cert 3 I.T., SCJP[1.4], SCJD)
    > Software Engineer
    > IBM Australia - Tivoli Security Software
    > (2003 VTR1000F)
    >
    >
     
    sowbug, Jan 24, 2004
    #4
  5. sowbug

    Tony Morris Guest

    sorry, you're right.
    Reading up on the javac task reveals the following:

    excludes Comma- or space-separated list of files (may be specified
    using wildcard patterns) that must be excluded; no files (except default
    excludes) are excluded when omitted.


    which means you can't use <excludes> for excluding files.
    But the solution:

    excludesfile The name of a file that contains a list of files to
    exclude (may be specified using wildcard patterns).


    is quite trivial.

    --
    Tony Morris
    (BInfTech, Cert 3 I.T., SCJP[1.4], SCJD)
    Software Engineer
    IBM Australia - Tivoli Security Software
    (2003 VTR1000F)


    "sowbug" <> wrote in message
    news:...
    > Thanks for responding Tony, but the javac task doesn't support the
    > nested <fileset> element. Not even with the new version(1.6).
    >
    >
    >
    > "Tony Morris" <> wrote in message

    news:<bupimt$a58$>...
    > > Use a <fileset>
    > > http://ant.apache.org/manual/CoreTypes/fileset.html
    > >
    > > --
    > > Tony Morris
    > > (BInfTech, Cert 3 I.T., SCJP[1.4], SCJD)
    > > Software Engineer
    > > IBM Australia - Tivoli Security Software
    > > (2003 VTR1000F)
    > >
    > >
     
    Tony Morris, Jan 26, 2004
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. z3
    Replies:
    0
    Views:
    513
  2. Victor
    Replies:
    0
    Views:
    8,890
    Victor
    Sep 1, 2004
  3. Collin VanDyck
    Replies:
    2
    Views:
    669
    Collin VanDyck
    Nov 18, 2004
  4. krabhi
    Replies:
    1
    Views:
    9,416
    Marco Meschieri
    Aug 9, 2006
  5. Lax
    Replies:
    1
    Views:
    951
    Jean-Francois Briere
    Jan 18, 2007
Loading...

Share This Page