-
Notifications
You must be signed in to change notification settings - Fork 4
/
build.xml
278 lines (229 loc) · 11 KB
/
build.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
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
<?xml version="1.0" encoding="ISO-8859-1"?>
<project name="coffee-brew" default="install-rubymine-31">
<!-- Define build properties -->
<loadfile property="version" srcfile="VERSION">
<filterchain>
<striplinebreaks/>
</filterchain>
</loadfile>
<property file="build.properties"/>
<!-- Reference the IDEA classpath from the local IDE installation -->
<path id="ideax.classpath">
<fileset dir="${ideax.source}">
<include name="lib/*.jar"/>
<include name="redist/*.jar"/>
</fileset>
<fileset dir="${ideax.app}">
<include name="*.jar"/>
</fileset>
</path>
<path id="maia.classpath">
<fileset dir="${maia.source}">
<include name="lib/*.jar"/>
<include name="redist/*.jar"/>
</fileset>
<fileset dir="${maia.app}">
<include name="*.jar"/>
</fileset>
</path>
<!-- Define the java compiler task -->
<taskdef name="javacIdeax" classname="com.intellij.ant.Javac2">
<classpath refid="ideax.classpath"/>
</taskdef>
<taskdef name="javacMaia" classname="com.intellij.ant.Javac2">
<classpath refid="maia.classpath"/>
</taskdef>
<!-- Define the jflex compiler task -->
<taskdef name="jflexIdeax" classname="JFlex.anttask.JFlexTask">
<classpath location="${ideax.source}/tools/lexer/jflex-1.4/lib/JFlex.jar"/>
</taskdef>
<taskdef name="jflexMaia" classname="JFlex.anttask.JFlexTask">
<classpath location="${maia.source}/tools/lexer/jflex-1.4/lib/JFlex.jar"/>
</taskdef>
<!-- Clean up generated files -->
<target name="clean">
<delete dir="target"/>
</target>
<!-- Create target directories -->
<target name="init" depends="clean">
<mkdir dir="target/ideax-classes/META-INF"/>
<mkdir dir="target/junit-ideax"/>
<mkdir dir="target/test-ideax-classes"/>
<mkdir dir="target/test-ideax-reports"/>
<mkdir dir="target/maia-classes/META-INF"/>
<mkdir dir="target/junit-maia"/>
<mkdir dir="target/test-maia-classes"/>
<mkdir dir="target/test-maia-reports"/>
<mkdir dir="target/coffee-script"/>
<mkdir dir="target/jar"/>
</target>
<!-- Copy compilation resources -->
<target name="resources-ideax" depends="init">
<copy todir="target/ideax-classes">
<fileset dir="resources" excludes="coffee-script/**"/>
</copy>
</target>
<target name="resources-maia" depends="init">
<copy todir="target/maia-classes">
<fileset dir="resources" excludes="coffee-script/**"/>
</copy>
</target>
<!-- Generate the tokens from the CoffeeScript resources for testing the plugion -->
<target name="generate-original-tokens" depends="init"
description="Generate the CoffeeScript tokens within resources/coffee-script">
<apply executable="/usr/local/bin/node">
<arg value="/usr/local/share/npm/bin/coffee"/>
<arg value="-t"/>
<fileset dir="resources/coffee-script" includes="*.coffee"/>
<redirector>
<outputmapper type="glob" from="*.coffee" to="resources/coffee-script/*.tokens"/>
</redirector>
</apply>
</target>
<!-- Generate the lexer class -->
<target name="generate-ideax-lexer">
<jflexIdeax skeleton="${ideax.source}/tools/lexer/idea-flex.skeleton" nobak="true"
file="src/org/coffeebrew/lang/lexer/coffee-script.flex"
destdir="src"
charat="true"/>
</target>
<target name="generate-maia-lexer">
<jflexMaia skeleton="${maia.source}/tools/lexer/idea-flex.skeleton" nobak="true"
file="src/org/coffeebrew/lang/lexer/coffee-script.flex"
destdir="src"
charat="true"/>
</target>
<!-- Compile the plugin -->
<target name="compile-ideax" depends="resources-ideax, generate-ideax-lexer">
<javacIdeax srcdir="src" destdir="target/ideax-classes" source="1.5" target="1.5" includeantruntime="yes">
<classpath refid="ideax.classpath"/>
</javacIdeax>
<javacIdeax srcdir="test" destdir="target/test-ideax-classes" source="1.5" target="1.5" includeantruntime="yes">
<classpath refid="ideax.classpath"/>
<classpath location="target/ideax-classes"/>
</javacIdeax>
</target>
<target name="compile-maia" depends="resources-maia, generate-maia-lexer">
<javacMaia srcdir="src" destdir="target/maia-classes" source="1.5" target="1.5" includeantruntime="yes">
<classpath refid="maia.classpath"/>
</javacMaia>
<javacMaia srcdir="test" destdir="target/test-maia-classes" source="1.5" target="1.5" includeantruntime="yes">
<classpath refid="maia.classpath"/>
<classpath location="target/maia-classes"/>
</javacMaia>
</target>
<!-- Test the plugin -->
<target name="test-ideax" depends="compile-ideax">
<junit failureproperty="unit-test.fail" forkmode="once" fork="yes" includeantruntime="yes"
tempdir="${basedir}/target/junit-ideax" printsummary="yes" showoutput="yes">
<classpath location="${basedir}/target/ideax-classes"/>
<classpath location="${basedir}/target/test-ideax-classes"/>
<classpath refid="ideax.classpath"/>
<formatter type="xml"/>
<batchtest todir="${basedir}/target/test-ideax-reports" fork="yes">
<fileset dir="${basedir}/target/test-ideax-classes" includes="**/*Test.class"/>
</batchtest>
</junit>
<fail if="unit-test.fail" message="Unit test failed. See target/test-ideax-reports for more information."/>
</target>
<target name="test-maia" depends="compile-maia">
<junit failureproperty="unit-test.fail" forkmode="once" fork="yes" includeantruntime="yes"
tempdir="${basedir}/target/junit-maia" printsummary="yes" showoutput="yes">
<classpath location="${basedir}/target/maia-classes"/>
<classpath location="${basedir}/target/test-maia-classes"/>
<classpath refid="maia.classpath"/>
<formatter type="xml"/>
<batchtest todir="${basedir}/target/test-maia-reports" fork="yes">
<fileset dir="${basedir}/target/test-maia-classes" includes="**/*Test.class"/>
</batchtest>
</junit>
<fail if="unit-test.fail" message="Unit test failed. See target/test-maia-reports for more information."/>
</target>
<!-- Build the jar -->
<target name="jar" depends="test-maia, test-ideax" description="Build the plugin jar">
<copy file="META-INF/plugin.xml" todir="target/ideax-classes/META-INF">
<filterset>
<filter token="version" value="${version}"/>
</filterset>
</copy>
<jar destfile="target/jar/coffee-brew-${version}.jar" compress="true">
<fileset dir="target/ideax-classes"/>
</jar>
</target>
<!-- Install plugin to IntelliJ IDEA 9.0.3 CE -->
<target name="install-idea-9" depends="jar" description="Install the plugin to IntelliJ IDEA 9.0.3 CE">
<mkdir dir="${user.home}/Library/Application Support/IntelliJIdea90CE"/>
<delete dir="${user.home}/Library/Application Support/IntelliJIdea90CE" includes="coffee-brew*.jar"/>
<copy todir="${user.home}/Library/Application Support/IntelliJIdea90CE">
<fileset dir="${basedir}/target/jar" includes="*.jar"/>
</copy>
</target>
<!-- Install plugin to IntelliJ IDEA 10 CE -->
<target name="install-idea-10" depends="jar" description="Install the plugin to IntelliJ IDEA 10 CE">
<mkdir dir="${user.home}/Library/Application Support/IntelliJIdea10CE"/>
<delete dir="${user.home}/Library/Application Support/IntelliJIdea10CE" includes="coffee-brew*.jar"/>
<copy todir="${user.home}/Library/Application Support/IntelliJIdea10CE">
<fileset dir="${basedir}/target/jar" includes="*.jar"/>
</copy>
</target>
<!-- Install plugin to RubyMine 3.0.1 -->
<target name="install-rubymine-30" depends="jar" description="Install the plugin to RubyMine 3.0.1">
<mkdir dir="${user.home}/Library/Application Support/RubyMine30"/>
<delete dir="${user.home}/Library/Application Support/RubyMine30" includes="coffee-brew*.jar"/>
<copy todir="${user.home}/Library/Application Support/RubyMine30">
<fileset dir="${basedir}/target/jar" includes="*.jar"/>
</copy>
</target>
<!-- Install plugin to RubyMine 3.1 EAP -->
<target name="install-rubymine-31" depends="jar" description="Install the plugin to RubyMine 3.1 EAP">
<mkdir dir="${user.home}/Library/Application Support/RubyMine31"/>
<delete dir="${user.home}/Library/Application Support/RubyMine31" includes="coffee-brew*.jar"/>
<copy todir="${user.home}/Library/Application Support/RubyMine31">
<fileset dir="${basedir}/target/jar" includes="*.jar"/>
</copy>
</target>
<!-- Release new version -->
<target name="release" depends="nothing-to-commit" description="Release a new version">
<echo>The current version is: ${version}</echo>
<input message="Enter the new version: " addproperty="release"/>
<antcall target="jar">
<param name="version" value="${release}"/>
</antcall>
<input message="Going to release version ${release}. Are you sure? " addproperty="do.release" validargs="y,n"/>
<condition property="do.abort">
<equals arg1="n" arg2="${do.release}"/>
</condition>
<fail if="do.abort">Release aborted by user.</fail>
<echo file="VERSION">${release}</echo>
<exec executable="git">
<arg line="commit VERSION -m 'New release v${release}'"/>
</exec>
<exec executable="git">
<arg line="tag v${release}"/>
</exec>
<exec executable="git">
<arg line="push --tags origin master"/>
</exec>
<echo>Release is done. Please upload target/jar/coffee-brew-${release}.jar to JetBrains Plugin Repository now.
</echo>
<exec executable="open">
<arg value="http://plugins.intellij.net/plugin/?&id=5920"/>
</exec>
<echo>---------------------- CHANGELOG ------------------------</echo>
<exec executable="git">
<arg line="shortlog v${version}..v${release}"/>
</exec>
<echo>---------------------------------------------------------</echo>
</target>
<target name="nothing-to-commit">
<exec executable="git" outputproperty="result">
<arg value="status"/>
</exec>
<condition property="do.abort">
<not>
<contains substring="nothing to commit" string="${result}"/>
</not>
</condition>
<fail if="do.abort">Uncommited changes. Please commit all changes before release a new version.</fail>
</target>
</project>