Java Code Examples for org.gradle.api.artifacts.Configuration#getFiles()
The following examples show how to use
org.gradle.api.artifacts.Configuration#getFiles() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DefaultPluginRequestApplicator.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
private void defineScriptHandlerClassScope(ScriptHandler scriptHandler, ClassLoaderScope classLoaderScope) { Configuration classpathConfiguration = scriptHandler.getConfigurations().getByName(ScriptHandler.CLASSPATH_CONFIGURATION); Set<File> files = classpathConfiguration.getFiles(); ClassPath classPath = new DefaultClassPath(files); classLoaderScope.export(classPath); classLoaderScope.lock(); }
Example 2
Source File: DependencyOrder.java From pygradle with Apache License 2.0 | 5 votes |
/** * Collects configuration files in post-order. * * @param configuration Gradle configuration to work with * @return set of files corresponding to post-order of dependency tree */ public static Collection<File> configurationPostOrderFiles(Configuration configuration) { Map<ModuleVersionIdentifier, File> idToFileMap = new HashMap<>(); Set<File> files = new LinkedHashSet<>(); Set<File> configurationFiles = configuration.getFiles(); // Create an id:file mapping. Set<ResolvedArtifact> artifacts = configuration.getResolvedConfiguration().getResolvedArtifacts(); for (ResolvedArtifact artifact : artifacts) { ModuleVersionIdentifier id = artifact.getModuleVersion().getId(); File file = artifact.getFile(); idToFileMap.put(id, file); } // Prepare an ordered set of files in post-order. for (ResolvedComponentResult d : configurationPostOrderDependencies(configuration)) { if (!idToFileMap.containsKey(d.getModuleVersion())) { logger.warn("***** WARNING Missing resolved artifact for " + d); } else { files.add(idToFileMap.get(d.getModuleVersion())); } } // Make sure the files set is a subset of configuration files. if (!configurationFiles.containsAll(files)) { throw new GradleException("Could not find matching dependencies for all configuration files"); } /* * Our rest.li generated packages will extend configuration and * will not appear in the resolved results. We are going to add * them at the end in the same order they were added to * configuration files. */ if (files.size() != configurationFiles.size()) { files.addAll(difference(configurationFiles, files)); } return files; }
Example 3
Source File: DefaultPluginRequestApplicator.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
private void defineScriptHandlerClassScope(ScriptHandler scriptHandler, ClassLoaderScope classLoaderScope) { Configuration classpathConfiguration = scriptHandler.getConfigurations().getByName(ScriptHandler.CLASSPATH_CONFIGURATION); Set<File> files = classpathConfiguration.getFiles(); ClassPath classPath = new DefaultClassPath(files); classLoaderScope.export(classPath); classLoaderScope.lock(); }
Example 4
Source File: DefaultScriptPluginFactory.java From pushfish-android with BSD 2-Clause "Simplified" License | 4 votes |
public void apply(final Object target) { DefaultServiceRegistry services = new DefaultServiceRegistry(); services.add(ScriptPluginFactory.class, DefaultScriptPluginFactory.this); services.add(ScriptHandlerFactory.class, scriptHandlerFactory); services.add(ClassLoaderScope.class, classLoaderScope); services.add(LoggingManagerInternal.class, loggingManagerFactory.create()); services.add(Instantiator.class, instantiator); services.add(ScriptHandler.class, scriptHandler); services.add(FileLookup.class, fileLookup); ScriptSource withImports = importsReader.withImports(scriptSource); List<PluginRequest> pluginRequests = new LinkedList<PluginRequest>(); if (target instanceof PluginAware) { services.add(PluginHandler.class, new DefaultPluginHandler(pluginRequests)); } else { services.add(PluginHandler.class, new NonPluggableTargetPluginHandler(target)); } ScriptCompiler compiler = scriptCompilerFactory.createCompiler(withImports); compiler.setClassloader(classLoaderScope.getBase().getChildClassLoader()); PluginsAndBuildscriptTransformer scriptBlockTransformer = new PluginsAndBuildscriptTransformer(classpathClosureName); StatementExtractingScriptTransformer classpathScriptTransformer = new StatementExtractingScriptTransformer(classpathClosureName, scriptBlockTransformer); compiler.setTransformer(classpathScriptTransformer); ScriptRunner<? extends BasicScript> classPathScriptRunner = compiler.compile(scriptType); classPathScriptRunner.getScript().init(target, services); classPathScriptRunner.run(); Configuration classpathConfiguration = scriptHandler.getConfigurations().getByName(ScriptHandler.CLASSPATH_CONFIGURATION); Set<File> files = classpathConfiguration.getFiles(); ClassPath classPath = new DefaultClassPath(files); ClassLoader exportedClassLoader = classLoaderScope.export(classPath); if (!pluginRequests.isEmpty()) { PluginResolver pluginResolver = pluginResolverFactory.createPluginResolver(exportedClassLoader); @SuppressWarnings("ConstantConditions") PluginResolutionApplicator resolutionApplicator = new PluginResolutionApplicator((PluginAware) target, classLoaderScope); PluginRequestApplicator requestApplicator = new PluginRequestApplicator(pluginResolver, resolutionApplicator); requestApplicator.applyPlugin(pluginRequests); } classLoaderScope.lock(); compiler.setClassloader(classLoaderScope.getScopeClassLoader()); compiler.setTransformer(new BuildScriptTransformer("no_" + classpathScriptTransformer.getId(), classpathScriptTransformer.invert())); ScriptRunner<? extends BasicScript> runner = compiler.compile(scriptType); BasicScript script = runner.getScript(); script.init(target, services); if (target instanceof ScriptAware) { ((ScriptAware) target).setScript(script); } runner.run(); }
Example 5
Source File: PrepareAPTask.java From atlas with Apache License 2.0 | 4 votes |
/** * Directory of so */ @TaskAction void generate() throws IOException, DocumentException { Project project = getProject(); File apBaseFile = null; File apFile = getApFile(); if (null != apFile && apFile.exists()) { apBaseFile = apFile; } else { String apDependency = getApDependency(); if (StringUtils.isNotBlank(apContext.getApDependency())) { Dependency dependency = project.getDependencies().create(apDependency); Configuration configuration = project.getConfigurations().detachedConfiguration(dependency); configuration.setTransitive(false); configuration.getResolutionStrategy().cacheChangingModulesFor(0, TimeUnit.MILLISECONDS); configuration.getResolutionStrategy().cacheDynamicVersionsFor(0, TimeUnit.MILLISECONDS); for (File file : configuration.getFiles()) { if (file.getName().endsWith(".ap")) { apBaseFile = file; break; } } } } if (null != apBaseFile && apBaseFile.exists()) { try { explodedDir = getExplodedDir(); BetterZip.unzipDirectory(apBaseFile, explodedDir); apContext.setApExploredFolder(explodedDir); Set<String> awbBundles = getAwbBundles(); if (awbBundles != null) { // Unzip the baseline Bundle for (String awbBundle : awbBundles) { File awbFile = BetterZip.extractFile(new File(explodedDir, AP_INLINE_APK_FILENAME), "lib/armeabi/" + awbBundle, new File(explodedDir, AP_INLINE_AWB_EXTRACT_DIRECTORY)); File awbExplodedDir = new File(new File(explodedDir, AP_INLINE_AWB_EXPLODED_DIRECTORY), FilenameUtils.getBaseName(awbBundle)); BetterZip.unzipDirectory(awbFile, awbExplodedDir); FileUtils.renameTo(new File(awbExplodedDir, FN_APK_CLASSES_DEX), new File(awbExplodedDir, "classes2.dex")); } // Preprocessing increment androidmanifest.xml ManifestFileUtils.updatePreProcessBaseManifestFile( FileUtils.join(explodedDir, "manifest-modify", ANDROID_MANIFEST_XML), new File(explodedDir, ANDROID_MANIFEST_XML)); } if (explodedDir.listFiles().length == 0){ throw new RuntimeException("unzip ap exception, no files found"); } }catch (Throwable e){ FileUtils.deleteIfExists(apBaseFile); throw new GradleException(e.getMessage(),e); } } }
Example 6
Source File: DefaultScriptPluginFactory.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
public void apply(final Object target) { DefaultServiceRegistry services = new DefaultServiceRegistry(); services.add(ScriptPluginFactory.class, DefaultScriptPluginFactory.this); services.add(ScriptHandlerFactory.class, scriptHandlerFactory); services.add(ClassLoaderScope.class, classLoaderScope); services.add(LoggingManagerInternal.class, loggingManagerFactory.create()); services.add(Instantiator.class, instantiator); services.add(ScriptHandler.class, scriptHandler); services.add(FileLookup.class, fileLookup); ScriptSource withImports = importsReader.withImports(scriptSource); List<PluginRequest> pluginRequests = new LinkedList<PluginRequest>(); if (target instanceof PluginAware) { services.add(PluginHandler.class, new DefaultPluginHandler(pluginRequests)); } else { services.add(PluginHandler.class, new NonPluggableTargetPluginHandler(target)); } ScriptCompiler compiler = scriptCompilerFactory.createCompiler(withImports); compiler.setClassloader(classLoaderScope.getBase().getChildClassLoader()); PluginsAndBuildscriptTransformer scriptBlockTransformer = new PluginsAndBuildscriptTransformer(classpathClosureName); StatementExtractingScriptTransformer classpathScriptTransformer = new StatementExtractingScriptTransformer(classpathClosureName, scriptBlockTransformer); compiler.setTransformer(classpathScriptTransformer); ScriptRunner<? extends BasicScript> classPathScriptRunner = compiler.compile(scriptType); classPathScriptRunner.getScript().init(target, services); classPathScriptRunner.run(); Configuration classpathConfiguration = scriptHandler.getConfigurations().getByName(ScriptHandler.CLASSPATH_CONFIGURATION); Set<File> files = classpathConfiguration.getFiles(); ClassPath classPath = new DefaultClassPath(files); ClassLoader exportedClassLoader = classLoaderScope.export(classPath); if (!pluginRequests.isEmpty()) { PluginResolver pluginResolver = pluginResolverFactory.createPluginResolver(exportedClassLoader); @SuppressWarnings("ConstantConditions") PluginResolutionApplicator resolutionApplicator = new PluginResolutionApplicator((PluginAware) target, classLoaderScope); PluginRequestApplicator requestApplicator = new PluginRequestApplicator(pluginResolver, resolutionApplicator); requestApplicator.applyPlugin(pluginRequests); } classLoaderScope.lock(); compiler.setClassloader(classLoaderScope.getScopeClassLoader()); compiler.setTransformer(new BuildScriptTransformer("no_" + classpathScriptTransformer.getId(), classpathScriptTransformer.invert())); ScriptRunner<? extends BasicScript> runner = compiler.compile(scriptType); BasicScript script = runner.getScript(); script.init(target, services); if (target instanceof ScriptAware) { ((ScriptAware) target).setScript(script); } runner.run(); }