Source:
public void fetchArtifact(MavenJarArtifact artifact) { if (new File(localRepositoryDir, artifact.jarPath()).exists()) { return; } this.stagingRepositoryDir = Files.createTempDir(); this.stagingRepositoryDir.deleteOnExit(); createArtifactSubdirectory(artifact, stagingRepositoryDir); try { Futures.whenAllSucceed( fetchToStagingRepository(artifact.pomSha1Path()), fetchToStagingRepository(artifact.pomPath()), fetchToStagingRepository(artifact.jarSha1Path()), fetchToStagingRepository(artifact.jarPath())) .callAsync( () -> { createArtifactSubdirectory(artifact, localRepositoryDir); boolean pomValid = validateStagedFiles(artifact.pomPath(), artifact.pomSha1Path()); if (!pomValid) { throw new AssertionError("Unable to validate POM file"); } boolean jarValid = validateStagedFiles(artifact.jarPath(), artifact.jarSha1Path()); if (!jarValid) { throw new AssertionError("Unable to validate JAR file"); } commitFromStaging(artifact.pomPath()); commitFromStaging(artifact.jarPath()); commitFromStaging(artifact.jarSha1Path()); commitFromStaging(artifact.pomSha1Path()); removeArtifactFiles(stagingRepositoryDir, artifact); return Futures.immediateFuture(null); }, executorService) .get(); } catch (InterruptedException | ExecutionException e) { if (e instanceof InterruptedException) { Thread.currentThread().interrupt(); } removeArtifactFiles(stagingRepositoryDir, artifact); removeArtifactFiles(localRepositoryDir, artifact); throw new AssertionError("Failed to fetch maven artifacts", e); } }

Target:
public void fetchArtifact(MavenJarArtifact artifact) { if (new File(localRepositoryDir, artifact.jarPath()).exists()) { Logger.info(String.format("Found %s in local maven repository", artifact)); return; } this.stagingRepositoryDir = Files.createTempDir(); this.stagingRepositoryDir.deleteOnExit(); if (!createArtifactSubdirectory(artifact, stagingRepositoryDir)) { throw new AssertionError( "Unable to create artifact subdirectory in temp dir " + stagingRepositoryDir); } try { Futures.whenAllSucceed( fetchToStagingRepository(artifact.pomSha1Path()), fetchToStagingRepository(artifact.pomPath()), fetchToStagingRepository(artifact.jarSha1Path()), fetchToStagingRepository(artifact.jarPath())) .callAsync( () -> { if (new File(localRepositoryDir, artifact.jarPath()).exists()) { removeArtifactFiles(stagingRepositoryDir, artifact); return Futures.immediateFuture(null); } if (!createArtifactSubdirectory(artifact, localRepositoryDir)) { throw new IOException( "Unable to create artifact subdirectory in local maven repository " + localRepositoryDir); } boolean pomValid = validateStagedFiles(artifact.pomPath(), artifact.pomSha1Path()); if (!pomValid) { throw new AssertionError("SHA1 mismatch for POM file fetched in " + artifact); } boolean jarValid = validateStagedFiles(artifact.jarPath(), artifact.jarSha1Path()); if (!jarValid) { throw new AssertionError("SHA1 mismatch for JAR file fetched in " + artifact); } Logger.info( String.format( "Checksums validated, moving artifact %s to local maven directory", artifact)); commitFromStaging(artifact.pomPath()); commitFromStaging(artifact.jarPath()); commitFromStaging(artifact.jarSha1Path()); commitFromStaging(artifact.pomSha1Path()); removeArtifactFiles(stagingRepositoryDir, artifact); return Futures.immediateFuture(null); }, executorService) .get(); } catch (InterruptedException | ExecutionException e) { if (e instanceof InterruptedException) { Thread.currentThread().interrupt(); } removeArtifactFiles(stagingRepositoryDir, artifact); removeArtifactFiles(localRepositoryDir, artifact); Logger.error("Failed to fetch maven artifact " + artifact, e); throw new AssertionError("Failed to fetch maven artifact " + artifact, e); } }