-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGradle2Ant.xml
233 lines (201 loc) · 8.54 KB
/
Gradle2Ant.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
<?xml version="1.0" encoding="UTF-8" ?>
<project name="Gradle2Ant">
<description>
Call Gradle from Ant - Using Gradle Java plugin directly!
</description>
<!-- General properties! -->
<dirname property="current.dir" file="${ant.file}" />
<!-- General macro for running Gradle using Ant <exec> macro! -->
<macrodef name="gradle" description="Gradle task executioner">
<attribute name="task" />
<attribute name="project" default="" />
<attribute name="args" default="" />
<attribute name="wrapper" default="gradle" />
<attribute name="dir" default="${current.dir}" />
<sequential>
<exec executable="cmd" dir="@{dir}" failonerror="true">
<arg line="/C @{wrapper} @{project}:@{task} @{args}" />
</exec>
</sequential>
</macrodef>
<!-- Gradle task "classes" to compile classes -->
<macrodef name="gradle.classes" description="Gradle task 'classes'">
<attribute name="project" default="" />
<attribute name="args" default="" />
<attribute name="wrapper" default="gradle" />
<attribute name="dir" default="${current.dir}" />
<sequential>
<gradle task="classes"
project="@{project}"
args="@{args}"
wrapper="@{wrapper}"
dir="@{dir}" />
</sequential>
</macrodef>
<!-- Gradle task "jar" to create JAR archive -->
<macrodef name="gradle.jar" description="Gradle task 'jar'">
<attribute name="project" default="" />
<attribute name="args" default="" />
<attribute name="wrapper" default="gradle" />
<attribute name="dir" default="${current.dir}" />
<sequential>
<gradle task="jar"
project="@{project}"
args="@{args}"
wrapper="@{wrapper}"
dir="@{dir}" />
</sequential>
</macrodef>
<!-- Gradle task "fatJar" to create fat JAR archive -->
<macrodef name="gradle.fatJar" description="Gradle task 'fatJar'">
<attribute name="project" default="" />
<attribute name="args" default="" />
<attribute name="wrapper" default="gradle" />
<attribute name="dir" default="${current.dir}" />
<sequential>
<gradle task="fatJar"
project="@{project}"
args="@{args}"
wrapper="@{wrapper}"
dir="@{dir}" />
</sequential>
</macrodef>
<!-- Gradle task "testClasses" to compile test classes -->
<macrodef name="gradle.testClasses" description="Gradle task 'testClasses'">
<attribute name="project" default="" />
<attribute name="args" default="" />
<attribute name="wrapper" default="gradle" />
<attribute name="dir" default="${current.dir}" />
<sequential>
<gradle task="testClasses"
project="@{project}"
args="@{args}"
wrapper="@{wrapper}"
dir="@{dir}" />
</sequential>
</macrodef>
<!-- Gradle task "test" to run test classes -->
<macrodef name="gradle.test" description="Gradle task 'test'">
<attribute name="project" default="" />
<attribute name="args" default="" />
<attribute name="wrapper" default="gradle" />
<attribute name="dir" default="${current.dir}" />
<sequential>
<gradle task="test"
project="@{project}"
args="@{args}"
wrapper="@{wrapper}"
dir="@{dir}" />
</sequential>
</macrodef>
<!-- Gradle task "clean" to clean workspace -->
<macrodef name="gradle.clean" description="Gradle task 'clean'">
<attribute name="project" default="" />
<attribute name="args" default="" />
<attribute name="wrapper" default="gradle" />
<attribute name="dir" default="${current.dir}" />
<sequential>
<gradle task="clean"
project="@{project}"
args="@{args}"
wrapper="@{wrapper}"
dir="@{dir}" />
</sequential>
</macrodef>
<!-- Gradle task "javadoc" to create Java documentation -->
<macrodef name="gradle.javadoc" description="Gradle task 'javadoc'">
<attribute name="project" default="" />
<attribute name="args" default="" />
<attribute name="wrapper" default="gradle" />
<attribute name="dir" default="${current.dir}" />
<sequential>
<gradle task="javadoc"
project="@{project}"
args="@{args}"
wrapper="@{wrapper}"
dir="@{dir}" />
</sequential>
</macrodef>
<!-- Macro to add the Gradle wrapper verion as property to the current script -->
<macrodef name="gradlew.version" description="Load Gradle wrapper version">
<attribute name="dir" default="${current.dir}" />
<sequential>
<loadproperties srcfile="@{dir}/gradle/gradle-wrapper.properties" />
<script language="javascript"><![CDATA[
project.setProperty(
'gradle.version',
project.getProperty('distributionURL').split('gradle-')[1].split['-bin'][0]
)
]]></script>
</sequential>
</macrodef>
<!-- Macro to run Gradlew Wrapper from command line with non restricting arguments -->
<macrodef name="gradlew.cmd" description="Run Gradle Wrapper from command line">
<attribute name="args" default="" />
<attribute name="dir" default="${current.dir}" />
<sequential>
<exec executable="cmd" dir="@{dir}" failonerror="true">
<arg line="/C gradlew.bat @{args}" />
</exec>
</sequential>
</macrodef>
<!--
Macro to find the $buildDir/libs directory as the main Ant script is located inside
$projectDir/scripts by default!
-->
<scriptdef name="vGradleBuildLibsDir" language="javascript" description="">
<attribute name="buildxml" />
<![CDATA[
project.setProperty(
"gradle.build.libs.dir",
(new java.io.File(
new java.io.File(
(new java.io.File(
attributes.get("buildxml")
)).getParentFile().getParentFile(),
"build"
),
"libs"
)).getAbsolutePath()
);
]]>
</scriptdef>
<!-- Macro to get the generated JAR archive file name -->
<scriptdef name="vGradleJarName" language="javascript" description="">
<attribute name="folder" />
<attribute name="pname" />
<![CDATA[
var files = (new java.io.File(attributes.get("folder"))).listFiles();
for (i = 0; i < files.length; i++) {
var fn = files[i].getName();
if (fn.indexOf(attributes.get("pname")) !== -1 && fn.indexOf(".jar") !== -1
&& fn.indexOf("-fat") === -1) {
project.setProperty("gradle.jar.name", fn);
break;
}
}
]]>
</scriptdef>
<!-- Macro to get the generated fat JAR archive file name -->
<scriptdef name="vGradleFatJarName" language="javascript" description="">
<attribute name="folder" />
<attribute name="pname" />
<![CDATA[
var files = (new java.io.File(attributes.get("folder"))).listFiles();
for (i = 0; i < files.length; i++) {
var fn = files[i].getName();
if (fn.indexOf(attributes.get("pname")) !== -1 && fn.indexOf(".jar") !== -1
&& fn.indexOf("-fat") !== -1) {
project.setProperty("gradle.fatJar.name", fn);
break;
}
}
]]>
</scriptdef>
<!-- Target to kill all (zombie) Gradle processes (dont fail on error as WMIC isn't stable) -->
<target name="gradle.kill" description="Kill all (zombie) Gradle processes">
<exec executable="wmic.exe" failonerror="false">
<arg line="PROCESS WHERE "commandline like '%%org.gradle%%'" CALL Terminate" />
</exec>
</target>
</project>