How to publish a shadow jar with an empty pom using gradle maven-publish plugin and Kotlin DSL?

1.7k views Asked by At

The shadow plugin documentation has an example for groovy but I do not understand how to translate this to Kotlin.

Groovy example from https://imperceptiblethoughts.com/shadow/publishing :

publishing {
  publications {
    shadow(MavenPublication) { publication ->
      project.shadow.component(publication)
    }
  }
}

My best attempt at the Kotlin version:

publishing {
  publications {
    create<MavenPublication>("pluginMaven") {
      artifact(tasks["shadowJar"])
      project.shadow.component(this)
    }
  }
}

With the above Kotlin version, shadowed dependencies show up in the resulting pom as runtime dependencies, which defies of purpose of shadowing.

1

There are 1 answers

0
mikhailian On BEST ANSWER

The solution is

tasks {
    shadowJar {
       archiveClassifier.set("")
        minimize()
    }
}

Some background in this github issue.