-
Notifications
You must be signed in to change notification settings - Fork 16
/
build.xml.template
227 lines (203 loc) · 8.93 KB
/
build.xml.template
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
<?xml version="1.0"?>
<project name="Processing.R" default="install" basedir="." xmlns:jacoco="antlib:org.jacoco.ant" xmlns:artifact="antlib:org.apache.maven.artifact.ant">
<property name="mode.name" value="RLangMode" />
<!-- Folder to install modes in (probably a folder called "modes" inside your sketchbook folder) -->
<property name="processing.modes" value="@@modes@@" />
<!-- Path to your processing executable. -->
<property name="processing.executable" value="@@executable@@" />
<!-- Location of processing jars (core.jar, pde.jar, ..) -->
<property name="processing.classes.core" value="@@core@@" />
<property name="processing.classes.pde" value="@@pde@@" />
<!-- Version of the mode -->
<property name="processing.r.version" value="@@version@@" />
<property name="processing.r.prettyversion" value="@@pretty@@" />
<!-- Folder -->
<property name="try" value="try" />
<property name="mode-lib" value="lib/mode" />
<property name="test-lib" value="lib/test" />
<property name="build-lib" value="lib/build" />
<property name="src" value="src" />
<property name="build" value="build" />
<property name="bin" value="bin" />
<property name="dist" value="dist" />
<property name="r.core.dir" value="src/rprocessing/r" />
<!-- Test -->
<property name="test.build.dir" value="test-output" />
<property name="test.src.dir" value="src" />
<property name="result.classes.dir" location="${test.build.dir}" />
<property name="result.report.dir" location="${test.build.dir}/site/jacoco" />
<property name="result.exec.file" location="${test.build.dir}/jacoco.exec" />
<!-- Version control of dependencies -->
<property name="renjin-version" value="0.8.2411" />
<property name="java.target.version" value="1.8" />
<path id="mode-library-classpath">
<pathelement location="${processing.classes.pde}" />
<fileset dir="${processing.classes.core}">
<include name="*.jar" />
</fileset>
<fileset dir="${mode-lib}">
<include name="*.jar" />
</fileset>
</path>
<path id="test-library-classpath">
<fileset dir="${test-lib}">
<include name="*.jar" />
</fileset>
</path>
<taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml">
<classpath>
<path refid="test-library-classpath" />
</classpath>
</taskdef>
<target name="info">
<echo>This is the R mode for Processing, powered by github.com/gaocegege</echo>
</target>
<target name="checkos">
<condition property="isWindows" value="true">
<os family="windows" />
</condition>
<condition property="isMacOS" value="true">
<os family="mac" />
</condition>
<condition property="isLinux" value="true">
<and>
<isfalse value="${isMacOS}" />
<os family="unix" />
</and>
</condition>
</target>
<target name="dep" depends="checkos" if="isLinux">
<echo>The OS platform is Linux X86_64, download corresponding jars from remote.</echo>
<!-- Maven deps -->
<path id="maven-ant-tasks.classpath" path="${build-lib}/maven-ant-tasks-2.1.3.jar" />
<typedef resource="org/apache/maven/artifact/ant/antlib.xml"
uri="antlib:org.apache.maven.artifact.ant"
classpathref="maven-ant-tasks.classpath" />
<artifact:remoteRepository id="remote.repository" url="https://nexus.bedatadriven.com/content/groups/public/" />
<artifact:dependencies filesetId="dependency.fileset"
versionsId="dependency.versions">
<remoteRepository refid="remote.repository" />
<dependency groupId="org.renjin" artifactId="renjin-script-engine" version="${renjin-version}" />
<dependency groupId="org.renjin" artifactId="renjin-cli" version="${renjin-version}" />
</artifact:dependencies>
<copy todir="${mode-lib}">
<fileset refid="dependency.fileset" />
<mapper classpathref="maven-ant-tasks.classpath"
classname="org.apache.maven.artifact.ant.VersionMapper"
from="${dependency.versions}" to="flatten" />
</copy>
</target>
<target name="build" depends="dep">
<mkdir dir="build" />
<javac destdir="build" includeantruntime="false">
<src path="src/rprocessing" />
<classpath>
<path refid="mode-library-classpath" />
</classpath>
</javac>
<copy todir="build">
<fileset dir="src" excludes="**/*.java" />
</copy>
</target>
<target name="try" depends="build">
<propertyfile file="build.number" />
<!-- create the build.number file if it doesn't exist -->
<buildnumber file="build.number" />
<mkdir dir="${try}" />
<jar jarfile="try/${mode.name}.jar" basedir="build">
<manifest>
<attribute name="Main-Class" value="rprocessing.Runner" />
</manifest>
<zipfileset src="${processing.classes.pde}"/>
<zipgroupfileset dir="${processing.classes.core}" includes="*.jar" />
<zipgroupfileset dir="${mode-lib}" includes="**/*.jar" />
</jar>
</target>
<target name="package" depends="build">
<delete dir="${dist}" />
<property name="bundle" value="${dist}/${mode.name}" />
<mkdir dir="${bundle}" />
<mkdir dir="${bundle}/mode" />
<mkdir dir="${bundle}/examples" />
<jar jarfile="${bundle}/mode/${mode.name}.jar" basedir="build" />
<copy todir="${bundle}">
<fileset dir="resources/" />
</copy>
<copy todir="${bundle}/mode">
<fileset dir="${mode-lib}" />
</copy>
<copy todir="${bundle}/examples">
<fileset dir="examples/" />
</copy>
<!-- TODO: Configure the version in bash script. -->
<replaceregexp file="${bundle}/mode.properties" flags="g" match="@@mode-version@@" replace="${processing.r.version}" />
<replaceregexp file="${bundle}/mode.properties" flags="g" match="@@pretty-version@@" replace="${processing.r.prettyversion}" />
</target>
<target name="install" depends="package">
<delete dir="${processing.modes}/${mode.name}" />
<mkdir dir="${processing.modes}/${mode.name}" />
<copy todir="${processing.modes}/${mode.name}">
<fileset dir="${dist}/${mode.name}" />
</copy>
</target>
<target name="run" depends="install">
<exec executable="${processing.executable}" spawn="false" />
</target>
<target name="test-compile">
<mkdir dir="${test.build.dir}"/>
<javac srcdir="${test.src.dir}" destdir="${test.build.dir}" includeantruntime="false">
<classpath>
<path refid="mode-library-classpath" />
<path refid="test-library-classpath" />
</classpath>
</javac>
</target>
<target name="test" depends="test-compile">
<copy todir="${test.build.dir}/rprocessing/r" >
<fileset dir="${r.core.dir}" includes="**"/>
</copy>
<jacoco:coverage destfile="${result.exec.file}">
<junit printsummary="on" haltonfailure="yes" fork="true">
<classpath>
<path refid="mode-library-classpath" />
<path refid="test-library-classpath" />
<pathelement location="${test.build.dir}"/>
</classpath>
<formatter type="brief" usefile="false" />
<batchtest>
<fileset dir="${test.src.dir}" includes="**/*Test.java" />
</batchtest>
</junit>
</jacoco:coverage>
</target>
<target name="report" depends="test">
<!-- Step 3: Create coverage report -->
<jacoco:report>
<!--
This task needs the collected execution data and ...
-->
<executiondata>
<file file="${result.exec.file}"/>
</executiondata>
<!-- the class files and optional source files ... -->
<structure name="Processing.R">
<classfiles>
<fileset dir="${result.classes.dir}"/>
</classfiles>
<sourcefiles encoding="UTF-8">
<fileset dir="${test.src.dir}"/>
</sourcefiles>
</structure>
<!-- to produce reports in different formats. -->
<html destdir="${result.report.dir}"/>
<csv destfile="${result.report.dir}/report.csv"/>
<xml destfile="${result.report.dir}/report.xml"/>
</jacoco:report>
</target>
<target name="clean">
<delete dir="${build}" />
<delete dir="${dist}" />
<delete dir="${try}" />
<delete dir="${test.build.dir}" />
</target>
</project>