forked from pantheis/AdvancedInventoryManagement
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
179 lines (153 loc) · 6.59 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
<project name="AdvancedInventoryManagement" basedir="../" default="main">
<property environment="env" />
<property name="mcp.version" value="751"/>
<property name="forge.version" value="1.5.2-7.8.0.696"/>
<property name="mymod.version" value="1.0"/>
<property name="mod.name" value="${env.JOB_NAME}"/>
<property name="mod.dir" value="repo"/>
<property name="build.dir" value="build"/>
<property name="src.dir" value="${mod.dir}/src"/>
<property name="res.dir" value="${mod.dir}/resources"/>
<property name="sign.dir" value="/var/lib/jenkins/.sign"/>
<property name="download.dir" value="../download"/>
<property name="classes.dir" value="${build.dir}/classes"/>
<property name="jar.dir" value="${build.dir}/dist"/>
<property name="forge.dir" value="${build.dir}/${forge.version}/forge"/>
<property name="mcp.dir" value="${forge.dir}/mcp"/>
<property name="mcpsrc.dir" value="${mcp.dir}/src/minecraft"/>
<property name="forge.filename" value="minecraftforge-src-${forge.version}.zip"/>
<property name="mcpsrc.backup" value="mcpsrc-backup-${forge.version}.zip"/>
<available property="forge-exists" file="${download.dir}/${forge.filename}"/>
<available property="can-restore" file="${forge.dir}/../${mcpsrc.backup}"/>
<mkdir dir="${download.dir}"/>
<!-- Set build number -->
<target name="initialize-version" depends="version-provided,version-not-provided">
<property name="mymod.version.full" value="${mymod.version}.${build.number}"/>
<echo message="Starting build for ${mymod.version.full}"/>
</target>
<target name="version-not-provided" unless="env.BUILD_NUMBER">
<echo message="Setting build number"/>
<buildnumber/>
</target>
<target name="version-provided" if="env.BUILD_NUMBER">
<echo message="Checking build number"/>
<property name="build.number" value="${env.BUILD_NUMBER}"/>
</target>
<!-- Download forge (if it doesn't exist) -->
<target name="download-forge" depends="initialize-version" unless="forge-exists">
<echo message="Downloading Minecraft Forge ${forge.version}"/>
<get src="http://files.minecraftforge.net/minecraftforge-src-${forge.version}.zip" dest="${download.dir}" usetimestamp="True"/>
</target>
<!-- Setup mcp and forge -->
<target name="setup-forge" depends="initialize-version,download-forge" unless="can-restore">
<echo message="Setting up Forge and MCP"/>
<delete dir="${build.dir}" failonerror="false"/>
<unzip dest="${forge.dir}/.." src="${download.dir}/${forge.filename}"/>
<!-- Install forge -->
<exec dir="${forge.dir}" executable="cmd" osfamily="windows">
<arg line="/c install.cmd"/>
</exec>
<exec dir="${forge.dir}" executable="sh" osfamily="unix">
<arg value="install.sh"/>
</exec>
<!-- Backup decompiled source for quick restore -->
<zip destfile="${forge.dir}/../${mcpsrc.backup}" basedir="${mcpsrc.dir}"/>
</target>
<!-- Restore the mcp src folder to pristine state -->
<target name="restore-mcp-src" depends="initialize-version" if="can-restore">
<echo message="Restoring MCP source"/>
<delete dir="${classes.dir}"/>
<delete dir="${jar.dir}"/>
<delete dir="${mcpsrc.dir}"/>
<mkdir dir="${mcpsrc.dir}"/>
<unzip dest="${mcpsrc.dir}" src="${forge.dir}/../${mcpsrc.backup}"/>
</target>
<!-- Main body of script handles everything that isn't conditional -->
<target name="main" depends="setup-forge,restore-mcp-src">
<echo message="Loading certificate fingerprint"/>
<loadfile property="fingerprint" srcFile="${sign.dir}/.fingerprint">
<filterchain>
<striplinebreaks/>
</filterchain>
</loadfile>
<!-- Copy mod source to mcp -->
<echo message="Copying source files"/>
<copy todir="${mcpsrc.dir}">
<fileset dir="${src.dir}/common">
</fileset>
<filterset>
<filter token="CERTIFICATE_SUM" value='*/ certificateFingerprint="${fingerprint}", /*'/>
<filter token="VERSION" value="${mymod.version.full}" />
<filter token="BUILD_NUMBER" value="${build.number}" />
</filterset>
</copy>
<!-- Recompile -->
<echo message="Compiling"/>
<exec dir="${mcp.dir}" executable="cmd" osfamily="windows">
<arg line="/c recompile.bat"/>
</exec>
<exec dir="${mcp.dir}" executable="sh" osfamily="unix">
<arg value="recompile.sh" />
</exec>
<!-- Reobf -->
<echo message="Reobfuscating with srg names"/>
<exec dir="${mcp.dir}" executable="cmd" osfamily="windows">
<arg line="/c reobfuscate_srg.bat"/>
</exec>
<exec dir="${mcp.dir}" executable="sh" osfamily="unix">
<arg value="reobfuscate_srg.sh" />
</exec>
<!-- Copy mod classes -->
<echo message="Copying compiled classes"/>
<copy todir="${classes.dir}">
<fileset dir="${mcp.dir}/reobf/minecraft">
</fileset>
</copy>
<!-- Copy common resources -->
<echo message="Copying common resources"/>
<copy todir="${classes.dir}">
<fileset dir="${res.dir}/common">
</fileset>
<filterset>
<filter token="VERSION" value="${mymod.version.full}" />
<filter token="BUILD_NUMBER" value="${build.number}" />
</filterset>
</copy>
<!-- Copy client resources -->
<echo message="Copying client resources"/>
<copy todir="${classes.dir}">
<fileset dir="${res.dir}/client">
</fileset>
</copy>
<!-- Copy documentation -->
<echo message="Copying documentation"/>
<copy todir="${classes.dir}">
<fileset file="${mod.dir}/LICENSE.txt">
</fileset>
<fileset file="${mod.dir}/README">
</fileset>
<filterset>
<filter token="VERSION" value="${mymod.version.full}" />
<filter token="BUILD_NUMBER" value="${build.number}" />
</filterset>
</copy>
<!-- Jar the files -->
<echo message="Loading key info"/>
<loadfile property="keypass" srcFile="${sign.dir}/.key"/>
<echo message="Creating jar file ${jar.dir}/${mod.name}-${mymod.version.full}.jar"/>
<jar destfile="${jar.dir}/${mod.name}-${mymod.version.full}.jar" basedir="${classes.dir}">
<manifest>
<attribute name="Built-By" value="Kaijin-Jenkins"/>
<attribute name="Implementation-Vendor" value="KaijinMods"/>
<attribute name="Implementation-Title" value="${env.JOB_NAME}"/>
<attribute name="Implementation-Version" value="${mymod.version.full}"/>
</manifest>
</jar>
<echo message="Signing jar file"/>
<signjar jar="${jar.dir}/${mod.name}-${mymod.version.full}.jar" alias="KaijinCraft" keystore="${sign.dir}/.keystore" storepass="${keypass}"/>
<!-- Finally, clear out the repo and class files for a fresh start next time -->
<echo message="Cleaning up"/>
<delete dir="${classes.dir}" deleteonexit="true"/>
<delete dir="${mod.dir}" deleteonexit="true"/>
</target>
</project>