You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Barrie Treloar <Ba...@camtech.com.au> on 2000/07/26 09:44:16 UTC

Re: Example on web page

On Tue, 25 Jul 2000, David Walend wrote:

> <project name="foo" default="dist" basedir=".">
> 
>   <!-- set global properties for this build -->
>   <property name="src" value="." />
>   <property name="build" value="build" />
>   <property name="dist"  value="dist" />
> 
>   <target name="init">
>     <!-- Create the time stamp -->
>     <tstamp/>
>   </target>
> 
>   <target name="prepare" depends="init">
>     <!-- Create the build directory structure used by compile -->
>     <mkdir dir="${build}" />
>   </target>
> 
>   <target name="compile" depends="prepare">
>     <!-- Compile the java code from ${src} into ${build}
>        Use filtering to replace @version@ and @year@ marks in the code -->
>     <javac srcdir="${src}" destdir="${build}">
>       <include name="*.java"/>
>     </javac>
>   </target>
> 
>   <target name="dist" depends="compile">
>     <!-- Create the ${dist}/lib directory 
>        put everything in ${build} into the foo${DSTAMP}.jar file-->
>     <mkdir dir="${dist}/lib" />
>     <jar jarfile="${dist}/lib/foo${DSTAMP}.jar" 
>            basedir="${build}">
>       <include name="**" />
>     </jar>
>   </target>
> 
>   <target name="clean">
>     <!-- Delete the ${build} and ${dist} directory trees -->
>     <deltree dir="${build}" />
>     <deltree dir="${dist}" />
>   </target>
> </project>
> 
> -------------------

> I've left things grey. (I like grey.)

Some more comments:
        - grrr, I hate grey :)
        - Change name of project to MyProject or some such besides
          foo.
        - Remove init target and place tstamp into prepare.
        - Remove the comment in compile about use of filtering
        - Remove <include> in javac as this should be done
          automatically. 
        - Remove <include> in jar as this is should be done
          automatically.
        - Add a javadoc target?
          We do this by using the properties:

    <property name="src.dir" value="src" />

    <property name="build.dir" value="build" />
    <property name="build.dir.classes" value="${build.dir}/classes" />
    <property name="build.dir.javadoc" value="${build.dir}/javadoc" />

    <property name="classpath" value="your:classpath:goes:here" />
    <!-- You only need to specify the topmost package as javadoc task
    will create the correct package names for you -->
    <property name="packages" value="com.*" />    


    <target name="javadocs" depends="prepare">
      <mkdir dir="${build.dir.javadoc}" />
      <javadoc packagenames="${packages}"
               sourcepath="${src.dir}"
               destdir="${build.dir.javadoc}"
               classpath="${classpath}"
      </javadoc>
    </target>

Thanks for putting it together.

Barrie
--
Barrie Treloar
____________________________________________________________________

  Barrie Treloar                      Phone: +61 8 8303 3300
  Senior Analyst/Programmer           Fax:   +61 8 8303 4403 
  Electronic Commerce Division        Email: barrie@camtech.com.au
  Camtech (SA) Pty Ltd                http://www.camtech.com.au
 --- Level 8, 10 Pulteney Street, Adelaide SA 5000, Australia. ---
____________________________________________________________________



Re: Example on web page

Posted by Stefan Bodewig <bo...@bost.de>.
>>>>> "DW" == David Walend <dw...@eecs.tufts.edu> writes:

 DW> Can you verify that this is OK? In my setup (Using the July 18th
 DW> 1.1 ant release) if I don't have this <include name="*.java"/>,
 DW> the javac task copies the build.xml file into the build
 DW> directory.

And you get a deprecation warning, right?

Yes, the copying of support files has been dropped after the 1.1
release.

Stefan

[Patch] Re: Example in index.html

Posted by David Walend <dw...@eecs.tufts.edu>.
No one had more suggestions in the last 22 hours. So here's my first try
at a patch. Additional changes were moving the discussion of filter syntax
after the example (which has no filters), and adding myself to the contact
list at the top. Is that premature?

Please tell me what you think.

Thanks,

Dave



Re: Example on web page

Posted by David Walend <dw...@eecs.tufts.edu>.
Thanks again for the comments. Another revision:

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

  <!-- set global properties for this build -->
  <property name="src" value="." />
  <property name="build" value="build" />
  <property name="dist"  value="dist" />

  <target name="prepare">
    <!-- Create the time stamp -->
    <tstamp/>
    <!-- Create the build directory structure used by compile -->
    <mkdir dir="${build}" />
  </target>

  <target name="compile" depends="prepare">
    <!-- Compile the java code from ${src} into ${build} -->
    <javac srcdir="${src}" destdir="${build}" />
  </target>

  <target name="dist" depends="compile">
    <!-- Create the ${dist}/lib directory 
       put everything in ${build} into the MyProject-${DSTAMP}.jar file-->
    <mkdir dir="${dist}/lib" />
    <jar jarfile="${dist}/lib/MyProject-${DSTAMP}.jar" 
           basedir="${build}" />
  </target>

  <target name="clean">
    <!-- Delete the ${build} and ${dist} directory trees -->
    <deltree dir="${build}" />
    <deltree dir="${dist}" />
  </target>
</project>

------------------------------
Changes this time:

Hey Barrie... It's still grey! 

Changed the name of the project from "foo" to "MyProject." Is there a way
to get the project name as a property? 

Removed init target and put tstamp into prepare.

Removed the comment in the file about filtering

Removed the <include> tags (after downloading last night's build).

Decided not to add a javadoc target. I want to keep this really simple.
Barrie, perhaps one of us should update the javadoc example after this
one.

Decided to leave ${src} as "." I'm in the "build.xml is part of the source
code" school. And I want kids at home to be able to toss this file into a 
directory with some java source and get a .jar file.

Dave


Re: Example on web page

Posted by Barrie Treloar <Ba...@camtech.com.au>.
On Wed, 26 Jul 2000, David Walend wrote:

> On Wed, 26 Jul 2000, Barrie Treloar wrote:
> 
> >         - Remove <include> in javac as this should be done
> >           automatically. 
> 
> Barrie,
> 
> Can you verify that this is OK? In my setup (Using the July 18th 1.1 ant
> release) if I don't have this <include name="*.java"/>, the javac task
> copies the build.xml file into the build directory. 

As Stefan pointed out the 1.1 build still has the deprecated
functionality that copies support files from the src to the dest directory.

The problem occurs because you use:
        <property name="src" value="."/>

I would suggest that you use a directory hierarchy similar to jakarta
projects which put all source in the "src" directory.  So use

        <property name="src" value="src" />

This will mean that it won't copy any files unless they are in the src
directory and hopefully it will only contains .java files.

Add a comment to the javac target that warns of the deprecated
behaviour.

        <!-- The javac target has deprecated behaviour which copies 
        support files from the src to the dest directories.  Use
        copydir with include/exclude values instead of the deprecated
        behaviour -->

Barrie
--
Barrie Treloar
____________________________________________________________________

  Barrie Treloar                      Phone: +61 8 8303 3300
  Senior Analyst/Programmer           Fax:   +61 8 8303 4403 
  Electronic Commerce Division        Email: barrie@camtech.com.au
  Camtech (SA) Pty Ltd                http://www.camtech.com.au
 --- Level 8, 10 Pulteney Street, Adelaide SA 5000, Australia. ---
____________________________________________________________________



Re: Example on web page

Posted by David Walend <dw...@eecs.tufts.edu>.
On Wed, 26 Jul 2000, Barrie Treloar wrote:

>         - Remove <include> in javac as this should be done
>           automatically. 

Barrie,

Can you verify that this is OK? In my setup (Using the July 18th 1.1 ant
release) if I don't have this <include name="*.java"/>, the javac task
copies the build.xml file into the build directory. 

Thanks,

Dave