Skip to content

Commit

Permalink
Reuse shadowRuntimeElements
Browse files Browse the repository at this point in the history
  • Loading branch information
Goooler committed Sep 18, 2024
1 parent 890d887 commit 8ee6bea
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class ShadowJavaPlugin implements Plugin<Project> {

public static final String SHADOW_JAR_TASK_NAME = 'shadowJar'
public static final String SHADOW_GROUP = 'Shadow'
public static final String SHADOW_RUNTIME_ELEMENTS_CONFIGURATION_NAME = 'shadowRuntimeElements'

private final SoftwareComponentFactory softwareComponentFactory

Expand All @@ -39,7 +40,7 @@ class ShadowJavaPlugin implements Plugin<Project> {
it.extendsFrom(shadowConfiguration)
}

project.configurations.register("shadowRuntimeElements") {
def shadowRuntimeElements = project.configurations.create(SHADOW_RUNTIME_ELEMENTS_CONFIGURATION_NAME) {
it.extendsFrom(shadowConfiguration)
it.canBeConsumed = true
it.canBeResolved = false
Expand All @@ -53,14 +54,14 @@ class ShadowJavaPlugin implements Plugin<Project> {
}

project.components.named("java", AdhocComponentWithVariants) {
it.addVariantsFromConfiguration(project.configurations.shadowRuntimeElements) {
it.addVariantsFromConfiguration(shadowRuntimeElements) {
it.mapToOptional()
}
}

AdhocComponentWithVariants shadowComponent = softwareComponentFactory.adhoc(ShadowBasePlugin.COMPONENT_NAME)
project.components.add(shadowComponent)
shadowComponent.addVariantsFromConfiguration(project.configurations.shadowRuntimeElements) {
shadowComponent.addVariantsFromConfiguration(shadowRuntimeElements) {
it.mapToMavenScope("runtime")
}

Expand Down

0 comments on commit 8ee6bea

Please sign in to comment.