use of org.gradle.api.attributes.AttributeContainer in project native-build-tools by graalvm.
the class NativeImagePlugin method createNativeConfigurations.
@SuppressWarnings("unchecked")
private static NativeConfigurations createNativeConfigurations(Project project, String binaryName, String baseClasspathConfigurationName) {
ConfigurationContainer configurations = project.getConfigurations();
String prefix = "main".equals(binaryName) ? "" : capitalize(binaryName);
Configuration baseClasspath = configurations.getByName(baseClasspathConfigurationName);
Configuration compileOnly = configurations.create("nativeImage" + prefix + "CompileOnly", c -> {
c.setCanBeResolved(false);
c.setCanBeConsumed(false);
});
Configuration classpath = configurations.create("nativeImage" + prefix + "Classpath", c -> {
c.setCanBeConsumed(false);
c.setCanBeResolved(true);
c.extendsFrom(compileOnly);
baseClasspath.getExtendsFrom().forEach(c::extendsFrom);
c.attributes(attrs -> {
AttributeContainer baseAttributes = baseClasspath.getAttributes();
for (Attribute<?> attribute : baseAttributes.keySet()) {
Attribute<Object> attr = (Attribute<Object>) attribute;
Object value = baseAttributes.getAttribute(attr);
attrs.attribute(attr, value);
}
});
});
compileOnly.getDependencies().add(project.getDependencies().create(project));
return new NativeConfigurations(compileOnly, classpath);
}
use of org.gradle.api.attributes.AttributeContainer in project spring-boot by spring-projects.
the class JavaPluginAction method configureDevelopmentOnlyConfiguration.
private void configureDevelopmentOnlyConfiguration(Project project) {
Configuration developmentOnly = project.getConfigurations().create(SpringBootPlugin.DEVELOPMENT_ONLY_CONFIGURATION_NAME);
developmentOnly.setDescription("Configuration for development-only dependencies such as Spring Boot's DevTools.");
Configuration runtimeClasspath = project.getConfigurations().getByName(JavaPlugin.RUNTIME_CLASSPATH_CONFIGURATION_NAME);
Configuration productionRuntimeClasspath = project.getConfigurations().create(SpringBootPlugin.PRODUCTION_RUNTIME_CLASSPATH_CONFIGURATION_NAME);
AttributeContainer attributes = productionRuntimeClasspath.getAttributes();
ObjectFactory objectFactory = project.getObjects();
attributes.attribute(Usage.USAGE_ATTRIBUTE, objectFactory.named(Usage.class, Usage.JAVA_RUNTIME));
attributes.attribute(Bundling.BUNDLING_ATTRIBUTE, objectFactory.named(Bundling.class, Bundling.EXTERNAL));
attributes.attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, objectFactory.named(LibraryElements.class, LibraryElements.JAR));
productionRuntimeClasspath.setVisible(false);
productionRuntimeClasspath.setExtendsFrom(runtimeClasspath.getExtendsFrom());
productionRuntimeClasspath.setCanBeResolved(runtimeClasspath.isCanBeResolved());
productionRuntimeClasspath.setCanBeConsumed(runtimeClasspath.isCanBeConsumed());
runtimeClasspath.extendsFrom(developmentOnly);
}
use of org.gradle.api.attributes.AttributeContainer in project gradle by gradle.
the class NativeBasePlugin method addOutgoingConfigurationForRuntimeUsage.
private void addOutgoingConfigurationForRuntimeUsage(SoftwareComponentContainer components, final ConfigurationContainer configurations) {
components.withType(ConfigurableComponentWithRuntimeUsage.class, component -> {
Names names = component.getNames();
Configuration runtimeElements = configurations.create(names.withSuffix("runtimeElements"));
runtimeElements.extendsFrom(component.getImplementationDependencies());
runtimeElements.setCanBeResolved(false);
AttributeContainer attributes = component.getRuntimeAttributes();
copyAttributesTo(attributes, runtimeElements);
if (component.hasRuntimeFile()) {
runtimeElements.getOutgoing().artifact(component.getRuntimeFile());
}
component.getRuntimeElements().set(runtimeElements);
});
}
use of org.gradle.api.attributes.AttributeContainer in project gradle by gradle.
the class NativeBasePlugin method addOutgoingConfigurationForLinkUsage.
private void addOutgoingConfigurationForLinkUsage(SoftwareComponentContainer components, final ConfigurationContainer configurations) {
components.withType(ConfigurableComponentWithLinkUsage.class, component -> {
Names names = component.getNames();
Configuration linkElements = configurations.create(names.withSuffix("linkElements"));
linkElements.extendsFrom(component.getImplementationDependencies());
linkElements.setCanBeResolved(false);
AttributeContainer attributes = component.getLinkAttributes();
copyAttributesTo(attributes, linkElements);
linkElements.getOutgoing().artifact(component.getLinkFile());
component.getLinkElements().set(linkElements);
});
}
use of org.gradle.api.attributes.AttributeContainer in project gradle by gradle.
the class WarPlugin method configureComponent.
private void configureComponent(Project project, PublishArtifact warArtifact) {
AttributeContainer attributes = attributesFactory.mutable().attribute(Usage.USAGE_ATTRIBUTE, objectFactory.named(Usage.class, Usage.JAVA_RUNTIME));
project.getComponents().add(objectFactory.newInstance(WebApplication.class, warArtifact, "master", attributes));
}
Aggregations