ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Larry V. Streepy, Jr." <stre...@healthlanguage.com>
Subject Re: include/exclude question
Date Thu, 14 Jun 2001 21:58:50 GMT
Here's how I handled a similar issue.  I wanted to be able to compile
selected subsets of the entire tree (I know, it's a transitional
thing, getting people weaned off "make" and onto "ant").  I use a
generic compile target, antcall, and a series of patternsets to do
the work. An example is below:

  <!-- ==================================================================== -->
  <!-- Pattern sets for files to compile, copy, and jar                     -->
  <!-- ==================================================================== -->

  <patternset id="le.paths.all"      includes="gnu/**,weblogic/**,com/cyberplus/**"/>
  <patternset id="le.paths.util"     includes="com/cyberplus/util/**,gnu/**"/>
  <patternset id="le.paths.server"   includes="com/cyberplus/le/server/**,weblogic/**"/>


  <!-- ==================================================================== -->
  <!-- Generic compilation target - uses javac.patternset to control        -->
  <!-- what gets compiled                                                   -->
  <!-- ==================================================================== -->
  <target name="generic-compile">
    <javac srcdir="${src.dir}"
           destdir="${build.lib}"
           debug="${debug}"
           deprecation="${deprecation}"
           optimize="${optimize}"
           failonerror="yes"
           depend="yes"
           includeAntRuntime="no" >
      <bootclasspath refid="rt.path" />
      <classpath refid="base.path" />
      <patternset refid="${javac.patternset}" />
    </javac>
    
  </target>
  
  <!-- ==================================================================== -->
  <!-- Compile everything at once                                           -->
  <!-- ==================================================================== -->
  <target name="compile"
          depends="prepare-build"
          description="Compile ALL classes at once" >

    <antcall target="generic-compile">
      <param name="javac.patternset" value="le.paths.all"/>
    </antcall>
    
  </target>
  
  <!-- ==================================================================== -->
  <!-- Compile the utility classes                                          -->
  <!-- ==================================================================== -->
  <target name="compile-util"
          depends="prepare-build"
          description="Compile the utility classes" >

    <antcall target="generic-compile">
      <param name="javac.patternset" value="le.paths.util"/>
    </antcall>
    
  </target>
  
  <!-- ==================================================================== -->
  <!-- Compile the server EJB (implementation) classes                      -->
  <!-- ==================================================================== -->
  <target name="compile-server"
          depends="prepare-build,compile-util"
          description="Compile the EJB implementation classes" >
    
    <antcall target="generic-compile">
      <param name="javac.patternset" value="le.paths.server"/>
    </antcall>
    
  </target>
  


Nolan Ring wrote:
> 
> I'm sure this has been covered elsewhere -- but I couldn't find it .
> 
> I want to compile the vast majority of the .java files under ${srcdir}
> -- there are a total of 500+ files in a directory hierarchy that
> 
> is 3 or 4 directories deep and includes roughly 20 subdirectories.
> 
> In at least one case, however, I want to compile only a single file in
> one of the subdirectories, despite the fact that the subdirectory
> 
> itself includes many files and directories.
> 
> The only way I've figured to do this so far is to to define a separate
> javac task that includes the individual file I want build; and then to
> 
> define another javac task that excludes the entire directory.  I'm
> sure there's a better way to do this!
> 
> Can someone help me out??
> 
> Thanks much.
> 
> Nolan
> 
> Snippet of build.xml file:
> 
> <target name="gprs" depends="voip" >
>    <javac srcdir="${SAsrc}/gprs/src/Java"
>           destdir="${SAoutput}/gprs/Java"
>           deprecation="off"
>           failonerror="false">
>           <include name="**/asn1/gsm32005v310/Gsm32005v310.java" />
>    </javac>
> 
>    <javac srcdir="${SAsrc}/gprs/src/Java"
>           destdir="${SAoutput}/gprs/Java"
>           deprecation="off"
>           failonerror="false">
>       <exclude name="**/*archive*/**/*"/>
>       <exclude name="**/*test*/*"/>
>       <exclude name="**/*Test*/*"/>
>       <exclude name="**/gsm3gpp_JNI/**"/>
>       <exclude name="**/oi/ggsn_asn1/**/*"/>
>       <exclude name="**/asn1/gsm32005v310/**/" />
>       <include name="**/*.java" />
>    </javac>
> </target>

-- 
Larry V. Streepy, Jr.
Chief Technical Officer and VP of Engineering

Health Language, Inc.  -- "We speak the language of healthcare"

970/626-5028 (office)           mailto:streepy@healthlanguage.com
970/626-4425 (fax)              http://www.healthlanguage.com

Mime
View raw message