// Approach 1: Explicit Variant
// The following snippet will let you add attributes for linux and x86_64 to a configuration
configurations.someConfiguration {
attributes {
attribute(Usage.USAGE_ATTRIBUTE, objects.named<Usage>(Usage.JAVA_RUNTIME))
attribute(OperatingSystemFamily.OPERATING_SYSTEM_ATTRIBUTE, objects.named<OperatingSystemFamily>("linux"))
attribute(MachineArchitecture.ARCHITECTURE_ATTRIBUTE, objects.named<MachineArchitecture>("x86-64"))
}
}
// Approach 2: Copy existing configuration into another configuration
configurations.someConfiguration {
val runtimeAttributes = configurations.runtimeClasspath.get().attributes
runtimeAttributes.keySet().forEach { key ->
attributes.attribute(key as Attribute<Any>, runtimeAttributes.getAttribute(key))
}
}
1 Like