use of com.typesafe.zinc.Setup in project gradle by gradle.
the class ZincScalaCompilerFactory method createParallelSafeCompiler.
static Compiler createParallelSafeCompiler(final Iterable<File> scalaClasspath, final Iterable<File> zincClasspath, final xsbti.Logger logger, File gradleUserHome) {
File zincCacheHomeDir = new File(System.getProperty(ZincScalaCompilerUtil.ZINC_CACHE_HOME_DIR_SYSTEM_PROPERTY, gradleUserHome.getAbsolutePath()));
CacheRepository cacheRepository = ZincCompilerServices.getInstance(zincCacheHomeDir).get(CacheRepository.class);
String zincVersion = Setup.zincVersion().published();
String zincCacheKey = String.format("zinc-%s", zincVersion);
String zincCacheName = String.format("Zinc %s compiler cache", zincVersion);
final PersistentCache zincCache = cacheRepository.cache(zincCacheKey).withDisplayName(zincCacheName).withLockOptions(mode(FileLockManager.LockMode.Exclusive)).open();
Compiler compiler;
try {
final File cacheDir = zincCache.getBaseDir();
final String userSuppliedZincDir = System.getProperty("zinc.dir");
if (userSuppliedZincDir != null && !userSuppliedZincDir.equals(cacheDir.getAbsolutePath())) {
LOGGER.warn(ZincScalaCompilerUtil.ZINC_DIR_IGNORED_MESSAGE);
}
compiler = SystemProperties.getInstance().withSystemProperty(ZincScalaCompilerUtil.ZINC_DIR_SYSTEM_PROPERTY, cacheDir.getAbsolutePath(), new Factory<Compiler>() {
@Override
public Compiler create() {
Setup zincSetup = createZincSetup(scalaClasspath, zincClasspath, logger);
return createCompiler(zincSetup, zincCache, logger);
}
});
} finally {
zincCache.close();
}
return compiler;
}
use of com.typesafe.zinc.Setup in project gradle by gradle.
the class ZincScalaCompilerFactory method createZincSetup.
private static Setup createZincSetup(Iterable<File> scalaClasspath, Iterable<File> zincClasspath, xsbti.Logger logger) {
ScalaLocation scalaLocation = ScalaLocation.fromPath(Lists.newArrayList(scalaClasspath));
SbtJars sbtJars = SbtJars.fromPath(Lists.newArrayList(zincClasspath));
Setup setup = Setup.create(scalaLocation, sbtJars, Jvm.current().getJavaHome(), true);
if (LOGGER.isDebugEnabled()) {
Setup.debug(setup, logger);
}
return setup;
}
Aggregations