Commits
md_5 authored 00c9da2167f
166 166 | } |
167 167 | |
168 168 | File buildData = new File( "BuildData" ); |
169 169 | if ( !buildData.exists() ) |
170 170 | { |
171 171 | clone( "https://hub.spigotmc.org/stash/scm/spigot/builddata.git", buildData ); |
172 172 | } |
173 173 | |
174 174 | File maven; |
175 175 | String m2Home = System.getenv( "M2_HOME" ); |
176 - | if ( m2Home == null || !(maven = new File(m2Home)).exists() ) |
176 + | if ( m2Home == null || !( maven = new File( m2Home ) ).exists() ) |
177 177 | { |
178 178 | maven = new File( "apache-maven-3.2.5" ); |
179 179 | |
180 180 | if ( !maven.exists() ) |
181 181 | { |
182 182 | System.out.println( "Maven does not exist, downloading. Please wait." ); |
183 183 | |
184 184 | File mvnTemp = new File( "mvn.zip" ); |
185 185 | mvnTemp.deleteOnExit(); |
186 186 | |
233 233 | pull( spigotGit, buildInfo.getRefs().getSpigot() ); |
234 234 | } |
235 235 | |
236 236 | VersionInfo versionInfo = new Gson().fromJson( |
237 237 | Resources.toString( new File( "BuildData/info.json" ).toURI().toURL(), Charsets.UTF_8 ), |
238 238 | VersionInfo.class |
239 239 | ); |
240 240 | // Default to 1.8 builds. |
241 241 | if ( versionInfo == null ) |
242 242 | { |
243 - | versionInfo = new VersionInfo( "1.8", "bukkit-1.8.at", "bukkit-1.8-cl.csrg", "bukkit-1.8-members.csrg", "package.srg" ); |
243 + | versionInfo = new VersionInfo( "1.8", "bukkit-1.8.at", "bukkit-1.8-cl.csrg", "bukkit-1.8-members.csrg", "package.srg", null ); |
244 244 | } |
245 245 | System.out.println( "Attempting to build Minecraft with details: " + versionInfo ); |
246 246 | |
247 247 | File vanillaJar = new File( workDir, "minecraft_server." + versionInfo.getMinecraftVersion() + ".jar" ); |
248 - | if ( !vanillaJar.exists() ) |
248 + | if ( !vanillaJar.exists() || !checkHash( vanillaJar, versionInfo ) ) |
249 249 | { |
250 250 | download( String.format( "https://s3.amazonaws.com/Minecraft.Download/versions/%1$s/minecraft_server.%1$s.jar", versionInfo.getMinecraftVersion() ), vanillaJar ); |
251 251 | } |
252 + | if ( !checkHash( vanillaJar, versionInfo ) ) |
253 + | { |
254 + | System.err.println( "**** Could not download clean Minecraft jar, giving up." ); |
255 + | return; |
256 + | } |
252 257 | |
253 258 | Iterable<RevCommit> mappings = buildGit.log() |
254 259 | .addPath( "mappings/" + versionInfo.getAccessTransforms() ) |
255 260 | .addPath( "mappings/" + versionInfo.getClassMappings() ) |
256 261 | .addPath( "mappings/" + versionInfo.getMemberMappings() ) |
257 262 | .addPath( "mappings/" + versionInfo.getPackageMappings() ) |
258 263 | .setMaxCount( 1 ).call(); |
259 264 | |
260 265 | Hasher mappingsHash = Hashing.md5().newHasher(); |
261 266 | for ( RevCommit rev : mappings ) |
413 418 | } |
414 419 | |
415 420 | if ( !skipCompile ) |
416 421 | { |
417 422 | System.out.println( "Success! Everything compiled successfully. Copying final .jar files now." ); |
418 423 | copyJar( "CraftBukkit/target", "craftbukkit", "craftbukkit-" + versionInfo.getMinecraftVersion() + ".jar" ); |
419 424 | copyJar( "Spigot/Spigot-Server/target", "spigot", "spigot-" + versionInfo.getMinecraftVersion() + ".jar" ); |
420 425 | } |
421 426 | } |
422 427 | |
428 + | private static boolean checkHash(File vanillaJar, VersionInfo versionInfo) throws IOException |
429 + | { |
430 + | String hash = Files.hash( vanillaJar, Hashing.md5() ).toString(); |
431 + | if ( !dev && versionInfo.getMinecraftHash() != null && !hash.equals( versionInfo.getMinecraftHash() ) ) |
432 + | { |
433 + | System.err.println( "**** Warning, Minecraft jar hash of " + hash + " does not match stored hash of " + versionInfo.getMinecraftHash() ); |
434 + | return false; |
435 + | } else |
436 + | { |
437 + | System.out.println( "Found good Minecraft hash (" + hash + ")" ); |
438 + | return true; |
439 + | } |
440 + | } |
441 + | |
423 442 | public static final String get(String url) throws IOException |
424 443 | { |
425 444 | URLConnection con = new URL( url ).openConnection(); |
426 445 | con.setConnectTimeout( 5000 ); |
427 446 | con.setReadTimeout( 5000 ); |
428 447 | |
429 448 | InputStreamReader r = null; |
430 449 | try |
431 450 | { |
432 451 | r = new InputStreamReader( con.getInputStream() ); |