1 | <project xmlns:ivy="antlib:org.apache.ivy.ant" name="gscf" 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" /> |
---|
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 | <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 |
---|
58 | ================================= --> |
---|
59 | <target name="-resolve" description="--> Retrieve dependencies with ivy" depends="init-ivy"> |
---|
60 | <ivy:retrieve pattern="${lib.dir}/[conf]/[artifact]-[revision].[ext]"/> |
---|
61 | </target> |
---|
62 | |
---|
63 | <target name="-init-grails" depends="-resolve"> |
---|
64 | <path id="grails.classpath"> |
---|
65 | <fileset dir="${lib.dir}/build"/> |
---|
66 | <fileset dir="${lib.dir}"/> |
---|
67 | </path> |
---|
68 | |
---|
69 | <path id="compile.classpath"> |
---|
70 | <fileset dir="${lib.dir}/compile"/> |
---|
71 | </path> |
---|
72 | |
---|
73 | <path id="test.classpath"> |
---|
74 | <fileset dir="${lib.dir}/test"/> |
---|
75 | </path> |
---|
76 | |
---|
77 | <path id="app.classpath"> |
---|
78 | <fileset dir="${lib.dir}/runtime"/> |
---|
79 | </path> |
---|
80 | |
---|
81 | <taskdef name="grailsTask" |
---|
82 | classname="grails.ant.GrailsTask" |
---|
83 | classpathref="grails.classpath"/> |
---|
84 | </target> |
---|
85 | |
---|
86 | <target name="deps-report" depends="-resolve" description="--> Generate report of module dependencies."> |
---|
87 | <ivy:report conf="*"/> |
---|
88 | </target> |
---|
89 | |
---|
90 | <!-- ================================= |
---|
91 | target: clean |
---|
92 | ================================= --> |
---|
93 | <target name="clean" description="--> Cleans a Grails application"> |
---|
94 | <delete failonerror="true"> |
---|
95 | <fileset dir="${lib.dir}/build" includes="*/"/> |
---|
96 | <fileset dir="${lib.dir}/compile" includes="*/"/> |
---|
97 | <fileset dir="${lib.dir}/runtime" includes="*/"/> |
---|
98 | <fileset dir="${lib.dir}/test" includes="*/"/> |
---|
99 | </delete> |
---|
100 | <antcall target="--grails-clean"/> |
---|
101 | </target> |
---|
102 | |
---|
103 | <!-- extra target to avoid errors on Windows because libs on classpath can not be deleted --> |
---|
104 | <target name="--grails-clean" depends="-init-grails"> |
---|
105 | <grails script="Clean"/> |
---|
106 | </target> |
---|
107 | |
---|
108 | <!-- ================================= |
---|
109 | target: compile |
---|
110 | ================================= --> |
---|
111 | <target name="compile" depends="-init-grails" description="--> Compiles a Grails application"> |
---|
112 | <grails script="Compile"/> |
---|
113 | </target> |
---|
114 | |
---|
115 | <!-- ================================= |
---|
116 | target: war |
---|
117 | ================================= --> |
---|
118 | <target name="war" depends="-init-grails" description="--> Creates a WAR of a Grails application"> |
---|
119 | <grails script="War"/> |
---|
120 | </target> |
---|
121 | |
---|
122 | <!-- ================================= |
---|
123 | target: test |
---|
124 | ================================= --> |
---|
125 | <target name="test" depends="-init-grails" description="--> Run a Grails applications unit tests"> |
---|
126 | <grails script="TestApp"/> |
---|
127 | </target> |
---|
128 | |
---|
129 | <!-- ================================= |
---|
130 | target: run |
---|
131 | ================================= --> |
---|
132 | <target name="run" depends="-init-grails" description="--> Runs a Grails application using embedded Jetty"> |
---|
133 | <grails script="RunApp"/> |
---|
134 | </target> |
---|
135 | |
---|
136 | <!-- ================================= |
---|
137 | target: deploy |
---|
138 | ================================= --> |
---|
139 | <target name="deploy" depends="war" description="--> The deploy target (initially empty)"> |
---|
140 | <!-- TODO --> |
---|
141 | </target> |
---|
142 | </project> |
---|