Будет работать следующее:
val sourcesJar by creating(Jar::class) {
dependsOn(JavaPlugin.CLASSES_TASK_NAME)
classifier = "sources"
from(sourceSets["main"].allSource)
}
val javadocJar by creating(Jar::class) {
dependsOn(JavaPlugin.JAVADOC_TASK_NAME)
classifier = "javadoc"
from(tasks["javadoc"])
}
artifacts {
add("archives", sourcesJar)
add("archives", javadocJar)
}
Полное build.gradle.kts
будет выглядеть так:
plugins {
kotlin("jvm") version "1.2.71"
}
repositories {
mavenCentral()
}
dependencies {
}
tasks {
val sourcesJar by creating(Jar::class) {
dependsOn(JavaPlugin.CLASSES_TASK_NAME)
classifier = "sources"
from(sourceSets["main"].allSource)
}
val javadocJar by creating(Jar::class) {
dependsOn(JavaPlugin.JAVADOC_TASK_NAME)
classifier = "javadoc"
from(tasks["javadoc"])
}
artifacts {
add("archives", sourcesJar)
add("archives", javadocJar)
}
}