|
1 |
| -<project name="grain" default="test"> |
2 |
| - |
3 |
| - <condition property="grails" value="grails.bat"> |
4 |
| - <os family="windows"/> |
| 1 | +<project xmlns:ivy="antlib:org.apache.ivy.ant" name="grain" 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" /> |
5 | 6 | </condition>
|
6 |
| - <property name="grails" value="grails" /> |
| 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" /> |
| 10 | + |
| 11 | + <target name="download-ivy" unless="offline"> |
| 12 | + <available file="${ivy.jar.file}" property="ivy.available"/> |
| 13 | + <antcall target="-download-ivy" /> |
| 14 | + </target> |
| 15 | + |
| 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 | + <sequential> |
| 47 | + <grailsTask script="@{script}" classpathref="grails.classpath"> |
| 48 | + <compileClasspath refid="compile.classpath"/> |
| 49 | + <testClasspath refid="test.classpath"/> |
| 50 | + <runtimeClasspath refid="app.classpath"/> |
| 51 | + </grailsTask> |
| 52 | + </sequential> |
| 53 | + </macrodef> |
| 54 | + |
| 55 | + <!-- ================================= |
| 56 | + target: resolve |
| 57 | + ================================= --> |
| 58 | + <target name="-resolve" description="--> Retrieve dependencies with ivy" depends="init-ivy"> |
| 59 | + <ivy:retrieve pattern="${lib.dir}/[conf]/[artifact]-[revision].[ext]"/> |
| 60 | + </target> |
| 61 | + |
| 62 | + <target name="-init-grails" depends="-resolve"> |
| 63 | + <path id="grails.classpath"> |
| 64 | + <fileset dir="${lib.dir}/build"/> |
| 65 | + </path> |
| 66 | + |
| 67 | + <path id="compile.classpath"> |
| 68 | + <fileset dir="${lib.dir}/compile"/> |
| 69 | + </path> |
| 70 | + |
| 71 | + <path id="test.classpath"> |
| 72 | + <fileset dir="${lib.dir}/test"/> |
| 73 | + </path> |
7 | 74 |
|
8 |
| - <!-- ================================= |
9 |
| - target: clean |
| 75 | + <path id="app.classpath"> |
| 76 | + <fileset dir="${lib.dir}/runtime"/> |
| 77 | + </path> |
| 78 | + |
| 79 | + <taskdef name="grailsTask" |
| 80 | + classname="grails.ant.GrailsTask" |
| 81 | + classpathref="grails.classpath"/> |
| 82 | + </target> |
| 83 | + |
| 84 | + <target name="deps-report" depends="-resolve" description="--> Generate report of module dependencies."> |
| 85 | + <ivy:report conf="*"/> |
| 86 | + </target> |
| 87 | + |
| 88 | + <!-- ================================= |
| 89 | + target: clean |
10 | 90 | ================================= -->
|
11 |
| - <target name="clean" description="--> Cleans a Grails application"> |
12 |
| - <exec executable="${grails}" failonerror="true"> |
13 |
| - <arg value="clean"/> |
14 |
| - </exec> |
| 91 | + <target name="clean" depends="-init-grails" description="--> Cleans a Grails application"> |
| 92 | + <grails script="Clean"/> |
| 93 | + <delete dir="${lib.dir}" includes="**/*"/> |
15 | 94 | </target>
|
16 | 95 |
|
17 |
| - <!-- ================================= |
18 |
| - target: war |
| 96 | + <!-- ================================= |
| 97 | + target: compile |
19 | 98 | ================================= -->
|
20 |
| - <target name="war" description="--> Creates a WAR of a Grails application"> |
21 |
| - <exec executable="${grails}" failonerror="true"> |
22 |
| - <arg value="war"/> |
23 |
| - </exec> |
24 |
| - </target> |
25 |
| - |
26 |
| - <!-- ================================= |
27 |
| - target: test |
| 99 | + <target name="compile" depends="-init-grails" description="--> Compiles a Grails application"> |
| 100 | + <grails script="Compile"/> |
| 101 | + </target> |
| 102 | + |
| 103 | + <!-- ================================= |
| 104 | + target: war |
28 | 105 | ================================= -->
|
29 |
| - <target name="test" description="--> Run a Grails applications unit tests"> |
30 |
| - <exec executable="${grails}" failonerror="true"> |
31 |
| - <arg value="test-app"/> |
32 |
| - </exec> |
33 |
| - </target> |
34 |
| - |
35 |
| - <!-- ================================= |
36 |
| - target: deploy |
| 106 | + <target name="war" depends="-init-grails" description="--> Creates a WAR of a Grails application"> |
| 107 | + <grails script="War"/> |
| 108 | + </target> |
| 109 | + |
| 110 | + <!-- ================================= |
| 111 | + target: test |
| 112 | + ================================= --> |
| 113 | + <target name="test" depends="-init-grails" description="--> Run a Grails applications unit tests"> |
| 114 | + <grails script="TestApp"/> |
| 115 | + </target> |
| 116 | + |
| 117 | + <!-- ================================= |
| 118 | + target: run |
| 119 | + ================================= --> |
| 120 | + <target name="run" depends="-init-grails" description="--> Runs a Grails application using embedded Jetty"> |
| 121 | + <grails script="RunApp"/> |
| 122 | + </target> |
| 123 | + |
| 124 | + <!-- ================================= |
| 125 | + target: deploy |
37 | 126 | ================================= -->
|
38 | 127 | <target name="deploy" depends="war" description="--> The deploy target (initially empty)">
|
39 | 128 | <!-- TODO -->
|
|
0 commit comments