Skip to content

Commit

Permalink
Add javadoc and common sources publishing
Browse files Browse the repository at this point in the history
Also get rid of "Default Kotlin Hierarchy Template was not applied" warning
  • Loading branch information
serjsysoev committed Sep 5, 2024
1 parent 5d7e023 commit 229e51a
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
32 changes: 30 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ tasks {
}

val allMetadataJar by existing(Jar::class) {
archiveClassifier.set("all")
archiveClassifier.set("common")
}

val javadocJar by creating(Jar::class) {
Expand All @@ -202,6 +202,21 @@ nexusPublishing {
}
}

configurations {
create("javadocElements") {
attributes {
attribute(Category.CATEGORY_ATTRIBUTE, project.objects.named(Category::class.java, Category.DOCUMENTATION))
attribute(Bundling.BUNDLING_ATTRIBUTE, project.objects.named(Bundling::class.java, Bundling.EXTERNAL))
attribute(DocsType.DOCS_TYPE_ATTRIBUTE, project.objects.named(DocsType::class.java, DocsType.JAVADOC))
attribute(Usage.USAGE_ATTRIBUTE, project.objects.named(Usage::class.java, Usage.JAVA_RUNTIME))
}
}
}

artifacts {
add("javadocElements", tasks.getByName("javadocJar"))
}

publishing {
val artifactBaseName = base.archivesName.get()
configureMultiModuleMavenPublishing {
Expand All @@ -210,14 +225,27 @@ publishing {
artifactId = artifactBaseName
groupId = "org.jetbrains"
configureKotlinPomAttributes(packaging = "jar")
artifact(tasks.getByName("javadocJar"))
}
variant("metadataApiElements") { suppressPomMetadataWarnings() }
variant("metadataSourcesElementsFromJvm") {
name = "metadataSourcesElements"
configuration {
// to avoid clash in Gradle 8+ with metadataSourcesElements configuration with the same attributes
isCanBeConsumed = false
}
attributes {
copyAttributes(from = project.configurations["metadataSourcesElements"].attributes, to = this)
}
artifact(tasks["sourcesJar"]) {
classifier = "sources-common"
}
}
variant("jvmApiElements")
variant("jvmRuntimeElements") {
configureVariantDetails { mapToMavenScope("runtime") }
}
variant("jvmSourcesElements")
variant("javadocElements")
}
val targetModules = kotlin.targets.filter { it.targetName != "jvm" && it.targetName != "metadata" }.map { target ->
val targetName = target.targetName
Expand Down
3 changes: 2 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ kotlin.code.style=official
kotlin.mpp.stability.nowarn=true
kotlin.stdlib.default.dependency=false
kotlin.internal.mpp.createDefaultMultiplatformPublications=false
kotlin.native.ignoreIncorrectDependencies=true
kotlin.native.ignoreIncorrectDependencies=true
kotlin.mpp.applyDefaultHierarchyTemplate=false

0 comments on commit 229e51a

Please sign in to comment.