From 8aa3a224c30cbb9223aac5456c12ec22ff64fa5b Mon Sep 17 00:00:00 2001 From: md_5 Date: Fri, 10 Feb 2017 18:35:39 +1100 Subject: Add server URL reading and correct building outdated versions per BUILDTOOLS-305 --- src/main/java/org/spigotmc/builder/Builder.java | 20 +++++++++++++++++--- src/main/java/org/spigotmc/builder/VersionInfo.java | 12 ++++++++++++ 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/spigotmc/builder/Builder.java b/src/main/java/org/spigotmc/builder/Builder.java index 1ff6d78..a8eb0aa 100644 --- a/src/main/java/org/spigotmc/builder/Builder.java +++ b/src/main/java/org/spigotmc/builder/Builder.java @@ -74,6 +74,7 @@ public class Builder private static boolean generateSource; private static boolean generateDocs; private static boolean dev; + private static String applyPatchesShell = "sh"; public static void main(String[] args) throws Exception { @@ -259,7 +260,7 @@ public class Builder } VersionInfo versionInfo = new Gson().fromJson( - Resources.toString( new File( "BuildData/info.json" ).toURI().toURL(), Charsets.UTF_8 ), + Files.toString( new File( "BuildData/info.json" ), Charsets.UTF_8 ), VersionInfo.class ); // Default to 1.8 builds. @@ -272,7 +273,20 @@ public class Builder File vanillaJar = new File( workDir, "minecraft_server." + versionInfo.getMinecraftVersion() + ".jar" ); if ( !vanillaJar.exists() || !checkHash( vanillaJar, versionInfo ) ) { - download( String.format( "https://s3.amazonaws.com/Minecraft.Download/versions/%1$s/minecraft_server.%1$s.jar", versionInfo.getMinecraftVersion() ), vanillaJar ); + if ( versionInfo.getServerUrl() != null ) + { + download( versionInfo.getServerUrl(), vanillaJar ); + } else + { + download( String.format( "https://s3.amazonaws.com/Minecraft.Download/versions/%1$s/minecraft_server.%1$s.jar", versionInfo.getMinecraftVersion() ), vanillaJar ); + + // Legacy versions can also specify a specific shell to build with which has to be bash-compatible + applyPatchesShell = System.getenv().get( "SHELL" ); + if ( applyPatchesShell == null || applyPatchesShell.trim().isEmpty() ) + { + applyPatchesShell = "bash"; + } + } } if ( !checkHash( vanillaJar, versionInfo ) ) { @@ -426,7 +440,7 @@ public class Builder try { - runProcess( spigot, "sh", "applyPatches.sh" ); + runProcess( spigot, applyPatchesShell, "applyPatches.sh" ); System.out.println( "*** Spigot patches applied!" ); if ( !skipCompile ) diff --git a/src/main/java/org/spigotmc/builder/VersionInfo.java b/src/main/java/org/spigotmc/builder/VersionInfo.java index 65caace..b143403 100644 --- a/src/main/java/org/spigotmc/builder/VersionInfo.java +++ b/src/main/java/org/spigotmc/builder/VersionInfo.java @@ -13,6 +13,7 @@ public class VersionInfo private String packageMappings; private String minecraftHash; private String decompileCommand; + private String serverUrl; public VersionInfo(String minecraftVersion, String accessTransforms, String classMappings, String memberMappings, String packageMappings, String minecraftHash) { @@ -23,4 +24,15 @@ public class VersionInfo this.packageMappings = packageMappings; this.minecraftHash = minecraftHash; } + + public VersionInfo(String minecraftVersion, String accessTransforms, String classMappings, String memberMappings, String packageMappings, String minecraftHash, String decompileCommand) + { + this.minecraftVersion = minecraftVersion; + this.accessTransforms = accessTransforms; + this.classMappings = classMappings; + this.memberMappings = memberMappings; + this.packageMappings = packageMappings; + this.minecraftHash = minecraftHash; + this.decompileCommand = decompileCommand; + } } -- cgit v1.2.3