EDIT: Things have been dramatically changed. Here are the latest question.
I want to configure my Gradle project with multiple subproject to use shadowed jar as main jar, and to create javadoc with it.
Here are my current goals:
- When I run
gradle publishToMavenLocal
orgradle publish
, Gradle must generate these files:- Shadow Jar as Main:
Since only reason I use shadow plugin in root project is combining all subprojects as one, the shadow jar must be main jar, which doesn't have any postfix like-all
,-dev-all
etc. - Create javadoc of all subprojects:
Each subprojects have javadoc comment on their source code. I want to create combined javadoc-like thing when publishing.
- Shadow Jar as Main:
So, after publishing, there should be mol-1.0.0-SNAPSHOT.jar
(shadow jar) and mol-1.0.0-SNAPSHOT-javadoc.jar
(javadoc) present in Maven repository. (mol
is name of my project)
Here are my Gradle build scripts. You can inspect full codes in GitHub repo because there are too many files related to.
NOTE: I think I've over-engineered my build script. So I minified my build scripts so no buildSrc
is needed.
// <root>/build.gradle.kts
import org.gradle.api.attributes.Bundling.BUNDLING_ATTRIBUTE
import org.gradle.api.attributes.Bundling.EXTERNAL
import org.gradle.api.attributes.Category.CATEGORY_ATTRIBUTE
import org.gradle.api.attributes.Category.VERIFICATION
import org.gradle.api.attributes.VerificationType.MAIN_SOURCES
import org.gradle.api.attributes.VerificationType.VERIFICATION_TYPE_ATTRIBUTE
import org.gradle.kotlin.dsl.named
plugins {
`java-library`
`maven-publish`
id("com.github.johnrengelman.shadow") version("7.1.2")
//id("io.freefair.aggregate-javadoc") version("6.5.1")
id("io.freefair.aggregate-javadoc-jar") version("6.5.1")
}
@Suppress("UnstableApiUsage")
val mainSources by configurations.creating<Configuration> {
isVisible = false
isCanBeResolved = true
isCanBeConsumed = false
attributes {
attribute(CATEGORY_ATTRIBUTE, objects.named(VERIFICATION))
attribute(BUNDLING_ATTRIBUTE, objects.named(EXTERNAL))
attribute(VERIFICATION_TYPE_ATTRIBUTE, objects.named(MAIN_SOURCES))
}
}
dependencies {
implementation(project(":bukkit_1_19_R1", "reobf")) {
isTransitive = false
}
implementation(project(":core"))
mainSources(project(":bukkit_1_19_R1"))
mainSources(project(":core"))
}
tasks {
java {
toolchain.languageVersion.set(JavaLanguageVersion.of(17))
}
build {
dependsOn(shadowJar)
}
shadowJar {
archiveClassifier.set("")
}
}
allprojects {
group = "com.github.exmsrv"
version = "1.0.0-SNAPSHOT"
}
@file:Suppress("UnstableApiUsage")
dependencyResolutionManagement {
repositories {
mavenCentral()
maven("https://repo.papermc.io/repository/maven-public/")
}
pluginManagement {
repositories {
gradlePluginPortal()
mavenCentral()
maven("https://repo.papermc.io/repository/maven-public/")
}
}
}
rootProject.name = "mol"
include("core")
include("bukkit_1_19_R1")
// <root>/bukkit_1_19_R1/build.gradle.kts
plugins {
`java-library`
id("io.papermc.paperweight.userdev") version("1.3.8")
}
dependencies {
compileOnly(project(":core"))
paperweightDevelopmentBundle("io.papermc.paper:dev-bundle:1.19.2-R0.1-SNAPSHOT")
}
// <root>/core/build.gradle.kts
plugins {
`java-library`
}
dependencies {
compileOnly("io.papermc.paper:paper-api:1.19.2-R0.1-SNAPSHOT")
}
// Do not put publishing block because it will be shadowed by shadowJar
As you can see, these are not 'complete'. I need help for completing these scripts.
NOTE: I've managed to publish shadowed jar as main, but for some reason, aggregateJavadocJar
task takes too long to process. After inspecting javadoc.options
file, it turned out it tried to create uber-javadoc which contains javadocs of every dependencies.
This is not what I meant. I want javadoc link to other javadoc link if it is not my code.
Here is what I found (javadoc.options
)