Commits
Thinkofname authored and md_5 committed 47c51288b2d
56 56 | import org.eclipse.jgit.api.ResetCommand; |
57 57 | import org.eclipse.jgit.api.errors.GitAPIException; |
58 58 | import org.eclipse.jgit.revwalk.RevCommit; |
59 59 | |
60 60 | public class Builder |
61 61 | { |
62 62 | |
63 63 | public static final String LOG_FILE = "BuildTools.log.txt"; |
64 64 | public static final boolean IS_WINDOWS = System.getProperty( "os.name" ).startsWith( "Windows" ); |
65 65 | public static final File CWD = new File( "." ); |
66 - | public static final String MC_VERSION = "1.8"; |
67 66 | private static boolean dontUpdate; |
68 67 | private static boolean skipCompile; |
69 68 | private static boolean generateSource; |
70 69 | private static boolean generateDocs; |
71 70 | private static boolean dev; |
72 71 | |
73 72 | public static void main(String[] args) throws Exception |
74 73 | { |
75 74 | // May be null |
76 75 | String buildVersion = Builder.class.getPackage().getImplementationVersion(); |
219 218 | System.exit( 1 ); |
220 219 | } |
221 220 | } |
222 221 | |
223 222 | pull( buildGit, buildInfo.getRefs().getBuildData() ); |
224 223 | pull( bukkitGit, buildInfo.getRefs().getBukkit() ); |
225 224 | pull( craftBukkitGit, buildInfo.getRefs().getCraftBukkit() ); |
226 225 | pull( spigotGit, buildInfo.getRefs().getSpigot() ); |
227 226 | } |
228 227 | |
229 - | File vanillaJar = new File( workDir, "minecraft_server." + MC_VERSION + ".jar" ); |
228 + | VersionInfo versionInfo = new Gson().fromJson( |
229 + | Resources.toString( new File( "BuildData/info.json" ).toURI().toURL(), Charsets.UTF_8 ), |
230 + | VersionInfo.class |
231 + | ); |
232 + | // Default to 1.8 builds. |
233 + | if ( versionInfo == null ) |
234 + | { |
235 + | versionInfo = new VersionInfo( "1.8", "bukkit-1.8.at", "bukkit-1.8-cl.csrg", "bukkit-1.8-members.csrg", "package.srg" ); |
236 + | } |
237 + | System.out.println( "Attempting to build Minecraft with details: " + versionInfo ); |
238 + | |
239 + | File vanillaJar = new File( workDir, "minecraft_server." + versionInfo.getMinecraftVersion() + ".jar" ); |
230 240 | if ( !vanillaJar.exists() ) |
231 241 | { |
232 - | download( String.format( "https://s3.amazonaws.com/Minecraft.Download/versions/%1$s/minecraft_server.%1$s.jar", MC_VERSION ), vanillaJar ); |
242 + | download( String.format( "https://s3.amazonaws.com/Minecraft.Download/versions/%1$s/minecraft_server.%1$s.jar", versionInfo.getMinecraftVersion() ), vanillaJar ); |
233 243 | } |
234 244 | |
235 245 | Iterable<RevCommit> mappings = buildGit.log() |
236 - | .addPath( "mappings/bukkit-1.8.at" ) |
237 - | .addPath( "mappings/bukkit-1.8-cl.csrg" ) |
238 - | .addPath( "mappings/bukkit-1.8-members.csrg" ) |
239 - | .addPath( "mappings/package.srg" ) |
246 + | .addPath( "mappings/" + versionInfo.getAccessTransforms() ) |
247 + | .addPath( "mappings/" + versionInfo.getClassMappings() ) |
248 + | .addPath( "mappings/" + versionInfo.getMemberMappings() ) |
249 + | .addPath( "mappings/" + versionInfo.getPackageMappings() ) |
240 250 | .setMaxCount( 1 ).call(); |
241 251 | |
242 252 | Hasher mappingsHash = Hashing.md5().newHasher(); |
243 253 | for ( RevCommit rev : mappings ) |
244 254 | { |
245 255 | mappingsHash.putString( rev.getName(), Charsets.UTF_8 ); |
246 256 | } |
247 257 | String mappingsVersion = mappingsHash.hash().toString().substring( 24 ); // Last 8 chars |
248 258 | |
249 259 | File finalMappedJar = new File( workDir, "mapped." + mappingsVersion + ".jar" ); |
250 260 | if ( !finalMappedJar.exists() ) |
251 261 | { |
252 262 | System.out.println( "Final mapped jar: " + finalMappedJar + " does not exist, creating!" ); |
253 263 | |
254 264 | File clMappedJar = new File( finalMappedJar + "-cl" ); |
255 265 | File mMappedJar = new File( finalMappedJar + "-m" ); |
256 266 | |
257 - | runProcess( CWD, "java", "-jar", "BuildData/bin/SpecialSource-2.jar", "map", "-i", vanillaJar.getPath(), "-m", "BuildData/mappings/bukkit-1.8-cl.csrg", "-o", clMappedJar.getPath() ); |
267 + | runProcess( CWD, "java", "-jar", "BuildData/bin/SpecialSource-2.jar", "map", "-i", vanillaJar.getPath(), "-m", "BuildData/mappings/" + versionInfo.getClassMappings(), "-o", clMappedJar.getPath() ); |
258 268 | |
259 269 | runProcess( CWD, "java", "-jar", "BuildData/bin/SpecialSource-2.jar", "map", "-i", clMappedJar.getPath(), |
260 - | "-m", "BuildData/mappings/bukkit-1.8-members.csrg", "-o", mMappedJar.getPath() ); |
270 + | "-m", "BuildData/mappings/" + versionInfo.getMemberMappings(), "-o", mMappedJar.getPath() ); |
261 271 | |
262 - | runProcess( CWD, "java", "-jar", "BuildData/bin/SpecialSource.jar", "-i", mMappedJar.getPath(), "--access-transformer", "BuildData/mappings/bukkit-1.8.at", |
263 - | "-m", "BuildData/mappings/package.srg", "-o", finalMappedJar.getPath() ); |
272 + | runProcess( CWD, "java", "-jar", "BuildData/bin/SpecialSource.jar", "-i", mMappedJar.getPath(), "--access-transformer", "BuildData/mappings/" + versionInfo.getAccessTransforms(), |
273 + | "-m", "BuildData/mappings/" + versionInfo.getPackageMappings(), "-o", finalMappedJar.getPath() ); |
264 274 | } |
265 275 | |
266 276 | runProcess( CWD, "sh", mvn, "install:install-file", "-Dfile=" + finalMappedJar, "-Dpackaging=jar", "-DgroupId=org.spigotmc", |
267 - | "-DartifactId=minecraft-server", "-Dversion=1.8-SNAPSHOT" ); |
277 + | "-DartifactId=minecraft-server", "-Dversion=" + versionInfo.getMinecraftVersion() + "-SNAPSHOT" ); |
268 278 | |
269 279 | File decompileDir = new File( workDir, "decompile-" + mappingsVersion ); |
270 280 | if ( !decompileDir.exists() ) |
271 281 | { |
272 282 | decompileDir.mkdir(); |
273 283 | |
274 284 | File clazzDir = new File( decompileDir, "classes" ); |
275 285 | unzip( finalMappedJar, clazzDir, new Predicate<String>() |
276 286 | { |
277 287 | |
387 397 | System.err.println( "Error compiling Spigot, are you running this jar via msysgit?" ); |
388 398 | ex.printStackTrace(); |
389 399 | System.exit( 1 ); |
390 400 | } |
391 401 | |
392 402 | for ( int i = 0; i < 35; i++ ) |
393 403 | { |
394 404 | System.out.println( " " ); |
395 405 | } |
396 406 | System.out.println( "Success! Everything compiled successfully. Copying final .jar files now." ); |
397 - | copyJar( "CraftBukkit/target", "craftbukkit", "craftbukkit-" + MC_VERSION + ".jar" ); |
398 - | copyJar( "Spigot/Spigot-Server/target", "spigot", "spigot-" + MC_VERSION + ".jar" ); |
407 + | copyJar( "CraftBukkit/target", "craftbukkit", "craftbukkit-" + versionInfo.getMinecraftVersion() + ".jar" ); |
408 + | copyJar( "Spigot/Spigot-Server/target", "spigot", "spigot-" + versionInfo.getMinecraftVersion() + ".jar" ); |
399 409 | } |
400 410 | |
401 411 | public static final String get(String url) throws IOException |
402 412 | { |
403 413 | URLConnection con = new URL( url ).openConnection(); |
404 414 | con.setConnectTimeout( 5000 ); |
405 415 | con.setReadTimeout( 5000 ); |
406 416 | |
407 417 | InputStreamReader r = null; |
408 418 | try |