From 76c6f0b6f90cb55019a35e816d6cf60df36742e7 Mon Sep 17 00:00:00 2001 From: md_5 Date: Fri, 27 Feb 2015 16:22:46 +1100 Subject: Check for required BuildTools version when building specific versions. --- src/main/java/org/spigotmc/builder/BuildInfo.java | 1 + src/main/java/org/spigotmc/builder/Builder.java | 26 ++++++++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/main/java/org/spigotmc/builder/BuildInfo.java b/src/main/java/org/spigotmc/builder/BuildInfo.java index 42fa7b3..e0500fc 100644 --- a/src/main/java/org/spigotmc/builder/BuildInfo.java +++ b/src/main/java/org/spigotmc/builder/BuildInfo.java @@ -10,6 +10,7 @@ public class BuildInfo private String name; private String description; + private int toolsVersion = -1; private Refs refs; @Data diff --git a/src/main/java/org/spigotmc/builder/Builder.java b/src/main/java/org/spigotmc/builder/Builder.java index 98042a6..20637f4 100644 --- a/src/main/java/org/spigotmc/builder/Builder.java +++ b/src/main/java/org/spigotmc/builder/Builder.java @@ -72,6 +72,24 @@ public class Builder public static void main(String[] args) throws Exception { + // May be null + String buildVersion = Builder.class.getPackage().getImplementationVersion(); + int buildNumber = -1; + if ( buildVersion != null ) + { + String[] split = buildVersion.split( "-" ); + if ( split.length == 4 ) + { + try + { + buildNumber = Integer.parseInt( split[3] ); + } catch ( NumberFormatException ex ) + { + } + } + } + System.out.println( "Loading BuildTools version: " + buildVersion + " (#" + buildNumber + ")" ); + OptionParser parser = new OptionParser(); OptionSpec disableCertFlag = parser.accepts( "disable-certificate-check" ); OptionSpec dontUpdateFlag = parser.accepts( "dont-update" ); @@ -172,7 +190,7 @@ public class Builder Git spigotGit = Git.open( spigot ); Git buildGit = Git.open( buildData ); - BuildInfo buildInfo = new BuildInfo( "Dev Build", "Development", new BuildInfo.Refs( "master", "master", "master", "master" ) ); + BuildInfo buildInfo = new BuildInfo( "Dev Build", "Development", 0, new BuildInfo.Refs( "master", "master", "master", "master" ) ); if ( !dontUpdate ) { @@ -194,6 +212,12 @@ public class Builder System.out.println( verInfo ); buildInfo = new Gson().fromJson( verInfo, BuildInfo.class ); + + if ( buildNumber != -1 && buildInfo.getToolsVersion() != -1 && buildNumber < buildInfo.getToolsVersion() ) + { + System.err.println( "**** Your BuildTools is out of date and will not build the requested version. Please grab a new copy from http://www.spigotmc.org/" ); + System.exit( 1 ); + } } pull( buildGit, buildInfo.getRefs().getBuildData() ); -- cgit v1.2.3