use of com.typesafe.zinc.Compiler 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;
}
Aggregations