diff options
author | md_5 <git@md-5.net> | 2017-11-18 09:52:58 +1100 |
---|---|---|
committer | md_5 <git@md-5.net> | 2017-11-18 09:52:58 +1100 |
commit | 609c14e728a43af2f55fbc22cce6a05d2c7ab082 (patch) | |
tree | c45ec0258b2220769f5986658a049fd8d2e3246a /src/main/java/org/spigotmc/builder | |
parent | ab525c0a154f53750ac057f63bb1724cb2c98fad (diff) | |
download | buildtools-609c14e728a43af2f55fbc22cce6a05d2c7ab082.tar buildtools-609c14e728a43af2f55fbc22cce6a05d2c7ab082.tar.gz buildtools-609c14e728a43af2f55fbc22cce6a05d2c7ab082.tar.lz buildtools-609c14e728a43af2f55fbc22cce6a05d2c7ab082.tar.xz buildtools-609c14e728a43af2f55fbc22cce6a05d2c7ab082.zip |
BUILDTOOLS-102: output-dir argument
Diffstat (limited to 'src/main/java/org/spigotmc/builder')
-rw-r--r-- | src/main/java/org/spigotmc/builder/Builder.java | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/src/main/java/org/spigotmc/builder/Builder.java b/src/main/java/org/spigotmc/builder/Builder.java index c11c47a..c0abc8f 100644 --- a/src/main/java/org/spigotmc/builder/Builder.java +++ b/src/main/java/org/spigotmc/builder/Builder.java @@ -125,6 +125,7 @@ public class Builder OptionSpec<Void> generateSourceFlag = parser.accepts( "generate-source" ); OptionSpec<Void> generateDocsFlag = parser.accepts( "generate-docs" ); OptionSpec<Void> devFlag = parser.accepts( "dev" ); + OptionSpec<File> outputDir = parser.acceptsAll( Arrays.asList( "o", "output-dir" ) ).withRequiredArg().ofType( File.class ).defaultsTo( CWD ); OptionSpec<String> jenkinsVersion = parser.accepts( "rev" ).withRequiredArg().defaultsTo( "latest" ); OptionSet options = parser.parse( args ); @@ -496,8 +497,8 @@ public class Builder if ( !skipCompile ) { System.out.println( "Success! Everything compiled successfully. Copying final .jar files now." ); - copyJar( "CraftBukkit/target", "craftbukkit", "craftbukkit-" + versionInfo.getMinecraftVersion() + ".jar" ); - copyJar( "Spigot/Spigot-Server/target", "spigot", "spigot-" + versionInfo.getMinecraftVersion() + ".jar" ); + copyJar( "CraftBukkit/target", "craftbukkit", new File( outputDir.value( options ), "craftbukkit-" + versionInfo.getMinecraftVersion() + ".jar" ) ); + copyJar( "Spigot/Spigot-Server/target", "spigot", new File( outputDir.value( options ), "spigot-" + versionInfo.getMinecraftVersion() + ".jar" ) ); } } @@ -536,7 +537,7 @@ public class Builder } } - public static void copyJar(String path, final String jarPrefix, String outJarName) throws Exception + public static void copyJar(String path, final String jarPrefix, File outJar) throws Exception { File[] files = new File( path ).listFiles( new FilenameFilter() { @@ -546,11 +547,17 @@ public class Builder return name.startsWith( jarPrefix ) && name.endsWith( ".jar" ); } } ); + + if ( !outJar.getParentFile().isDirectory() ) + { + outJar.getParentFile().mkdirs(); + } + for ( File file : files ) { - System.out.println( "Copying " + file.getName() + " to " + CWD.getAbsolutePath() ); - Files.copy( file, new File( CWD, outJarName ) ); - System.out.println( " - Saved as " + outJarName ); + System.out.println( "Copying " + file.getName() + " to " + outJar.getAbsolutePath() ); + Files.copy( file, outJar ); + System.out.println( " - Saved as " + outJar ); } } |