Skip to content

Commit

Permalink
Extract shadowConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
Goooler committed Feb 28, 2023
1 parent 65595ff commit de0c61d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,11 @@ class ShadowBasePlugin implements Plugin<Project> {
throw new GradleException("This version of Shadow supports Gradle 8.0+ only. Please upgrade.")
}
project.extensions.create(EXTENSION_NAME, ShadowExtension, project)
createShadowConfiguration(project)
project.configurations.create(CONFIGURATION_NAME)

project.tasks.register(KnowsTask.NAME, KnowsTask) { knows ->
knows.group = ShadowJavaPlugin.SHADOW_GROUP
knows.description = KnowsTask.DESC
}
}

private static void createShadowConfiguration(Project project) {
project.configurations.create(CONFIGURATION_NAME)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ class ShadowExtension {
void component(MavenPublication publication) {
publication.artifact(project.tasks.named("shadowJar"))

final def shadowConfig = project.configurations.getByName(ShadowBasePlugin.CONFIGURATION_NAME)
publication.pom { MavenPom pom ->
pom.withXml { xml ->
def dependenciesNode = xml.asNode().get('dependencies') ?: xml.asNode().appendNode('dependencies')
project.configurations.shadow.allDependencies.each {
shadowConfig.allDependencies.each {
if ((it instanceof ProjectDependency) || ! (it instanceof SelfResolvingDependency)) {
def dependencyNode = dependenciesNode.appendNode('dependency')
dependencyNode.appendNode('groupId', it.group)
Expand Down

0 comments on commit de0c61d

Please sign in to comment.