Search in sources :

Example 1 with Compiler

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;
}
Also used : AnalyzingCompiler(sbt.compiler.AnalyzingCompiler) Compiler(com.typesafe.zinc.Compiler) JavaCompiler(xsbti.compile.JavaCompiler) PersistentCache(org.gradle.cache.PersistentCache) Factory(org.gradle.internal.Factory) CacheRepository(org.gradle.cache.CacheRepository) Setup(com.typesafe.zinc.Setup) File(java.io.File)

Aggregations

Compiler (com.typesafe.zinc.Compiler)1 Setup (com.typesafe.zinc.Setup)1 File (java.io.File)1 CacheRepository (org.gradle.cache.CacheRepository)1 PersistentCache (org.gradle.cache.PersistentCache)1 Factory (org.gradle.internal.Factory)1 AnalyzingCompiler (sbt.compiler.AnalyzingCompiler)1 JavaCompiler (xsbti.compile.JavaCompiler)1