org.gradle.api.artifacts.Configuration Java Examples
The following examples show how to use
org.gradle.api.artifacts.Configuration.
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: DefaultDependencyHandler.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
public Object methodMissing(String name, Object args) { Object[] argsArray = (Object[]) args; Configuration configuration = configurationContainer.findByName(name); if (configuration == null) { throw new MissingMethodException(name, this.getClass(), argsArray); } List<?> normalizedArgs = CollectionUtils.flattenCollections(argsArray); if (normalizedArgs.size() == 2 && normalizedArgs.get(1) instanceof Closure) { return doAdd(configuration, normalizedArgs.get(0), (Closure) normalizedArgs.get(1)); } else if (normalizedArgs.size() == 1) { return doAdd(configuration, normalizedArgs.get(0), null); } else { for (Object arg : normalizedArgs) { doAdd(configuration, arg, null); } return null; } }
Example #2
Source File: SonarRunnerPlugin.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
private void addConfiguration(final Project project, final SonarRunnerRootExtension rootExtension) { final Configuration configuration = project.getConfigurations().create(SonarRunnerExtension.SONAR_RUNNER_CONFIGURATION_NAME); configuration .setVisible(false) .setTransitive(false) .setDescription("The SonarRunner configuration to use to run analysis") .getIncoming() .beforeResolve(new Action<ResolvableDependencies>() { public void execute(ResolvableDependencies resolvableDependencies) { DependencySet dependencies = resolvableDependencies.getDependencies(); if (dependencies.isEmpty()) { String toolVersion = rootExtension.getToolVersion(); DependencyHandler dependencyHandler = project.getDependencies(); Dependency dependency = dependencyHandler.create("org.codehaus.sonar.runner:sonar-runner-dist:" + toolVersion); configuration.getDependencies().add(dependency); } } }); }
Example #3
Source File: CppPublicMacrosPlugin.java From native-samples with Apache License 2.0 | 6 votes |
private static Configuration createConfiguration(ConfigurationContainer configurations, ObjectFactory objectFactory) { return configurations.create("cppPublicMacros", new Action<Configuration>() { @Override public void execute(Configuration configuration) { configurations.all(new Action<Configuration>() { @Override public void execute(Configuration it) { if (it.getName().toLowerCase().endsWith("implementation")) { configuration.extendsFrom(it); } } }); configuration.setCanBeConsumed(false); configuration.setCanBeResolved(true); configuration.getAttributes().attribute(Usage.USAGE_ATTRIBUTE, objectFactory.named(Usage.class, "cpp-public-macros")); } }); }
Example #4
Source File: SonarRunnerPlugin.java From pushfish-android with BSD 2-Clause "Simplified" License | 6 votes |
private void addConfiguration(final Project project, final SonarRunnerRootExtension rootExtension) { final Configuration configuration = project.getConfigurations().create(SonarRunnerExtension.SONAR_RUNNER_CONFIGURATION_NAME); configuration .setVisible(false) .setTransitive(false) .setDescription("The SonarRunner configuration to use to run analysis") .getIncoming() .beforeResolve(new Action<ResolvableDependencies>() { public void execute(ResolvableDependencies resolvableDependencies) { DependencySet dependencies = resolvableDependencies.getDependencies(); if (dependencies.isEmpty()) { String toolVersion = rootExtension.getToolVersion(); DependencyHandler dependencyHandler = project.getDependencies(); Dependency dependency = dependencyHandler.create("org.codehaus.sonar.runner:sonar-runner-dist:" + toolVersion); configuration.getDependencies().add(dependency); } } }); }
Example #5
Source File: IdeaDependenciesProvider.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
private boolean isMappedToIdeaScope(final Configuration configuration, IdeaModule ideaModule) { Iterable<IdeaScopeMappingRule> rules = Iterables.concat(scopeMappings.values()); boolean matchesRule = Iterables.any(rules, new Predicate<IdeaScopeMappingRule>() { public boolean apply(IdeaScopeMappingRule ideaScopeMappingRule) { return ideaScopeMappingRule.configurationNames.contains(configuration.getName()); } }); if (matchesRule) { return true; } for (Map<String, Collection<Configuration>> scopeMap : ideaModule.getScopes().values()) { Iterable<Configuration> configurations = Iterables.concat(scopeMap.values()); if (Iterables.any(configurations, Predicates.equalTo(configuration))) { return true; } } return false; }
Example #6
Source File: IdeaDependenciesProvider.java From pushfish-android with BSD 2-Clause "Simplified" License | 6 votes |
private boolean isMappedToIdeaScope(final Configuration configuration, IdeaModule ideaModule) { Iterable<IdeaScopeMappingRule> rules = Iterables.concat(scopeMappings.values()); boolean matchesRule = Iterables.any(rules, new Predicate<IdeaScopeMappingRule>() { public boolean apply(IdeaScopeMappingRule ideaScopeMappingRule) { return ideaScopeMappingRule.configurationNames.contains(configuration.getName()); } }); if (matchesRule) { return true; } for (Map<String, Collection<Configuration>> scopeMap : ideaModule.getScopes().values()) { Iterable<Configuration> configurations = Iterables.concat(scopeMap.values()); if (Iterables.any(configurations, Predicates.equalTo(configuration))) { return true; } } return false; }
Example #7
Source File: IdeDependenciesExtractor.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
public Collection<IdeExtendedRepoFileDependency> extractRepoFileDependencies(DependencyHandler dependencyHandler, Collection<Configuration> plusConfigurations, Collection<Configuration> minusConfigurations, boolean downloadSources, boolean downloadJavadoc) { // can have multiple IDE dependencies with same component identifier (see GRADLE-1622) Multimap<ComponentIdentifier, IdeExtendedRepoFileDependency> resolvedDependenciesComponentMap = LinkedHashMultimap.create(); for (IdeExtendedRepoFileDependency dep : resolvedExternalDependencies(plusConfigurations, minusConfigurations)) { resolvedDependenciesComponentMap.put(toComponentIdentifier(dep.getId()), dep); } List<Class<? extends Artifact>> artifactTypes = new ArrayList<Class<? extends Artifact>>(2); if (downloadSources) { artifactTypes.add(SourcesArtifact.class); } if (downloadJavadoc) { artifactTypes.add(JavadocArtifact.class); } downloadAuxiliaryArtifacts(dependencyHandler, resolvedDependenciesComponentMap, artifactTypes); Collection<UnresolvedIdeRepoFileDependency> unresolvedDependencies = unresolvedExternalDependencies(plusConfigurations, minusConfigurations); Collection<IdeExtendedRepoFileDependency> resolvedDependencies = resolvedDependenciesComponentMap.values(); Collection<IdeExtendedRepoFileDependency> resolvedAndUnresolved = new ArrayList<IdeExtendedRepoFileDependency>(unresolvedDependencies.size() + resolvedDependencies.size()); resolvedAndUnresolved.addAll(resolvedDependencies); resolvedAndUnresolved.addAll(unresolvedDependencies); return resolvedAndUnresolved; }
Example #8
Source File: AsciiDependencyReportRenderer.java From pushfish-android with BSD 2-Clause "Simplified" License | 6 votes |
public void startConfiguration(final Configuration configuration) { if (hasConfigs) { getTextOutput().println(); } hasConfigs = true; GraphRenderer renderer = new GraphRenderer(getTextOutput()); renderer.visit(new Action<StyledTextOutput>() { public void execute(StyledTextOutput styledTextOutput) { getTextOutput().withStyle(Identifier).text(configuration.getName()); getTextOutput().withStyle(Description).text(getDescription(configuration)); } }, true); NodeRenderer nodeRenderer = new SimpleNodeRenderer(); dependencyGraphRenderer = new DependencyGraphRenderer(renderer, nodeRenderer); }
Example #9
Source File: AsciiDependencyReportRenderer.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
public void startConfiguration(final Configuration configuration) { if (hasConfigs) { getTextOutput().println(); } hasConfigs = true; GraphRenderer renderer = new GraphRenderer(getTextOutput()); renderer.visit(new Action<StyledTextOutput>() { public void execute(StyledTextOutput styledTextOutput) { getTextOutput().withStyle(Identifier).text(configuration.getName()); getTextOutput().withStyle(Description).text(getDescription(configuration)); } }, true); NodeRenderer nodeRenderer = new SimpleNodeRenderer(); dependencyGraphRenderer = new DependencyGraphRenderer(renderer, nodeRenderer); }
Example #10
Source File: DependenciesSettings.java From gradle-golang-plugin with Mozilla Public License 2.0 | 5 votes |
@Nonnull protected Dependency doAdd(@Nonnull String configurationName, @Nonnull Dependency dependency, @Nullable Closure<?> configureWith) { if (!_root) { throw new IllegalStateException("Adding of dependencies for golang is currently not support at task level."); } final Configuration configuration = _project.getConfigurations().getByName(configurationName); configuration.getDependencies().add(dependency); if (configureWith != null) { return configure(configureWith, dependency); } return dependency; }
Example #11
Source File: VariantHelper.java From javaide with GNU General Public License v3.0 | 5 votes |
/** * Build a set of configuration containing all the Configuration object that a given * configuration extends from, directly or transitively. * * @param configuration the configuration * @return a set of config. */ private static Set<Configuration> flattenConfigurations(@NonNull Configuration configuration) { Set<Configuration> configs = Sets.newHashSet(); configs.add(configuration); for (Configuration extend : configuration.getExtendsFrom()) { configs.addAll(flattenConfigurations(extend)); } return configs; }
Example #12
Source File: ResolveLocalComponentFactory.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public MutableLocalComponentMetaData convert(Set<? extends Configuration> configurations, ModuleInternal module) { assert configurations.size() > 0 : "No configurations found for module: " + module.getName() + ". Configure them or apply a plugin that does it."; DefaultModuleDescriptor moduleDescriptor = new DefaultModuleDescriptor(IvyUtil.createModuleRevisionId(module), module.getStatus(), null); moduleDescriptor.addExtraAttributeNamespace(IVY_MAVEN_NAMESPACE_PREFIX, IVY_MAVEN_NAMESPACE); ComponentIdentifier componentIdentifier = componentIdentifierFactory.createComponentIdentifier(module); DefaultLocalComponentMetaData metaData = new DefaultLocalComponentMetaData(moduleDescriptor, componentIdentifier); configurationsToModuleDescriptorConverter.addConfigurations(metaData, configurations); dependenciesToModuleDescriptorConverter.addDependencyDescriptors(metaData, configurations); configurationsToArtifactsConverter.addArtifacts(metaData, configurations); return metaData; }
Example #13
Source File: IvyBackedArtifactPublisher.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
public void publish(final Iterable<? extends PublicationAwareRepository> repositories, final ModuleInternal module, final Configuration configuration, final File descriptor) throws PublishException { ivyContextManager.withIvy(new Action<Ivy>() { public void execute(Ivy ivy) { Set<Configuration> allConfigurations = configuration.getAll(); Set<Configuration> configurationsToPublish = configuration.getHierarchy(); MutableLocalComponentMetaData componentMetaData = publishLocalComponentFactory.convert(allConfigurations, module); if (descriptor != null) { ModuleDescriptor moduleDescriptor = componentMetaData.getModuleDescriptor(); ivyModuleDescriptorWriter.write(moduleDescriptor, descriptor); } // Need to convert a second time, to determine which artifacts to publish (and yes, this isn't a great way to do things...) componentMetaData = publishLocalComponentFactory.convert(configurationsToPublish, module); BuildableIvyModulePublishMetaData publishMetaData = componentMetaData.toPublishMetaData(); if (descriptor != null) { Artifact artifact = MDArtifact.newIvyArtifact(componentMetaData.getModuleDescriptor()); publishMetaData.addArtifact(artifact, descriptor); } List<ModuleVersionPublisher> publishResolvers = new ArrayList<ModuleVersionPublisher>(); for (PublicationAwareRepository repository : repositories) { ModuleVersionPublisher publisher = repository.createPublisher(); publishResolvers.add(publisher); } dependencyPublisher.publish(publishResolvers, publishMetaData); } }); }
Example #14
Source File: WrappedNativeLibraryPlugin.java From native-samples with Apache License 2.0 | 5 votes |
public DefaultMainPublication(Provider<String> baseName, Usage apiUsage, Configuration api, ImmutableAttributesFactory immutableAttributesFactory, ObjectFactory objectFactory) { this.baseName = baseName; AttributeContainer publicationAttributes = immutableAttributesFactory.mutable(); publicationAttributes.attribute(Usage.USAGE_ATTRIBUTE, apiUsage); publicationAttributes.attribute(ArtifactAttributes.ARTIFACT_FORMAT, ZIP_TYPE); this.mainVariant = new MainLibraryVariant("api", apiUsage, api, publicationAttributes, objectFactory); }
Example #15
Source File: RetrolambdaExec.java From javafxmobile-plugin with BSD 3-Clause "New" or "Revised" License | 5 votes |
private static VersionNumber retrolambdaVersion(Configuration retrolambdaConfig) { retrolambdaConfig.resolve(); Dependency retrolambdaDep = retrolambdaConfig.getDependencies().iterator().next(); if (retrolambdaDep.getVersion() == null) { // Don't know version return null; } return VersionNumber.parse(retrolambdaDep.getVersion()); }
Example #16
Source File: DependencyTaskTest.java From play-services-plugins with Apache License 2.0 | 5 votes |
@Test public void testIsTest_fromHierarchy() { Configuration configuration = mock(Configuration.class); when(configuration.getName()).thenReturn("random"); Configuration parent = mock(Configuration.class); when(parent.getName()).thenReturn("testCompile"); Set<Configuration> hierarchy = new HashSet<>(); hierarchy.add(parent); when(configuration.getHierarchy()).thenReturn(hierarchy); assertTrue(dependencyTask.isTest(configuration)); }
Example #17
Source File: CpdPluginTest.java From gradle-cpd-plugin with Apache License 2.0 | 5 votes |
@Test void CpdPlugin_shouldAllowConfigureToolDependenciesExplicitlyViaToolVersionProperty(Project project, Configuration cpdConfiguration, CpdExtension cpd, TaskProvider<Cpd> cpdCheck) { // Given: project.getRepositories().mavenLocal(); project.getRepositories().mavenCentral(); // When: cpd.setToolVersion("5.2.1"); // Then: assertThat(cpdCheck.get().getPmdClasspath()).isEqualTo(cpdConfiguration); assertThat(cpdConfiguration.resolve()).anyMatch(file -> file.getName().equals("pmd-core-5.2.1.jar")); }
Example #18
Source File: DependencyTaskTest.java From play-services-plugins with Apache License 2.0 | 5 votes |
@Test public void testGetResolvedArtifacts_ResolveException() { ResolvedConfiguration resolvedConfiguration = mock(ResolvedConfiguration.class); when(resolvedConfiguration.getLenientConfiguration()).thenThrow(ResolveException.class); Configuration configuration = mock(Configuration.class); when(configuration.getName()).thenReturn("compile"); when(configuration.isCanBeResolved()).thenReturn(true); when(configuration.getResolvedConfiguration()).thenReturn(resolvedConfiguration); assertThat(dependencyTask.getResolvedArtifacts(configuration), is(nullValue())); }
Example #19
Source File: PlayRoutesPlugin.java From playframework with Apache License 2.0 | 5 votes |
private Configuration createRoutesCompilerConfiguration(Project project) { Configuration compilerConfiguration = project.getConfigurations().create(ROUTES_COMPILER_CONFIGURATION_NAME); compilerConfiguration.setVisible(false); compilerConfiguration.setTransitive(true); compilerConfiguration.setDescription("The routes compiler library used to generate Scala source from routes templates."); return compilerConfiguration; }
Example #20
Source File: ResolveLocalComponentFactory.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
public MutableLocalComponentMetaData convert(Set<? extends Configuration> configurations, ModuleInternal module) { assert configurations.size() > 0 : "No configurations found for module: " + module.getName() + ". Configure them or apply a plugin that does it."; DefaultModuleDescriptor moduleDescriptor = new DefaultModuleDescriptor(IvyUtil.createModuleRevisionId(module), module.getStatus(), null); moduleDescriptor.addExtraAttributeNamespace(IVY_MAVEN_NAMESPACE_PREFIX, IVY_MAVEN_NAMESPACE); ComponentIdentifier componentIdentifier = componentIdentifierFactory.createComponentIdentifier(module); DefaultLocalComponentMetaData metaData = new DefaultLocalComponentMetaData(moduleDescriptor, componentIdentifier); configurationsToModuleDescriptorConverter.addConfigurations(metaData, configurations); dependenciesToModuleDescriptorConverter.addDependencyDescriptors(metaData, configurations); configurationsToArtifactsConverter.addArtifacts(metaData, configurations); return metaData; }
Example #21
Source File: WrappedNativeApplicationPlugin.java From native-samples with Apache License 2.0 | 5 votes |
@Override public void apply(Project project) { project.getPluginManager().apply("org.gradle.samples.wrapped-native-base"); // Add configurations for incoming dependencies final Usage cppApiUsage = project.getObjects().named(Usage.class, Usage.C_PLUS_PLUS_API); final Usage linkUsage = project.getObjects().named(Usage.class, Usage.NATIVE_LINK); Configuration implementation = project.getConfigurations().create("implementation", it -> { it.setCanBeConsumed(false); it.setCanBeResolved(false); }); // incoming compile time headers project.getConfigurations().create("cppCompile", it -> { it.setCanBeConsumed(false); it.getAttributes().attribute(Usage.USAGE_ATTRIBUTE, cppApiUsage); it.extendsFrom(implementation); }); // incoming link files project.getConfigurations().create("linkDebug", it -> { it.setCanBeConsumed(false); it.getAttributes().attribute(Usage.USAGE_ATTRIBUTE, linkUsage); it.getAttributes().attribute(CppBinary.DEBUGGABLE_ATTRIBUTE, true); it.getAttributes().attribute(CppBinary.OPTIMIZED_ATTRIBUTE, false); it.extendsFrom(implementation); }); project.getConfigurations().create("linkRelease", it -> { it.setCanBeConsumed(false); it.getAttributes().attribute(Usage.USAGE_ATTRIBUTE, linkUsage); it.getAttributes().attribute(CppBinary.DEBUGGABLE_ATTRIBUTE, true); it.getAttributes().attribute(CppBinary.OPTIMIZED_ATTRIBUTE, true); it.extendsFrom(implementation); }); }
Example #22
Source File: DefaultProjectDependency.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public void resolve(TaskDependencyResolveContext context) { if (!buildProjectDependencies) { return; } projectAccessListener.beforeResolvingProjectDependency(dependencyProject); Configuration configuration = getProjectConfiguration(); context.add(configuration); context.add(configuration.getAllArtifacts()); }
Example #23
Source File: UploadRule.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public void apply(String taskName) { for (Configuration configuration : project.getConfigurations()) { if (taskName.equals(configuration.getUploadTaskName())) { createUploadTask(configuration.getUploadTaskName(), configuration, project); } } }
Example #24
Source File: EarPlugin.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
private void configureConfigurations(final Project project) { ConfigurationContainer configurations = project.getConfigurations(); Configuration moduleConfiguration = configurations.create(DEPLOY_CONFIGURATION_NAME).setVisible(false) .setTransitive(false).setDescription("Classpath for deployable modules, not transitive."); Configuration earlibConfiguration = configurations.create(EARLIB_CONFIGURATION_NAME).setVisible(false) .setDescription("Classpath for module dependencies."); configurations.getByName(Dependency.DEFAULT_CONFIGURATION) .extendsFrom(moduleConfiguration, earlibConfiguration); }
Example #25
Source File: DefaultConf2ScopeMappingContainer.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
private List<Conf2ScopeMapping> getMappingsForConfigurations(Collection<Configuration> configurations) { List<Conf2ScopeMapping> existingMappings = new ArrayList<Conf2ScopeMapping>(); for (Configuration configuration : configurations) { if (mappings.get(configuration) != null) { existingMappings.add(mappings.get(configuration)); } else { existingMappings.add(new Conf2ScopeMapping(null, configuration, null)); } } return existingMappings; }
Example #26
Source File: BuildConfigurationRule.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
public void apply(String taskName) { if (taskName.startsWith(PREFIX)) { String configurationName = StringUtils.uncapitalize(taskName.substring(PREFIX.length())); Configuration configuration = configurations.findByName(configurationName); if (configuration != null) { Task task = tasks.create(taskName); task.dependsOn(configuration.getAllArtifacts()); task.setDescription(String.format("Builds the artifacts belonging to %s.", configuration)); } } }
Example #27
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 #28
Source File: JjtreeProgramInvokerTest.java From javaccPlugin with MIT License | 5 votes |
@Before public void setUp() throws Exception { project = mock(Project.class); Configuration classpath = mock(Configuration.class); tempOutputDirectory = testFolder.newFolder("tempOutput"); programInvoker = new JjtreeProgramInvoker(project, classpath, tempOutputDirectory); }
Example #29
Source File: DefaultProjectDependency.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
public void resolve(TaskDependencyResolveContext context) { if (!buildProjectDependencies) { return; } projectAccessListener.beforeResolvingProjectDependency(dependencyProject); Configuration configuration = getProjectConfiguration(); context.add(configuration); context.add(configuration.getAllArtifacts()); }
Example #30
Source File: JavaccPlugin.java From javaccPlugin with MIT License | 5 votes |
private Configuration createJavaccConfiguration(Project project) { Configuration configuration = project.getConfigurations().create("javacc"); configuration.setVisible(false); configuration.setTransitive(true); configuration.setDescription("The javacc dependencies to be used."); return configuration; }