Skip to content

Commit 504df7e

Browse files
committed
Reuse the config name
1 parent 45c8590 commit 504df7e

1 file changed

Lines changed: 19 additions & 19 deletions

File tree

  • src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/internal

src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/internal/UnusedTracker.kt

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package com.github.jengelman.gradle.plugins.shadow.internal
22

33
import java.io.File
4-
import kotlin.uuid.ExperimentalUuidApi
5-
import kotlin.uuid.Uuid
64
import org.gradle.api.Project
75
import org.gradle.api.artifacts.component.ModuleComponentIdentifier
86
import org.gradle.api.attributes.Category
@@ -19,25 +17,27 @@ internal fun Project.getApiJars(): Provider<List<File>> {
1917
val apiConfiguration =
2018
configurations.findByName(API_CONFIGURATION_NAME) ?: return provider { emptyList() }
2119

20+
val configName = "shadowMinimizeApi"
2221
val shadowApiConfig =
23-
configurations.register(
24-
@OptIn(ExperimentalUuidApi::class)
25-
"shadowMinimizeApi_${Uuid.random().toString().substring(0, 8)}"
26-
) {
27-
it.isCanBeResolved = true
28-
it.isCanBeConsumed = false
29-
it.attributes { attrs ->
30-
attrs.attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage::class.java, Usage.JAVA_API))
31-
attrs.attribute(
32-
Category.CATEGORY_ATTRIBUTE,
33-
objects.named(Category::class.java, Category.LIBRARY),
34-
)
35-
attrs.attribute(
36-
LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE,
37-
objects.named(LibraryElements::class.java, LibraryElements.JAR),
38-
)
22+
if (configurations.names.contains(configName)) {
23+
configurations.named(configName)
24+
} else {
25+
configurations.register(configName) {
26+
it.isCanBeResolved = true
27+
it.isCanBeConsumed = false
28+
it.attributes { attrs ->
29+
attrs.attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage::class.java, Usage.JAVA_API))
30+
attrs.attribute(
31+
Category.CATEGORY_ATTRIBUTE,
32+
objects.named(Category::class.java, Category.LIBRARY),
33+
)
34+
attrs.attribute(
35+
LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE,
36+
objects.named(LibraryElements::class.java, LibraryElements.JAR),
37+
)
38+
}
39+
it.extendsFrom(apiConfiguration)
3940
}
40-
it.extendsFrom(apiConfiguration)
4141
}
4242

4343
return shadowApiConfig.map { shadowApi ->

0 commit comments

Comments
 (0)