forked from XVicarious/INpureCore
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjenkins.xml
267 lines (239 loc) · 11.6 KB
/
jenkins.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
<project name="INpureCore" default="main" basedir=".">
<property environment="env"/>
<loadproperties srcfile="mod.properties" />
<loadproperties srcfile="maven.properties" />
<property name="src.dir" value="src/main/java"/>
<property name="api.dir" value="src/api/java"/>
<property name="utils.dir" value="utils"/>
<property name="deps.dir" value="deps"/>
<property name="download.dir" value="downloads"/>
<property name="build.dir" value="."/>
<property name="gradle.output.dir" value="${build.dir}/build/libs"/>
<property name="gradle.output" value="${gradle.output.dir}/modid-1.0.jar"/>
<property name="reobf.dir" value="${build.dir}/reobf"/>
<property name="bin.dir" value="${build.dir}/bin"/>
<property name="lib.dir" value="${build.dir}/libs"/>
<property name="forge.url" value=""/>
<!-- Project information -->
<property name="build.name" value="${ant.project.name}"/>
<!-- Version file -->
<property name="verclass.dir" value="${src.dir}/${class.pckg}" />
<property name="verclass.name" value="modInfo.java"/>
<property name="packaging.dir" value="${basedir}/build/dist"/>
<!-- Classpaths -->
<path id="gson">
<fileset dir="${download.dir}">
<include name="gson.jar"/>
</fileset>
</path>
<target name="properties">
<available property="has.folders" type="dir" file="${download.dir}"/>
<available property="has.forge" file="${download.dir}/forge.zip"/>
<available property="has.maven" file="${download.dir}/maven/maven-ant-tasks-2.1.3.jar"/>
</target>
<target name="make.dirs" unless="has.folders" depends="properties">
<mkdir dir="${deps.dir}"/>
<mkdir dir="${api.dir}"/>
<mkdir dir="${download.dir}"/>
<mkdir dir="${reobf.dir}"/>
<mkdir dir="${bin.dir}"/>
<mkdir dir="${lib.dir}"/>
</target>
<target name="setup.forge" depends="make.dirs" unless="has.forge">
<echo message="Downloading ForgeGradle..."/>
<get dest="${download.dir}/forge.zip">
<url url="${forge.url}"/>
</get>
<get dest="${download.dir}/gson.jar">
<url url="http://files.inpureprojects.info/libs/gson-2.3.1.jar"/>
</get>
<get dest="${lib.dir}">
<url url="http://files.inpureprojects.info/libs/commons-codec-1.9.jar"/>
<url url="http://files.inpureprojects.info/libs/commons-compress-1.8.1.jar"/>
<url url="http://files.inpureprojects.info/libs/jruby.jar"/>
<url url="http://files.inpureprojects.info/libs/luaj-jse-3.0.jar"/>
<url url="http://files.inpureprojects.info/libs/groovy-2.3.9.jar"/>
<url url="http://files.inpureprojects.info/libs/commons-io-2.4.jar"/>
<url url="http://files.inpureprojects.info/libs/groovy-jsr223-2.3.9.jar"/>
</get>
<get dest="${download.dir}">
<url url="http://files.inpureprojects.info/libs/jarjar-1.4.jar"/>
</get>
<echo message="Unzipping ForgeGradle..."/>
<unzip src="${download.dir}/forge.zip" dest="${build.dir}" overwrite="false"/>
<echo message="Cleaning up ForgeGradle files..."/>
<delete>
<fileset dir="${build.dir}">
<include name="*.txt"/>
</fileset>
</delete>
<delete dir="${build.dir}/eclipse"/>
<delete dir="${build.dir}/src/main/java/com"/>
<echo message="Running ForgeGradle Setup..."/>
<chmod dir="${build.dir}" perm="ugo+rx" includes="gradlew"/>
<exec dir="${build.dir}" executable="cmd" osfamily="windows">
<arg line="/c gradlew.bat setupDecompWorkspace setupDevWorkspace idea --refresh-dependencies"/>
</exec>
<exec dir="${build.dir}" executable="sh" osfamily="unix">
<arg line="gradlew setupDecompWorkspace setupDevWorkspace idea --refresh-dependencies"/>
</exec>
</target>
<target name="setup" depends="setup.forge">
<echo message="Setup: Complete."/>
</target>
<target name="compile" depends="setup">
<exec dir="${build.dir}" executable="cmd" osfamily="windows">
<arg line="/c gradlew.bat build"/>
</exec>
<exec dir="${build.dir}" executable="sh" osfamily="unix">
<arg line="gradlew build"/>
</exec>
</target>
<target name="get-version" depends="compile">
<script language="javascript"><![CDATA[
var name = project.getProperty("build.full");
if (name == null || name == "") {
name = project.getProperty("verclass.name");
if (name == null || name == "") {
project.setProperty("build.full", "-");
}
}
]]></script>
<local name="grep.out"/><local name="mfrv"/><local name="mcv"/>
<!-- Read version out of file -->
<script language="javascript"><![CDATA[
importClass(java.io.File);
importClass(java.util.Scanner);
var mainClass = new File(project.getProperty("verclass.dir"), project.getProperty("verclass.name"));
mainClass = new Scanner(mainClass, "UTF-8").useDelimiter("\\Z");
var text = mainClass.next();
mainClass.close();
var matches = /[0-9.]+R[0-9.]+((RC|B)[0-9]+)?/.exec(text);
project.setProperty("grep.out", matches[0]);
]]></script>
<!-- Split mod&mc version, update mcmod -->
<script language="javascript" classpathref="gson"><![CDATA[
importPackage(Packages.com.google.gson);
importPackage(Packages.com.google.gson.stream);
importPackage(java.io);
importClass(java.util.Scanner);
versionlist = project.getProperty("grep.out").split('R');
mcversion = versionlist[0];
mfrversion = versionlist[1];
if (versionlist.length > 2)
mfrversion = versionlist[1]+"R"+versionlist[2];
project.setProperty("mfrv", mfrversion);
project.setProperty("mcv", mcversion);
var c = project.getProperty("build.channel");
if (c == null || c == "")
project.setProperty("build.channel", mfrversion.indexOf("B") > 0 ? "alpha" : (
mfrversion.indexOf("RC") > 0 ? "beta" : "release"));
// open file and parse JSON structure
var file = new File(project.getProperty("resources.dir") + "/mcmod.info");
if (file.exists())
{
var mcmod = new Scanner(file, "UTF-8").useDelimiter("\\Z");
var data = new JsonParser().parse(mcmod.next()).getAsJsonArray();
mcmod.close();
// update all version elements
for (var i = 0, e = data.size(); i < e; ++i) {
var element = data.get(i).getAsJsonObject();
element.addProperty("version", mfrversion);
element.addProperty("mcversion", mcversion);
}
// write file back, pretty-printed
var output = new JsonWriter(new FileWriter(file));
output.setIndent(" ");
new Gson().toJson(data, output);
output.close();
}
]]></script>
<echo message="Version: ${mfrv} Channel: ${build.channel}"/>
<property name="build.full" value="-[${mcv}]${mfrv}-"/>
<property name="build.full.sub1" value="[${mcv}]${mfrv}-"/>
</target>
<target name="build-number-missing" depends="get-version" unless="env.BUILD_NUMBER">
<property name="env.BUILD_NUMBER" value="CUSTOM-BUILD"/>
</target>
<target name="build-number-there" depends="build-number-missing">
<echo message="Using build number ${env.BUILD_NUMBER}..."/>
<property name="build.number" value="${env.BUILD_NUMBER}"/>
</target>
<target name="package" depends="build-number-there">
<delete dir="${packaging.dir}"/>
<unzip src="${basedir}/build/libs/${ant.project.name}-1.0.jar" dest="${packaging.dir}/classes"/>
<taskdef name="jarjar" classname="com.tonicsystems.jarjar.JarJarTask" classpath="${download.dir}/jarjar-1.4.jar"/>
<jar destfile="${packaging.dir}/${build.name}${build.full}${build.number}.jar" basedir="${packaging.dir}/classes" manifest="${packaging.dir}/classes/META-INF/MANIFEST.MF"/>
<jar destfile="${packaging.dir}/src/${build.name}${build.full}${build.number}.jar" basedir="${basedir}/src/main/java" manifest="${packaging.dir}/classes/META-INF/MANIFEST.MF"/>
<jarjar jarfile="${packaging.dir}/dev/${build.name}${build.full}${build.number}.jar" manifest="${packaging.dir}/classes/META-INF/MANIFEST.MF">
<fileset dir="${basedir}/src/main/resources"/>
<fileset dir="${basedir}/build/classes/main"/>
<zipfileset src="${lib.dir}/commons-codec-1.9.jar"/>
<zipfileset src="${lib.dir}/commons-compress-1.8.1.jar"/>
<zipfileset src="${lib.dir}/jruby.jar"/>
<zipfileset src="${lib.dir}/luaj-jse-3.0.jar"/>
<zipfileset src="${lib.dir}/groovy-2.3.9.jar"/>
<zipfileset src="${lib.dir}/commons-io-2.4.jar"/>
<zipfileset src="${lib.dir}/groovy-jsr223-2.3.9.jar"/>
</jarjar>
<jar destfile="${packaging.dir}/api/${build.name}${build.full}${build.number}.jar" manifest="${packaging.dir}/classes/META-INF/MANIFEST.MF">
<fileset dir="${basedir}/src/main/java">
<include name="${maven.api.dir}"/>
</fileset>
</jar>
<jar destfile="${packaging.dir}/javadoc/${build.name}${build.full}${build.number}.jar" basedir="${basedir}/javadoc" manifest="${packaging.dir}/classes/META-INF/MANIFEST.MF"/>
<delete dir="${packaging.dir}/classes"/>
</target>
<target name="maven.setup" depends="package" unless="has.maven">
<property name="inpurelibs" value="http://files.inpureprojects.info/libs"/>
<mkdir dir="${download.dir}/maven"/>
<get dest="${download.dir}/maven">
<url url="${inpurelibs}/maven-ant-tasks-2.1.3.jar"/>
</get>
<mkdir dir="${download.dir}/ant-contrib"/>
<get dest="${download.dir}/ant-contrib/ant-contrib.jar">
<url url="${inpurelibs}/ant-contrib-1.0b3.jar"/>
</get>
</target>
<target name="maven" depends="maven.setup" xmlns:artifact="urn:maven-artifact-ant">
<typedef resource="org/apache/maven/artifact/ant/antlib.xml" uri="urn:maven-artifact-ant"
classpath="${download.dir}/maven/maven-ant-tasks-2.1.3.jar"/>
<taskdef resource="net/sf/antcontrib/antcontrib.properties">
<classpath>
<pathelement location="${download.dir}/ant-contrib/ant-contrib.jar"/>
</classpath>
</taskdef>
<!-- pom -->
<echo message="Writing pom data..."/>
<artifact:pom id="mypom" groupId="${maven.group}" artifactId="${build.name}" version="${build.full.sub1}${build.number}" name="${ant.project.name}">
<license name="IDGAF" url="${maven.license}"/>
<dependency groupId="appeng" artifactId="appliedenergistics2" version="rv1-stable-1" classifier="dev"/>
<dependency groupId="codechicken" artifactId="NotEnoughItems" version="1.7.10-1.0.3.57" classifier="dev"/>
<dependency groupId="codechicken" artifactId="ForgeMultipart" version="1.7.10-1.1.0.313" classifier="dev"/>
<dependency groupId="org.apache.logging.log4j" artifactId="log4j-core" version="2.0-beta9"/>
<dependency groupId="org.apache.commons" artifactId="commons-lang3" version="3.0"/>
</artifact:pom>
<!-- There seems to be a bug in maven-ant-tasks here. In order to avoid deploy exploding into a fireball you need to save your pom to a file temporarily and load it into a new id. -->
<artifact:writepom pomRefId="mypom" file="pom.xml"/>
<echo message="Loading pom data..."/>
<artifact:pom id="mypom1" file="pom.xml"/>
<!-- -->
<condition property="maven.repo.local" value="${maven.repo.local}" else="${user.home}/.m2/repository">
<isset property="maven.repo.local"/>
</condition>
<echo>maven.repo.local=${maven.repo.local}</echo>
<artifact:localRepository id="local.repository" path="${maven.repo.local}"/>
<artifact:install-provider artifactId="wagon-file" version="2.7"/>
<artifact:deploy file="${packaging.dir}/${build.name}${build.full}${build.number}.jar">
<remoteRepository url="file://${basedir}/maven"/>
<pom refid="mypom1"/>
<attach file="${packaging.dir}/src/${build.name}${build.full}${build.number}.jar" type="jar" classifier="sources"/>
<attach file="${packaging.dir}/dev/${build.name}${build.full}${build.number}.jar" type="jar" classifier="dev"/>
<attach file="${packaging.dir}/javadoc/${build.name}${build.full}${build.number}.jar" type="jar" classifier="javadoc"/>
<attach file="${packaging.dir}/api/${build.name}${build.full}${build.number}.jar" type="jar" classifier="api"/>
</artifact:deploy>
</target>
<target name="main" depends="maven">
<echo message="Build script execution complete."/>
</target>
</project>