Need help about configuring build.gradle.kts for build/javadoc/publish

I want to configure my build script written with Kotlin DSL.

My goals are four:

  1. When I run gradle build, Gradle should produce shadowed jar as ‘main jar’(without -all postfix) in <root>/build/lib directory.
    Currently, Gradle produces JAR file in subdirectory of each subprojects.
    Since the reason of shadowing is ‘create AIO jar’, user of my project must use shadowed jar, not ‘main jar’. I don’t want to make them always append :all when declaring dependency.
  2. When I run gradle javadoc, Gradle should produce javadoc in <root>/build/doc directory.
    Currently, Gradle produces javadoc in subdirectory of each subprojects. I want my javadoc as AIO, not separated by subprojects.
  3. When doing build or javadoc, do not produce directories like <root>/core/build and <root>/bukkit_1_19_R1/build (build directory in subprojects). I don’t want it. I want gradle things to be ‘centralized’.
  4. When I publish to both local and remote, create both (1) and (2).
    Currently, I can only see (1).

Here are my project’s build scripts.

// <root>/build.gradle.kts

plugins {
  id("com.github.johnrengelman.shadow") version("7.1.2")

dependencies {
  implementation(project(":bukkit_1_19_R1")) {
    isTransitive = false

tasks {
  * Goals:
  * 1. When run 'gradle build', build only one shadowed jar which contains all files of subproject's.
  *    This should locate at '<root>/build/lib', not under each subproject's directory.
  *    This means shadowed jar will act as 'default generated jar'.
  * 2. When run 'gradle javadoc', create one javadoc jar along with output of (1).
  *    This should contain all javadoc from subprojects, and does not create files under each subprojects.
  * 3. When publish, create both (1) and (2).
  // Create shadowed jar as default
  shadowJar {
  publishing {
    publications {
      create<MavenPublication>("shadow") {
        project.extensions.configure<com.github.jengelman.gradle.plugins.shadow.ShadowExtension> {

  javadoc {

allprojects {
  apply(plugin = "java-library")

  repositories {

  group = "com.gitlab.exmserver"
  version = "1.0.0-SNAPSHOT"
// <root>/core/build.gradle.kts
dependencies {
// <root>/bukkit_1_19_R1/build.gradle.kts
plugins {
  id("io.papermc.paperweight.userdev") version("1.3.8")

dependencies {

With these scripts, I have these problem.

  1. Javadoc tries to document ItemStack class which is not part of my project. Since Gradle cannot find javadoc for those kind of classes, it failes to create javadoc.
    I want to disable ‘lookup’ or ‘link’ for those kind of classes which are not part of my project. I want them displayed as plain code text like org.bukkit.inventory.ItemStack, not hyper-linked.
    If I must provide ‘link’ to those classes, I want to specify ‘base link’ where to find those kind of javadoc. Like ‘external javadoc’.
  2. My scripts produces shadowed jar as ‘main jar’(without -all postfix), but this isn’t located at <root>/build/lib directory.
  3. Javadocs are not located at <root>/build/docs too.

How to configure my build scripts to behave as what I want?

Things have been dramatically change, and the codes above are not latest. I decided to ask in SO.

I hope I can remove this thread, or edit the title of this thread, but I can’t do any of that.
If you came here to help, thank you for your kindness.