From 609c14e728a43af2f55fbc22cce6a05d2c7ab082 Mon Sep 17 00:00:00 2001 From: md_5 Date: Sat, 18 Nov 2017 09:52:58 +1100 Subject: BUILDTOOLS-102: output-dir argument --- src/main/java/org/spigotmc/builder/Builder.java | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'src/main/java/org') 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 generateSourceFlag = parser.accepts( "generate-source" ); OptionSpec generateDocsFlag = parser.accepts( "generate-docs" ); OptionSpec devFlag = parser.accepts( "dev" ); + OptionSpec outputDir = parser.acceptsAll( Arrays.asList( "o", "output-dir" ) ).withRequiredArg().ofType( File.class ).defaultsTo( CWD ); OptionSpec 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 ); } } -- cgit v1.2.3