Ignore:
Timestamp:
Mar 16, 2009, 8:09:47 AM (15 years ago)
Author:
gav
Message:

Migrate /branches/TaskRewrite to grails-1.1

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/TaskRewrite/src/build.xml

    r53 r74  
    1 <project name="gnumims" default="test">
     1<project xmlns:ivy="antlib:org.apache.ivy.ant" name="gnumims" default="test">
     2    <property environment="env"/>
     3        <property name="ivy.install.version" value="2.0.0" />
     4    <condition property="ivy.home" value="${env.IVY_HOME}">
     5      <isset property="env.IVY_HOME" />
     6    </condition>
     7    <property name="ivy.home" value="${user.home}/.ant" />
     8    <property name="ivy.jar.dir" value="${ivy.home}/lib" />
     9    <property name="ivy.jar.file" value="${ivy.jar.dir}/ivy-${ivy.install.version}.jar" />
    210
    3     <condition property="grails" value="grails.bat">
    4         <os family="windows"/>
    5     </condition>
    6     <property name="grails" value="grails" />
    7 
    8         <!-- =================================
    9           target: clean             
    10          ================================= -->
    11     <target name="clean" description="--> Cleans a Grails application">
    12                 <exec executable="${grails}" failonerror="true">
    13                         <arg value="clean"/>
    14                 </exec>                               
     11    <target name="download-ivy" unless="offline">
     12                <available file="${ivy.jar.file}" property="ivy.available"/>
     13                <antcall target="-download-ivy" />
    1514    </target>
    1615
    17         <!-- =================================
    18           target: war             
     16        <target name="-download-ivy" unless="ivy.available">
     17        <mkdir dir="${ivy.jar.dir}"/>
     18        <!-- download Ivy from web site so that it can be used even without any special installation -->
     19        <get src="http://www.apache.org/dist/ant/ivy/${ivy.install.version}/apache-ivy-${ivy.install.version}-bin.zip"
     20            dest="${ivy.home}/ivy.zip" usetimestamp="true" verbose="true"/>
     21            <unzip src="${ivy.home}/ivy.zip" dest="${ivy.jar.dir}">
     22                   <patternset>
     23                        <include name="**/*.jar"/>
     24                    </patternset>
     25                        <mapper type="flatten"/>
     26                </unzip>
     27        </target>
     28
     29    <target name="init-ivy" depends="download-ivy" unless="ivy.lib.path">
     30      <!-- try to load ivy here from ivy home, in case the user has not already dropped
     31              it into ant's lib dir (note that the latter copy will always take precedence).
     32              We will not fail as long as local lib dir exists (it may be empty) and
     33              ivy is in at least one of ant's lib dir or the local lib dir. -->
     34        <path id="ivy.lib.path">
     35            <fileset dir="${ivy.jar.dir}" includes="*.jar"/>
     36        </path>
     37        <taskdef resource="org/apache/ivy/ant/antlib.xml"
     38                 uri="antlib:org.apache.ivy.ant" classpathref="ivy.lib.path"/>
     39    </target>
     40
     41
     42    <property name="lib.dir" value="${basedir}/lib"/>
     43
     44    <macrodef name="grails">
     45        <attribute name="script"/>
     46        <attribute name="args" default="" />
     47        <sequential>
     48            <grailsTask script="@{script}" args="@{args}" classpathref="grails.classpath">
     49                <compileClasspath refid="compile.classpath"/>
     50                <testClasspath refid="test.classpath"/>
     51                <runtimeClasspath refid="app.classpath"/>
     52            </grailsTask>
     53        </sequential>
     54    </macrodef>
     55
     56    <!-- =================================
     57          target: resolve
    1958         ================================= -->
    20     <target name="war" description="--> Creates a WAR of a Grails application">
    21                 <exec executable="${grails}" failonerror="true">
    22                         <arg value="war"/>
    23                 </exec>                               
     59    <target name="-resolve" description="--> Retrieve dependencies with ivy" depends="init-ivy">
     60        <ivy:retrieve pattern="${lib.dir}/[conf]/[artifact]-[revision].[ext]"/>
    2461    </target>
    25        
    26         <!-- =================================
    27           target: test             
     62
     63    <target name="-init-grails" depends="-resolve">
     64        <path id="grails.classpath">
     65            <fileset dir="${lib.dir}/build"/>
     66        </path>
     67
     68        <path id="compile.classpath">
     69            <fileset dir="${lib.dir}/compile"/>
     70        </path>
     71
     72        <path id="test.classpath">
     73            <fileset dir="${lib.dir}/test"/>
     74        </path>
     75
     76        <path id="app.classpath">
     77            <fileset dir="${lib.dir}/runtime"/>
     78        </path>
     79
     80        <taskdef name="grailsTask"
     81                 classname="grails.ant.GrailsTask"
     82                 classpathref="grails.classpath"/>
     83    </target>
     84
     85    <target name="deps-report" depends="-resolve" description="--> Generate report of module dependencies.">
     86        <ivy:report conf="*"/>
     87    </target>
     88
     89    <!-- =================================
     90          target: clean
    2891         ================================= -->
    29     <target name="test" description="--> Run a Grails applications unit tests">
    30                 <exec executable="${grails}" failonerror="true">
    31                         <arg value="test-app"/>
    32                 </exec>                               
     92    <target name="clean" depends="-init-grails" description="--> Cleans a Grails application">
     93        <grails script="Clean"/>
     94        <delete dir="${lib.dir}" includes="**/*"/>
    3395    </target>
    34        
    35         <!-- =================================
    36           target: deploy             
     96
     97    <!-- =================================
     98          target: compile
     99         ================================= -->
     100    <target name="compile" depends="-init-grails" description="--> Compiles a Grails application">
     101        <grails script="Compile"/>
     102    </target>
     103
     104    <!-- =================================
     105          target: war
     106         ================================= -->
     107    <target name="war" depends="-init-grails" description="--> Creates a WAR of a Grails application">
     108        <grails script="War"/>
     109    </target>
     110
     111    <!-- =================================
     112          target: test
     113         ================================= -->
     114    <target name="test" depends="-init-grails" description="--> Run a Grails applications unit tests">
     115        <grails script="TestApp"/>
     116    </target>
     117
     118    <!-- =================================
     119          target: run
     120         ================================= -->
     121    <target name="run" depends="-init-grails" description="--> Runs a Grails application using embedded Jetty">
     122        <grails script="RunApp"/>
     123    </target>
     124
     125    <!-- =================================
     126          target: deploy
    37127         ================================= -->
    38128    <target name="deploy" depends="war" description="--> The deploy target (initially empty)">
Note: See TracChangeset for help on using the changeset viewer.