build fix

This commit is contained in:
Alexander Nozik 2019-05-10 09:51:31 +03:00
parent 7daeedb9ff
commit 1344471f40
4 changed files with 60 additions and 41 deletions

View File

@ -11,6 +11,7 @@ allprojects {
}
subprojects {
apply(plugin = "dokka-publish")
if (name.startsWith("dataforge")) {
apply(plugin = "npm-publish")
}

View File

@ -1,58 +1,73 @@
import org.jetbrains.dokka.gradle.DokkaTask
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformJvmPlugin
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinMultiplatformPlugin
plugins {
kotlin("multiplatform")
id("org.jetbrains.dokka")
`maven-publish`
}
kotlin {
plugins.withType(KotlinMultiplatformPlugin::class){
configure<KotlinMultiplatformExtension>{
val dokka by tasks.getting(DokkaTask::class) {
outputFormat = "html"
outputDirectory = "$buildDir/javadoc"
jdkVersion = 8
kotlinTasks {
// dokka fails to retrieve sources from MPP-tasks so we only define the jvm task
listOf(tasks.getByPath("compileKotlinJvm"))
}
sourceRoot {
// assuming only single source dir
path = sourceSets["commonMain"].kotlin.srcDirs.first().toString()
platforms = listOf("Common")
}
// although the JVM sources are now taken from the task,
// we still define the jvm source root to get the JVM marker in the generated html
sourceRoot {
// assuming only single source dir
path = sourceSets["jvmMain"].kotlin.srcDirs.first().toString()
platforms = listOf("JVM")
}
}
val javadocJar by tasks.registering(Jar::class) {
group = JavaBasePlugin.DOCUMENTATION_GROUP
dependsOn(dokka)
archiveClassifier.set("javadoc")
from("$buildDir/javadoc")
}
configure<PublishingExtension>{
targets.all {
val publication = publications.findByName(name) as MavenPublication
// Patch publications with fake javadoc
publication.artifact(javadocJar.get())
}
}
}
}
plugins.withType(KotlinPlatformJvmPlugin::class){
val dokka by tasks.getting(DokkaTask::class) {
outputFormat = "html"
outputDirectory = "$buildDir/javadoc"
jdkVersion = 8
kotlinTasks {
// dokka fails to retrieve sources from MPP-tasks so we only define the jvm task
listOf(tasks.getByPath("compileKotlinJvm"))
}
sourceRoot {
// assuming only single source dir
path = sourceSets["commonMain"].kotlin.srcDirs.first().toString()
platforms = listOf("Common")
}
// although the JVM sources are now taken from the task,
// we still define the jvm source root to get the JVM marker in the generated html
sourceRoot {
// assuming only single source dir
path = sourceSets["jvmMain"].kotlin.srcDirs.first().toString()
platforms = listOf("JVM")
}
}
val javadocJar by tasks.registering(Jar::class) {
group = JavaBasePlugin.DOCUMENTATION_GROUP
dependsOn(dokka)
archiveClassifier.set("javadoc")
from("$buildDir/javadoc")
}
publishing {
// publications.filterIsInstance<MavenPublication>().forEach { publication ->
// if (publication.name == "kotlinMultiplatform") {
// // for our root metadata publication, set artifactId with a package and project name
// publication.artifactId = project.name
// } else {
// // for targets, set artifactId with a package, project name and target name (e.g. iosX64)
// publication.artifactId = "${project.name}-${publication.name}"
// }
// }
targets.all {
val publication = publications.findByName(name) as MavenPublication
// Patch publications with fake javadoc
configure<PublishingExtension>{
publications.filterIsInstance<MavenPublication>().forEach {publication ->
publication.artifact(javadocJar.get())
}
}

View File

@ -1,4 +1,7 @@
import org.gradle.kotlin.dsl.*
import org.gradle.kotlin.dsl.`maven-publish`
import org.gradle.kotlin.dsl.apply
import org.gradle.kotlin.dsl.dependencies
import org.gradle.kotlin.dsl.kotlin
plugins {
kotlin("multiplatform")
@ -74,8 +77,6 @@ kotlin {
}
}
apply(plugin = "dokka-publish")
// Apply JS test configuration
val runJsTests by ext(false)

View File

@ -18,17 +18,18 @@ plugins {
}
val vcs = "https://github.com/altavir/dataforge-core"
val bintrayRepo = "https://bintray.com/mipt-npm/dataforge"
// Configure publishing
publishing {
repositories {
maven("https://bintray.com/mipt-npm/dataforge")
maven(bintrayRepo)
}
// Process each publication we have in this project
publications.filterIsInstance<MavenPublication>().forEach { publication ->
// use type safe pom config GSL insterad of old dynamic
// use type safe pom config GSL instead of old dynamic
publication.pom {
name.set(project.name)
description.set(project.description)
@ -70,7 +71,7 @@ bintray {
userOrg = "mipt-npm"
repo = "dataforge"
name = project.name
issueTrackerUrl = "https://github.com/altavir/dataforge-core/issues"
issueTrackerUrl = "$vcs/issues"
setLicenses("Apache-2.0")
vcsUrl = vcs
version.apply {
@ -80,6 +81,7 @@ bintray {
}
}
//workaround bintray bug
afterEvaluate {
setPublications(*publishing.publications.names.toTypedArray())
}