summaryrefslogtreecommitdiffstats
path: root/src/main/java/org
diff options
context:
space:
mode:
authorAntony Riley <antony@cyberiantiger.org>2014-12-12 11:21:43 +1100
committermd_5 <git@md-5.net>2014-12-12 11:21:43 +1100
commit7b889b881fe8d55b95f6b5950542bca90916470f (patch)
tree5fa55a91b6d779e4abd11ea822ae5c18d37c685c /src/main/java/org
parenta664e1f26301c38ad858faa769cc9f9d4555983c (diff)
downloadbuildtools-7b889b881fe8d55b95f6b5950542bca90916470f.tar
buildtools-7b889b881fe8d55b95f6b5950542bca90916470f.tar.gz
buildtools-7b889b881fe8d55b95f6b5950542bca90916470f.tar.lz
buildtools-7b889b881fe8d55b95f6b5950542bca90916470f.tar.xz
buildtools-7b889b881fe8d55b95f6b5950542bca90916470f.zip
Log output to BuildTools.log.txt
Conflicts: src/main/java/org/spigotmc/builder/Builder.java
Diffstat (limited to 'src/main/java/org')
-rw-r--r--src/main/java/org/spigotmc/builder/Builder.java107
1 files changed, 84 insertions, 23 deletions
diff --git a/src/main/java/org/spigotmc/builder/Builder.java b/src/main/java/org/spigotmc/builder/Builder.java
index f825ab3..3296b0e 100644
--- a/src/main/java/org/spigotmc/builder/Builder.java
+++ b/src/main/java/org/spigotmc/builder/Builder.java
@@ -11,9 +11,12 @@ import com.google.common.io.Files;
import com.google.common.io.Resources;
import difflib.DiffUtils;
import difflib.Patch;
+import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
+import java.io.FileDescriptor;
+import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.FilenameFilter;
@@ -25,6 +28,7 @@ import java.io.PrintStream;
import java.net.URL;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
+import java.security.SecureRandom;
import java.security.cert.X509Certificate;
import java.util.Arrays;
import java.util.Date;
@@ -40,6 +44,7 @@ import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import lombok.RequiredArgsConstructor;
import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.output.TeeOutputStream;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.ResetCommand;
import org.eclipse.jgit.api.errors.GitAPIException;
@@ -48,6 +53,7 @@ import org.eclipse.jgit.revwalk.RevCommit;
public class Builder
{
+ public static final String LOG_FILE = "BuildTools.log.txt";
public static final boolean IS_WINDOWS = System.getProperty( "os.name" ).startsWith( "Windows" );
public static final boolean IS_MAC = System.getProperty( "os.name" ).startsWith( "Mac" );
public static final File CWD = new File( "." );
@@ -68,6 +74,9 @@ public class Builder
dontUpdate = true;
}
}
+
+ logOutput();
+
if ( IS_MAC )
{
System.out.println( "Sorry, but Macintosh is not currently a supported platform for compilation at this time." );
@@ -299,18 +308,21 @@ public class Builder
System.exit( 1 );
}
- for ( int i = 0; i < 35; i++ ) System.out.println( " " );
+ for ( int i = 0; i < 35; i++ )
+ {
+ System.out.println( " " );
+ }
System.out.println( "Success! Everything compiled successfully. Copying final .jar files now." );
copyJar( "CraftBukkit/target", "craftbukkit", "craftbukkit-" + MC_VERSION + ".jar" );
copyJar( "Spigot/Spigot-Server/target", "spigot", "spigot-" + MC_VERSION + ".jar" );
}
- public static void copyJar( String path, final String jarPrefix, String outJarName ) throws Exception
+ public static void copyJar(String path, final String jarPrefix, String outJarName) throws Exception
{
File[] files = new File( path ).listFiles( new FilenameFilter()
{
@Override
- public boolean accept( File dir, String name )
+ public boolean accept(File dir, String name)
{
return name.startsWith( jarPrefix ) && name.endsWith( ".jar" );
}
@@ -480,39 +492,88 @@ public class Builder
return target;
}
- public static void disableHttpsCertificateCheck() {
+ public static void disableHttpsCertificateCheck()
+ {
// This globally disables certificate checking
// http://stackoverflow.com/questions/19723415/java-overriding-function-to-disable-ssl-certificate-check
try
{
- TrustManager[] trustAllCerts = new TrustManager[] {new X509TrustManager() {
- public java.security.cert.X509Certificate[] getAcceptedIssuers() {
- return null;
- }
- public void checkClientTrusted(X509Certificate[] certs, String authType) {
- }
- public void checkServerTrusted(X509Certificate[] certs, String authType) {
+ TrustManager[] trustAllCerts = new TrustManager[]
+ {
+ new X509TrustManager()
+ {
+ @Override
+ public java.security.cert.X509Certificate[] getAcceptedIssuers()
+ {
+ return null;
+ }
+
+ @Override
+ public void checkClientTrusted(X509Certificate[] certs, String authType)
+ {
+ }
+
+ @Override
+ public void checkServerTrusted(X509Certificate[] certs, String authType)
+ {
+ }
}
- }
};
- SSLContext sc = SSLContext.getInstance("SSL");
- sc.init(null, trustAllCerts, new java.security.SecureRandom());
- HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
-
- HostnameVerifier allHostsValid = new HostnameVerifier() {
- public boolean verify(String hostname, SSLSession session) {
+
+ // Trust SSL certs
+ SSLContext sc = SSLContext.getInstance( "SSL" );
+ sc.init( null, trustAllCerts, new SecureRandom() );
+ HttpsURLConnection.setDefaultSSLSocketFactory( sc.getSocketFactory() );
+
+ // Trust host names
+ HostnameVerifier allHostsValid = new HostnameVerifier()
+ {
+ @Override
+ public boolean verify(String hostname, SSLSession session)
+ {
return true;
}
};
- HttpsURLConnection.setDefaultHostnameVerifier(allHostsValid);
+ HttpsURLConnection.setDefaultHostnameVerifier( allHostsValid );
} catch ( NoSuchAlgorithmException ex )
{
- System.out.println("Failed to disable https certificate check");
- ex.printStackTrace(System.out);
+ System.out.println( "Failed to disable https certificate check" );
+ ex.printStackTrace( System.err );
} catch ( KeyManagementException ex )
{
- System.out.println("Failed to disable https certificate check");
- ex.printStackTrace(System.out);
+ System.out.println( "Failed to disable https certificate check" );
+ ex.printStackTrace( System.err );
+ }
+ }
+
+ public static void logOutput()
+ {
+ try
+ {
+ final OutputStream logOut = new BufferedOutputStream( new FileOutputStream( LOG_FILE ) );
+
+ Runtime.getRuntime().addShutdownHook( new Thread()
+ {
+ @Override
+ public void run()
+ {
+ System.setOut( new PrintStream( new FileOutputStream( FileDescriptor.out ) ) );
+ System.setErr( new PrintStream( new FileOutputStream( FileDescriptor.err ) ) );
+ try
+ {
+ logOut.close();
+ } catch ( IOException ex )
+ {
+ // We're shutting the jvm down anyway.
+ }
+ }
+ } );
+
+ System.setOut( new PrintStream( new TeeOutputStream( System.out, logOut ) ) );
+ System.setErr( new PrintStream( new TeeOutputStream( System.err, logOut ) ) );
+ } catch ( FileNotFoundException ex )
+ {
+ System.err.println( "Failed to create log file: " + LOG_FILE );
}
}
}