mirror of https://github.com/sbt/sbt.git
Add public method to get no-op global lock
This commit is contained in:
parent
025c4cef9a
commit
aa3527996f
|
|
@ -12,6 +12,7 @@ import xsbti.Logger;
|
||||||
import xsbti.compile.CompilerBridgeProvider;
|
import xsbti.compile.CompilerBridgeProvider;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.util.concurrent.Callable;
|
||||||
|
|
||||||
public final class ZincBridgeProvider {
|
public final class ZincBridgeProvider {
|
||||||
/**
|
/**
|
||||||
|
|
@ -46,6 +47,44 @@ public final class ZincBridgeProvider {
|
||||||
return ZincComponentCompiler$.MODULE$.getDefaultConfiguration(baseDirectory, ivyHome, resolvers, logger);
|
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.
|
||||||
|
* <p>
|
||||||
|
* This operation is necesary to invoke {@link ZincBridgeProvider#getProvider(File, GlobalLock, ComponentProvider, IvyConfiguration, Logger)}.
|
||||||
|
*
|
||||||
|
* @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;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a compiler bridge provider that allows the user to fetch Scala and a compiled bridge.
|
* Get a compiler bridge provider that allows the user to fetch Scala and a compiled bridge.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue