Update dependencies + cleanup

This commit is contained in:
md_5 2021-11-23 11:17:18 +11:00
parent 60064b24ce
commit 3624ad4d1c
No known key found for this signature in database
GPG key ID: E8E901AC7C617C11
2 changed files with 22 additions and 76 deletions

View file

@ -34,7 +34,7 @@
<dependency> <dependency>
<groupId>com.google.guava</groupId> <groupId>com.google.guava</groupId>
<artifactId>guava</artifactId> <artifactId>guava</artifactId>
<version>21.0</version> <version>31.0.1-jre</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency> <dependency>
@ -46,7 +46,7 @@
<dependency> <dependency>
<groupId>org.eclipse.jgit</groupId> <groupId>org.eclipse.jgit</groupId>
<artifactId>org.eclipse.jgit</artifactId> <artifactId>org.eclipse.jgit</artifactId>
<version>5.8.0.202006091008-r</version> <version>5.13.0.202109080827-r</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency> <dependency>
@ -64,13 +64,13 @@
<dependency> <dependency>
<groupId>commons-io</groupId> <groupId>commons-io</groupId>
<artifactId>commons-io</artifactId> <artifactId>commons-io</artifactId>
<version>2.6</version> <version>2.11.0</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.google.code.gson</groupId> <groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId> <artifactId>gson</artifactId>
<version>2.8.6</version> <version>2.8.9</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
</dependencies> </dependencies>

View file

@ -23,7 +23,6 @@ import java.io.FileDescriptor;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.FileWriter; import java.io.FileWriter;
import java.io.FilenameFilter;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
@ -52,10 +51,8 @@ import java.util.function.Predicate;
import java.util.jar.JarFile; import java.util.jar.JarFile;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
import java.util.zip.ZipFile; import java.util.zip.ZipFile;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection; import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext; import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;
import javax.net.ssl.TrustManager; import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager; import javax.net.ssl.X509TrustManager;
import javax.swing.JFrame; import javax.swing.JFrame;
@ -479,7 +476,7 @@ public class Builder
mapUtil.loadBuk( classMappings ); mapUtil.loadBuk( classMappings );
if ( !memberMappings.exists() ) if ( !memberMappings.exists() )
{ {
memberMappings = new File( workDir, "bukkit-" + mappingsVersion + "-members.csrg" );; memberMappings = new File( workDir, "bukkit-" + mappingsVersion + "-members.csrg" );
mapUtil.makeFieldMaps( mojangMappings, memberMappings, true ); mapUtil.makeFieldMaps( mojangMappings, memberMappings, true );
runMaven( CWD, "install:install-file", "-Dfile=" + memberMappings, "-Dpackaging=csrg", "-DgroupId=org.spigotmc", runMaven( CWD, "install:install-file", "-Dfile=" + memberMappings, "-Dpackaging=csrg", "-DgroupId=org.spigotmc",
@ -541,15 +538,7 @@ public class Builder
decompileDir.mkdir(); decompileDir.mkdir();
File clazzDir = new File( decompileDir, "classes" ); File clazzDir = new File( decompileDir, "classes" );
unzip( finalMappedJar, clazzDir, new Predicate<String>() unzip( finalMappedJar, clazzDir, (input) -> input.startsWith( "net/minecraft" ) );
{
@Override
public boolean test(String input)
{
return input.startsWith( "net/minecraft" );
}
} );
if ( versionInfo.getDecompileCommand() == null ) if ( versionInfo.getDecompileCommand() == null )
{ {
versionInfo.setDecompileCommand( "java -jar BuildData/bin/fernflower.jar -dgs=1 -hdc=0 -rbr=0 -asc=1 -udv=0 {0} {1}" ); versionInfo.setDecompileCommand( "java -jar BuildData/bin/fernflower.jar -dgs=1 -hdc=0 -rbr=0 -asc=1 -udv=0 {0} {1}" );
@ -622,13 +611,14 @@ public class Builder
Patch parsedPatch = DiffUtils.parseUnifiedDiff( readFile ); Patch parsedPatch = DiffUtils.parseUnifiedDiff( readFile );
List<?> modifiedLines = DiffUtils.patch( Files.readLines( clean, Charsets.UTF_8 ), parsedPatch ); List<?> modifiedLines = DiffUtils.patch( Files.readLines( clean, Charsets.UTF_8 ), parsedPatch );
BufferedWriter bw = new BufferedWriter( new FileWriter( t ) ); try ( BufferedWriter bw = new BufferedWriter( new FileWriter( t ) ) )
for ( Object line : modifiedLines )
{ {
bw.write( (String) line ); for ( Object line : modifiedLines )
bw.newLine(); {
bw.write( (String) line );
bw.newLine();
}
} }
bw.close();
} catch ( Exception ex ) } catch ( Exception ex )
{ {
throw new RuntimeException( "Error patching " + relativeName, ex ); throw new RuntimeException( "Error patching " + relativeName, ex );
@ -780,31 +770,15 @@ public class Builder
con.setConnectTimeout( 5000 ); con.setConnectTimeout( 5000 );
con.setReadTimeout( 5000 ); con.setReadTimeout( 5000 );
InputStreamReader r = null; try ( InputStreamReader r = new InputStreamReader( con.getInputStream() ) )
try
{ {
r = new InputStreamReader( con.getInputStream() );
return CharStreams.toString( r ); return CharStreams.toString( r );
} finally
{
if ( r != null )
{
r.close();
}
} }
} }
public static void copyJar(String path, final String jarPrefix, final String jarSuffix, File outJar) throws Exception public static void copyJar(String path, final String jarPrefix, final String jarSuffix, File outJar) throws Exception
{ {
File[] files = new File( path ).listFiles( new FilenameFilter() File[] files = new File( path ).listFiles( (dir, name) -> name.startsWith( jarPrefix ) && name.endsWith( jarSuffix ) );
{
@Override
public boolean accept(File dir, String name)
{
return name.startsWith( jarPrefix ) && name.endsWith( jarSuffix );
}
} );
if ( !outJar.getParentFile().isDirectory() ) if ( !outJar.getParentFile().isDirectory() )
{ {
@ -848,7 +822,7 @@ public class Builder
public static int runMaven(File workDir, String... command) throws Exception public static int runMaven(File workDir, String... command) throws Exception
{ {
List<String> args = new LinkedList<String>(); List<String> args = new LinkedList<>();
if ( IS_WINDOWS ) if ( IS_WINDOWS )
{ {
@ -990,8 +964,7 @@ public class Builder
@Override @Override
public void run() public void run()
{ {
BufferedReader br = new BufferedReader( new InputStreamReader( in ) ); try ( BufferedReader br = new BufferedReader( new InputStreamReader( in ) ) )
try
{ {
String line; String line;
while ( ( line = br.readLine() ) != null ) while ( ( line = br.readLine() ) != null )
@ -1013,9 +986,7 @@ public class Builder
public static void unzip(File zipFile, File targetFolder, Predicate<String> filter) throws IOException public static void unzip(File zipFile, File targetFolder, Predicate<String> filter) throws IOException
{ {
targetFolder.mkdir(); targetFolder.mkdir();
ZipFile zip = new ZipFile( zipFile ); try ( ZipFile zip = new ZipFile( zipFile ) )
try
{ {
for ( Enumeration<? extends ZipEntry> entries = zip.entries(); entries.hasMoreElements(); ) for ( Enumeration<? extends ZipEntry> entries = zip.entries(); entries.hasMoreElements(); )
{ {
@ -1041,22 +1012,13 @@ public class Builder
outFile.getParentFile().mkdirs(); outFile.getParentFile().mkdirs();
} }
InputStream is = zip.getInputStream( entry ); try ( InputStream is = zip.getInputStream( entry ); OutputStream os = new FileOutputStream( outFile ); )
OutputStream os = new FileOutputStream( outFile );
try
{ {
ByteStreams.copy( is, os ); ByteStreams.copy( is, os );
} finally
{
is.close();
os.close();
} }
System.out.println( "Extracted: " + outFile ); System.out.println( "Extracted: " + outFile );
} }
} finally
{
zip.close();
} }
} }
@ -1064,9 +1026,7 @@ public class Builder
{ {
System.out.println( "Starting clone of " + url + " to " + target ); System.out.println( "Starting clone of " + url + " to " + target );
Git result = Git.cloneRepository().setURI( url ).setDirectory( target ).call(); try ( Git result = Git.cloneRepository().setURI( url ).setDirectory( target ).call() )
try
{ {
StoredConfig config = result.getRepository().getConfig(); StoredConfig config = result.getRepository().getConfig();
config.setBoolean( "core", null, "autocrlf", autocrlf ); config.setBoolean( "core", null, "autocrlf", autocrlf );
@ -1074,9 +1034,6 @@ public class Builder
didClone = true; didClone = true;
System.out.println( "Cloned git repository " + url + " to " + target.getAbsolutePath() + ". Current HEAD: " + commitHash( result ) ); System.out.println( "Cloned git repository " + url + " to " + target.getAbsolutePath() + ". Current HEAD: " + commitHash( result ) );
} finally
{
result.close();
} }
} }
@ -1150,20 +1107,8 @@ public class Builder
HttpsURLConnection.setDefaultSSLSocketFactory( sc.getSocketFactory() ); HttpsURLConnection.setDefaultSSLSocketFactory( sc.getSocketFactory() );
// Trust host names // Trust host names
HostnameVerifier allHostsValid = new HostnameVerifier() HttpsURLConnection.setDefaultHostnameVerifier( (hostname, session) -> true );
{ } catch ( NoSuchAlgorithmException | KeyManagementException ex )
@Override
public boolean verify(String hostname, SSLSession session)
{
return true;
}
};
HttpsURLConnection.setDefaultHostnameVerifier( allHostsValid );
} catch ( NoSuchAlgorithmException ex )
{
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" ); System.out.println( "Failed to disable https certificate check" );
ex.printStackTrace( System.err ); ex.printStackTrace( System.err );
@ -1214,6 +1159,7 @@ public class Builder
}, SHA1 }, SHA1
{ {
@Override @Override
@SuppressWarnings("deprecation")
public HashFunction getHash() public HashFunction getHash()
{ {
return Hashing.sha1(); return Hashing.sha1();