Java Code Examples for org.gradle.api.artifacts.Configuration#extendsFrom()
The following examples show how to use
org.gradle.api.artifacts.Configuration#extendsFrom() .
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: JavaBasePlugin.java From javaide with GNU General Public License v3.0 | 6 votes |
private void defineConfigurationsForSourceSet(SourceSet sourceSet, ConfigurationContainer configurations) { Configuration compileConfiguration = configurations.maybeCreate(sourceSet.getCompileConfigurationName()); compileConfiguration.setVisible(false); compileConfiguration.setDescription("Dependencies for " + sourceSet + "."); Configuration runtimeConfiguration = configurations.maybeCreate(sourceSet.getRuntimeConfigurationName()); runtimeConfiguration.setVisible(false); runtimeConfiguration.extendsFrom(compileConfiguration); runtimeConfiguration.setDescription("Runtime dependencies for " + sourceSet + "."); Configuration compileOnlyConfiguration = configurations.maybeCreate(sourceSet.getCompileOnlyConfigurationName()); compileOnlyConfiguration.setVisible(false); compileOnlyConfiguration.extendsFrom(compileConfiguration); compileOnlyConfiguration.setDescription("Compile dependencies for " + sourceSet + "."); Configuration compileClasspathConfiguration = configurations.maybeCreate(sourceSet.getCompileClasspathConfigurationName()); compileClasspathConfiguration.setVisible(false); compileClasspathConfiguration.extendsFrom(compileOnlyConfiguration); compileClasspathConfiguration.setDescription("Compile classpath for " + sourceSet + "."); sourceSet.setCompileClasspath(compileClasspathConfiguration); sourceSet.setRuntimeClasspath(sourceSet.getOutput().plus(runtimeConfiguration)); }
Example 2
Source File: PythonPlugin.java From pygradle with Apache License 2.0 | 6 votes |
private static void createConfigurations(Project project) { Configuration pythonConf = project.getConfigurations().create(CONFIGURATION_PYTHON.getValue()); /* * To resolve transitive dependencies, we need the 'default' configuration * to extend the 'python' configuration. This is because the source * configuration must match the configuration which the artifact is * published to (i.e., 'default' in our case). */ project.getConfigurations().getByName("default").extendsFrom(pythonConf); project.getConfigurations().create(CONFIGURATION_BOOTSTRAP_REQS.getValue()); project.getConfigurations().create(CONFIGURATION_SETUP_REQS.getValue()); Configuration buildReq = project.getConfigurations().create(CONFIGURATION_BUILD_REQS.getValue()); project.getConfigurations().create(CONFIGURATION_PYDOCS.getValue()); project.getConfigurations().create(CONFIGURATION_TEST.getValue()); project.getConfigurations().create(CONFIGURATION_VENV.getValue()); project.getConfigurations().create(CONFIGURATION_WHEEL.getValue()); // TODO: Kept for backwards compatibility. Remove when not needed (very soon). // Even though flake8 is no longer in its own virtual env, users may still be adding libraries through the // flake8 configuration, which still needs to be added to the build config so those libraries exist in the venv. Configuration flake8 = project.getConfigurations().create("flake8"); buildReq.extendsFrom(flake8); }
Example 3
Source File: DefaultDependencyHandler.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
private Dependency doAdd(Configuration configuration, Object dependencyNotation, Closure configureClosure) { if (dependencyNotation instanceof Configuration) { Configuration other = (Configuration) dependencyNotation; if (!configurationContainer.contains(other)) { throw new UnsupportedOperationException("Currently you can only declare dependencies on configurations from the same project."); } configuration.extendsFrom(other); return null; } Dependency dependency = create(dependencyNotation, configureClosure); configuration.getDependencies().add(dependency); return dependency; }
Example 4
Source File: JavaPlugin.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
void configureConfigurations(Project project) { ConfigurationContainer configurations = project.getConfigurations(); Configuration compileConfiguration = configurations.getByName(COMPILE_CONFIGURATION_NAME); Configuration runtimeConfiguration = configurations.getByName(RUNTIME_CONFIGURATION_NAME); Configuration compileTestsConfiguration = configurations.getByName(TEST_COMPILE_CONFIGURATION_NAME); compileTestsConfiguration.extendsFrom(compileConfiguration); configurations.getByName(TEST_RUNTIME_CONFIGURATION_NAME).extendsFrom(runtimeConfiguration, compileTestsConfiguration); configurations.getByName(Dependency.DEFAULT_CONFIGURATION).extendsFrom(runtimeConfiguration); }
Example 5
Source File: DefaultDependencyHandler.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
private Dependency doAdd(Configuration configuration, Object dependencyNotation, Closure configureClosure) { if (dependencyNotation instanceof Configuration) { Configuration other = (Configuration) dependencyNotation; if (!configurationContainer.contains(other)) { throw new UnsupportedOperationException("Currently you can only declare dependencies on configurations from the same project."); } configuration.extendsFrom(other); return null; } Dependency dependency = create(dependencyNotation, configureClosure); configuration.getDependencies().add(dependency); return dependency; }
Example 6
Source File: JavaPlugin.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
void configureConfigurations(Project project) { ConfigurationContainer configurations = project.getConfigurations(); Configuration compileConfiguration = configurations.getByName(COMPILE_CONFIGURATION_NAME); Configuration runtimeConfiguration = configurations.getByName(RUNTIME_CONFIGURATION_NAME); Configuration compileTestsConfiguration = configurations.getByName(TEST_COMPILE_CONFIGURATION_NAME); compileTestsConfiguration.extendsFrom(compileConfiguration); configurations.getByName(TEST_RUNTIME_CONFIGURATION_NAME).extendsFrom(runtimeConfiguration, compileTestsConfiguration); configurations.getByName(Dependency.DEFAULT_CONFIGURATION).extendsFrom(runtimeConfiguration); }
Example 7
Source File: DefaultDependencyHandler.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
private Dependency doAdd(Configuration configuration, Object dependencyNotation, Closure configureClosure) { if (dependencyNotation instanceof Configuration) { Configuration other = (Configuration) dependencyNotation; if (!configurationContainer.contains(other)) { throw new UnsupportedOperationException("Currently you can only declare dependencies on configurations from the same project."); } configuration.extendsFrom(other); return null; } Dependency dependency = create(dependencyNotation, configureClosure); configuration.getDependencies().add(dependency); return dependency; }
Example 8
Source File: JavaPlugin.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
void configureConfigurations(Project project) { ConfigurationContainer configurations = project.getConfigurations(); Configuration compileConfiguration = configurations.getByName(COMPILE_CONFIGURATION_NAME); Configuration runtimeConfiguration = configurations.getByName(RUNTIME_CONFIGURATION_NAME); Configuration compileTestsConfiguration = configurations.getByName(TEST_COMPILE_CONFIGURATION_NAME); compileTestsConfiguration.extendsFrom(compileConfiguration); configurations.getByName(TEST_RUNTIME_CONFIGURATION_NAME).extendsFrom(runtimeConfiguration, compileTestsConfiguration); configurations.getByName(Dependency.DEFAULT_CONFIGURATION).extendsFrom(runtimeConfiguration); }
Example 9
Source File: DefaultDependencyHandler.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
private Dependency doAdd(Configuration configuration, Object dependencyNotation, Closure configureClosure) { if (dependencyNotation instanceof Configuration) { Configuration other = (Configuration) dependencyNotation; if (!configurationContainer.contains(other)) { throw new UnsupportedOperationException("Currently you can only declare dependencies on configurations from the same project."); } configuration.extendsFrom(other); return null; } Dependency dependency = create(dependencyNotation, configureClosure); configuration.getDependencies().add(dependency); return dependency; }
Example 10
Source File: JavaPlugin.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
void configureConfigurations(Project project) { ConfigurationContainer configurations = project.getConfigurations(); Configuration compileConfiguration = configurations.getByName(COMPILE_CONFIGURATION_NAME); Configuration runtimeConfiguration = configurations.getByName(RUNTIME_CONFIGURATION_NAME); Configuration compileTestsConfiguration = configurations.getByName(TEST_COMPILE_CONFIGURATION_NAME); compileTestsConfiguration.extendsFrom(compileConfiguration); configurations.getByName(TEST_RUNTIME_CONFIGURATION_NAME).extendsFrom(runtimeConfiguration, compileTestsConfiguration); configurations.getByName(Dependency.DEFAULT_CONFIGURATION).extendsFrom(runtimeConfiguration); }
Example 11
Source File: NoHttpCheckstylePlugin.java From nohttp with Apache License 2.0 | 4 votes |
@Override public void apply(Project project) { this.project = project; this.extension = this.project.getExtensions().create(NOHTTP_EXTENSION_NAME, NoHttpExtension.class); this.extension.setToolVersion(NOHTTP_VERSION); this.extension.setSource(project.fileTree(project.getProjectDir(), new Action<ConfigurableFileTree>() { @Override public void execute(ConfigurableFileTree files) { String projectDir = project.getProjectDir().getAbsolutePath(); files.exclude(createBuildExclusion(projectDir, project)); project.subprojects(new Action<Project>() { @Override public void execute(Project p) { files.exclude(createBuildExclusion(projectDir, p)); } }); files.exclude(".git/**"); files.exclude(".gradle/**"); files.exclude("buildSrc/.gradle/**"); files.exclude(".idea/**"); files.exclude("**/*.class"); files.exclude("**/*.hprof"); files.exclude("**/*.jar"); files.exclude("**/*.jpg"); files.exclude("**/*.jks"); files.exclude("**/spring.handlers"); files.exclude("**/spring.schemas"); files.exclude("**/spring.tooling"); } })); File legacyWhiteListFile = project.file(LEGACY_WHITELIST_FILE_PATH); if (legacyWhiteListFile.exists()) { this.extension.setAllowlistFile(legacyWhiteListFile); } File defaultWhiteListFile = project.file(DEFAULT_WHITELIST_FILE_PATH); if (defaultWhiteListFile.exists()) { this.extension.setAllowlistFile(defaultWhiteListFile); } File allowlistFile = this.project.file(DEFAULT_ALLOWLIST_FILE_PATH); if (allowlistFile.exists()) { this.extension.setAllowlistFile(allowlistFile); } project.getPluginManager().apply(CheckstylePlugin.class); Configuration checkstyleConfiguration = project.getConfigurations().getByName(CHECKSTYLE_CONFIGURATION_NAME); Configuration noHttpConfiguration = project.getConfigurations().create(DEFAULT_CONFIGURATION_NAME); checkstyleConfiguration.extendsFrom(noHttpConfiguration); configureDefaultDependenciesForProject(noHttpConfiguration); createCheckstyleTaskForProject(checkstyleConfiguration); configureCheckTask(); }
Example 12
Source File: ClojureCommonPlugin.java From clojurephant with Apache License 2.0 | 4 votes |
private void configureDev(Project project, SourceSetContainer sourceSets) { SourceSet main = sourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME); SourceSet test = sourceSets.getByName(SourceSet.TEST_SOURCE_SET_NAME); SourceSet dev = sourceSets.create(DEV_SOURCE_SET_NAME); Configuration nrepl = project.getConfigurations().create(NREPL_CONFIGURATION_NAME); project.getDependencies().add(NREPL_CONFIGURATION_NAME, "nrepl:nrepl:0.6.0"); project.getConfigurations().getByName(dev.getCompileClasspathConfigurationName()).extendsFrom(nrepl); project.getConfigurations().getByName(dev.getRuntimeClasspathConfigurationName()).extendsFrom(nrepl); Function<SourceSet, FileCollection> nonClojureOutput = sourceSet -> { FileCollection allOutput = sourceSet.getOutput(); return allOutput.filter((File file) -> { return project.getTasks().stream() .filter(task -> task instanceof ClojureCompile || task instanceof ClojureScriptCompile || task instanceof ProcessResources) .allMatch(task -> !task.getOutputs().getFiles().contains(file)); }); }; dev.setCompileClasspath(project.files( test.getOutput(), main.getOutput(), project.getConfigurations().getByName(dev.getCompileClasspathConfigurationName()))); dev.setRuntimeClasspath(project.files( dev.getAllSource().getSourceDirectories(), nonClojureOutput.apply(dev), nonClojureOutput.apply(test), nonClojureOutput.apply(main), project.getConfigurations().getByName(dev.getRuntimeClasspathConfigurationName()))); Consumer<Function<SourceSet, String>> devExtendsTest = getConfName -> { Configuration devConf = project.getConfigurations().getByName(getConfName.apply(dev)); Configuration testConf = project.getConfigurations().getByName(getConfName.apply(test)); devConf.extendsFrom(testConf); }; devExtendsTest.accept(SourceSet::getImplementationConfigurationName); devExtendsTest.accept(SourceSet::getRuntimeOnlyConfigurationName); TaskProvider<ClojureNRepl> repl = project.getTasks().register(NREPL_TASK_NAME, ClojureNRepl.class, task -> { task.setGroup("run"); task.setDescription("Starts an nREPL server."); task.setClasspath(dev.getRuntimeClasspath()); }); // if you only ask for the REPL task, don't pre-compile/check the Clojure code (besides the dev one // for the user namespace) project.getGradle().getTaskGraph().whenReady(graph -> { // using this string concat approach to avoid realizing the task provider, if it's not needed if (!graph.hasTask(project.getPath() + NREPL_TASK_NAME)) { return; } Set<Task> selectedTasks = new HashSet<>(graph.getAllTasks()); Queue<Task> toProcess = new LinkedList<>(); toProcess.add(repl.get()); Set<Task> toDisable = new HashSet<>(); while (!toProcess.isEmpty()) { Task next = toProcess.remove(); selectedTasks.remove(next); if (next instanceof ClojureCompile || next instanceof ClojureScriptCompile) { toDisable.add(next); } else if (next instanceof ClojureCheck && !"checkDevClojure".equals(next.getName())) { toDisable.add(next); } graph.getDependencies(next).forEach(toProcess::add); } // if empty, only the REPL was requested to run, so we can optimize for that use case if (selectedTasks.isEmpty()) { toDisable.forEach(task -> task.setEnabled(false)); } }); }