Check for required BuildTools version when building specific versions.

This commit is contained in:
md_5 2015-02-27 16:22:46 +11:00
parent 9027b7f12a
commit 76c6f0b6f9
2 changed files with 26 additions and 1 deletions

View file

@ -10,6 +10,7 @@ public class BuildInfo
private String name;
private String description;
private int toolsVersion = -1;
private Refs refs;
@Data

View file

@ -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<Void> disableCertFlag = parser.accepts( "disable-certificate-check" );
OptionSpec<Void> 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() );