Commits
md_5 authored 609c14e728a
118 118 | } |
119 119 | System.out.println( "Loading BuildTools version: " + buildVersion + " (#" + buildNumber + ")" ); |
120 120 | |
121 121 | OptionParser parser = new OptionParser(); |
122 122 | OptionSpec<Void> disableCertFlag = parser.accepts( "disable-certificate-check" ); |
123 123 | OptionSpec<Void> dontUpdateFlag = parser.accepts( "dont-update" ); |
124 124 | OptionSpec<Void> skipCompileFlag = parser.accepts( "skip-compile" ); |
125 125 | OptionSpec<Void> generateSourceFlag = parser.accepts( "generate-source" ); |
126 126 | OptionSpec<Void> generateDocsFlag = parser.accepts( "generate-docs" ); |
127 127 | OptionSpec<Void> devFlag = parser.accepts( "dev" ); |
128 + | OptionSpec<File> outputDir = parser.acceptsAll( Arrays.asList( "o", "output-dir" ) ).withRequiredArg().ofType( File.class ).defaultsTo( CWD ); |
128 129 | OptionSpec<String> jenkinsVersion = parser.accepts( "rev" ).withRequiredArg().defaultsTo( "latest" ); |
129 130 | |
130 131 | OptionSet options = parser.parse( args ); |
131 132 | |
132 133 | if ( options.has( disableCertFlag ) ) |
133 134 | { |
134 135 | disableHttpsCertificateCheck(); |
135 136 | } |
136 137 | dontUpdate = options.has( dontUpdateFlag ); |
137 138 | skipCompile = options.has( skipCompileFlag ); |
489 490 | } |
490 491 | |
491 492 | for ( int i = 0; i < 35; i++ ) |
492 493 | { |
493 494 | System.out.println( " " ); |
494 495 | } |
495 496 | |
496 497 | if ( !skipCompile ) |
497 498 | { |
498 499 | System.out.println( "Success! Everything compiled successfully. Copying final .jar files now." ); |
499 - | copyJar( "CraftBukkit/target", "craftbukkit", "craftbukkit-" + versionInfo.getMinecraftVersion() + ".jar" ); |
500 - | copyJar( "Spigot/Spigot-Server/target", "spigot", "spigot-" + versionInfo.getMinecraftVersion() + ".jar" ); |
500 + | copyJar( "CraftBukkit/target", "craftbukkit", new File( outputDir.value( options ), "craftbukkit-" + versionInfo.getMinecraftVersion() + ".jar" ) ); |
501 + | copyJar( "Spigot/Spigot-Server/target", "spigot", new File( outputDir.value( options ), "spigot-" + versionInfo.getMinecraftVersion() + ".jar" ) ); |
501 502 | } |
502 503 | } |
503 504 | |
504 505 | private static boolean checkHash(File vanillaJar, VersionInfo versionInfo) throws IOException |
505 506 | { |
506 507 | String hash = Files.hash( vanillaJar, Hashing.md5() ).toString(); |
507 508 | if ( !dev && versionInfo.getMinecraftHash() != null && !hash.equals( versionInfo.getMinecraftHash() ) ) |
508 509 | { |
509 510 | System.err.println( "**** Warning, Minecraft jar hash of " + hash + " does not match stored hash of " + versionInfo.getMinecraftHash() ); |
510 511 | return false; |
529 530 | return CharStreams.toString( r ); |
530 531 | } finally |
531 532 | { |
532 533 | if ( r != null ) |
533 534 | { |
534 535 | r.close(); |
535 536 | } |
536 537 | } |
537 538 | } |
538 539 | |
539 - | public static void copyJar(String path, final String jarPrefix, String outJarName) throws Exception |
540 + | public static void copyJar(String path, final String jarPrefix, File outJar) throws Exception |
540 541 | { |
541 542 | File[] files = new File( path ).listFiles( new FilenameFilter() |
542 543 | { |
543 544 | |
544 545 | public boolean accept(File dir, String name) |
545 546 | { |
546 547 | return name.startsWith( jarPrefix ) && name.endsWith( ".jar" ); |
547 548 | } |
548 549 | } ); |
550 + | |
551 + | if ( !outJar.getParentFile().isDirectory() ) |
552 + | { |
553 + | outJar.getParentFile().mkdirs(); |
554 + | } |
555 + | |
549 556 | for ( File file : files ) |
550 557 | { |
551 - | System.out.println( "Copying " + file.getName() + " to " + CWD.getAbsolutePath() ); |
552 - | Files.copy( file, new File( CWD, outJarName ) ); |
553 - | System.out.println( " - Saved as " + outJarName ); |
558 + | System.out.println( "Copying " + file.getName() + " to " + outJar.getAbsolutePath() ); |
559 + | Files.copy( file, outJar ); |
560 + | System.out.println( " - Saved as " + outJar ); |
554 561 | } |
555 562 | } |
556 563 | |
557 564 | public static void pull(Git repo, String ref) throws Exception |
558 565 | { |
559 566 | System.out.println( "Pulling updates for " + repo.getRepository().getDirectory() ); |
560 567 | |
561 568 | repo.reset().setRef( "origin/master" ).setMode( ResetCommand.ResetType.HARD ).call(); |
562 569 | repo.fetch().call(); |
563 570 | |