Package org.gradle.cache

Examples of org.gradle.cache.PersistentCache


        private <T extends Script> T loadViaCache(ClassLoader classLoader, Class<T> scriptBaseClass) {
            Map<String, Object> properties = new HashMap<String, Object>();
            properties.put("source.filename", source.getFileName());
            properties.put("source.hash", HashUtil.createHash(source.getResource().getText()));

            PersistentCache cache = cacheRepository.cache(String.format("scripts/%s", source.getClassName())).withProperties(properties).open();
            File classesDir;
            if (transformer != null) {
                String subdirName = String.format("%s_%s", transformer.getId(), scriptBaseClass.getSimpleName());
                classesDir = new File(cache.getBaseDir(), subdirName);
            } else {
                classesDir = new File(cache.getBaseDir(), scriptBaseClass.getSimpleName());
            }

            if (!cache.isValid() || !classesDir.exists()) {
                scriptCompilationHandler.compileToDir(source, classLoader, classesDir, transformer, scriptBaseClass);
                cache.markValid();
            }
            Class<? extends T> scriptClass = scriptCompilationHandler.loadFromDir(source, classLoader, classesDir,
                    scriptBaseClass);
            return scriptBaseClass.cast(ReflectionUtil.newInstance(scriptClass, new Object[0]));
        }
View Full Code Here


            return super.findClassPath(name);
        }

        synchronized (lock) {
            if (workerClassPath == null) {
                PersistentCache cache = cacheRepository.cache("workerMain").open();
                File classesDir = new File(cache.getBaseDir(), "classes");
                if (!cache.isValid()) {
                    for (Class<?> aClass : Arrays.asList(GradleWorkerMain.class, BootstrapClassLoaderWorker.class)) {
                        String fileName = aClass.getName().replace('.', '/') + ".class";
                        GFileUtils.copyURLToFile(WorkerProcessClassPathProvider.class.getClassLoader().getResource(fileName),
                                new File(classesDir, fileName));
                    }

                    cache.markValid();
                }

                workerClassPath = Collections.singleton(classesDir);
            }
            return workerClassPath;
View Full Code Here

        Map<String, Object> properties = new HashMap<String, Object>();
        properties.put("source.filename", source.getFileName());
        properties.put("source.hash", HashUtil.createCompactMD5(source.getResource().getText()));

        String cacheName = String.format("scripts/%s/%s/%s", source.getClassName(), scriptBaseClass.getSimpleName(), transformer.getId());
        PersistentCache cache = cacheRepository.cache(cacheName)
                .withProperties(properties)
                .withValidator(validator)
                .withDisplayName(String.format("%s class cache for %s", transformer.getId(), source.getDisplayName()))
                .withInitializer(new ProgressReportingInitializer(progressLoggerFactory, new CacheInitializer(source, classLoader, transformer, verifier, scriptBaseClass)))
                .open();
View Full Code Here

        }
        LOGGER.info("================================================" + " Start building buildSrc");

        // If we were not the most recent version of Gradle to build the buildSrc dir, then do a clean build
        // Otherwise, just to a regular build
        final PersistentCache buildSrcCache = createCache(startParameter);
        try {
            GradleLauncher gradleLauncher = buildGradleLauncher(startParameter);
            try {
                return buildSrcCache.useCache("rebuild buildSrc", new BuildSrcUpdateFactory(buildSrcCache, gradleLauncher, new BuildSrcBuildListenerFactory()));
            } finally {
                gradleLauncher.stop();
            }
        } finally {
            // This isn't quite right. We should not unlock the classes until we're finished with them, and the classes may be used across multiple builds
            buildSrcCache.close();
        }
    }
View Full Code Here

            HttpResourceAccessor accessor = new HttpResourceAccessor(http);
            PluginResolutionServiceClient httpClient = startParameter.isOffline()
                    ? new OfflinePluginResolutionServiceClient()
                    : new HttpPluginResolutionServiceClient(accessor);

            PersistentCache cache = cacheRepository
                    .cache(CACHE_NAME)
                    .withDisplayName("Plugin Resolution Cache")
                    .withLockOptions(mode(FileLockManager.LockMode.None))
                    .open();
View Full Code Here

TOP

Related Classes of org.gradle.cache.PersistentCache

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.