mirror of https://github.com/sbt/sbt.git
Remove verbose Java global lock implementation
This commit is contained in:
parent
aa3527996f
commit
6d012abaf9
|
|
@ -47,20 +47,6 @@ public final class ZincBridgeProvider {
|
|||
return ZincComponentCompiler$.MODULE$.getDefaultConfiguration(baseDirectory, ivyHome, resolvers, logger);
|
||||
}
|
||||
|
||||
/**
|
||||
* Cast a CheckedException as an unchecked one.
|
||||
*
|
||||
* @param throwable to cast
|
||||
* @param <T> the type of the Throwable
|
||||
* @return this method will never return a Throwable instance, it will just throw it.
|
||||
* @throws T the throwable as an unchecked throwable
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private static <T extends Throwable> RuntimeException rethrow(Throwable throwable) throws T {
|
||||
throw (T) throwable; // rely on vacuous cast
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Defines a global lock that does nothing but calling the callable to synchronize
|
||||
* across threads. The lock file is used to resolve and download dependencies via ivy.
|
||||
|
|
@ -70,19 +56,7 @@ public final class ZincBridgeProvider {
|
|||
* @return A default global lock.
|
||||
*/
|
||||
public static GlobalLock getDefaultLock() {
|
||||
return new GlobalLock() {
|
||||
@Override
|
||||
public <T> T apply(File lockFile, Callable<T> run) {
|
||||
T value = null;
|
||||
try {
|
||||
value = run.call();
|
||||
} catch (Exception e) {
|
||||
// Rethrow runtime exception because apply does not define throwing Exception
|
||||
rethrow(e);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
};
|
||||
return ZincComponentCompiler$.MODULE$.getDefaultLock();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ package inc
|
|||
|
||||
import java.io.File
|
||||
import java.net.URLClassLoader
|
||||
import java.util.concurrent.Callable
|
||||
|
||||
import sbt.internal.inc.classpath.ClasspathUtilities
|
||||
import sbt.io.{ Hash, IO }
|
||||
|
|
@ -19,6 +20,7 @@ import sbt.internal.util.FullLogger
|
|||
import sbt.librarymanagement._
|
||||
import sbt.librarymanagement.syntax._
|
||||
import sbt.util.{ InterfaceUtil, Logger }
|
||||
import xsbti.GlobalLock
|
||||
import xsbti.compile.CompilerBridgeProvider
|
||||
|
||||
private[sbt] object ZincComponentCompiler {
|
||||
|
|
@ -145,6 +147,10 @@ private[sbt] object ZincComponentCompiler {
|
|||
FileRepository("local", Resolver.defaultFileConfiguration, finalPatterns)
|
||||
}
|
||||
|
||||
def getDefaultLock: GlobalLock = new GlobalLock {
|
||||
override def apply[T](file: File, callable: Callable[T]): T = callable.call()
|
||||
}
|
||||
|
||||
def getDefaultConfiguration(baseDirectory: File,
|
||||
ivyHome: File,
|
||||
resolvers0: Array[Resolver],
|
||||
|
|
|
|||
Loading…
Reference in New Issue