From 1344471f40eefd5dc93292e524ba4e9d613b4159 Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Fri, 10 May 2019 09:51:31 +0300 Subject: [PATCH] build fix --- build.gradle.kts | 1 + .../src/main/kotlin/dokka-publish.gradle.kts | 85 +++++++++++-------- .../main/kotlin/npm-multiplatform.gradle.kts | 7 +- .../src/main/kotlin/npm-publish.gradle.kts | 8 +- 4 files changed, 60 insertions(+), 41 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 4fc08ab3..e2482330 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -11,6 +11,7 @@ allprojects { } subprojects { + apply(plugin = "dokka-publish") if (name.startsWith("dataforge")) { apply(plugin = "npm-publish") } diff --git a/buildSrc/src/main/kotlin/dokka-publish.gradle.kts b/buildSrc/src/main/kotlin/dokka-publish.gradle.kts index 318e08ae..b816a5c4 100644 --- a/buildSrc/src/main/kotlin/dokka-publish.gradle.kts +++ b/buildSrc/src/main/kotlin/dokka-publish.gradle.kts @@ -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{ + 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{ + + 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().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{ + publications.filterIsInstance().forEach {publication -> publication.artifact(javadocJar.get()) } } diff --git a/buildSrc/src/main/kotlin/npm-multiplatform.gradle.kts b/buildSrc/src/main/kotlin/npm-multiplatform.gradle.kts index 671986b8..dd048a39 100644 --- a/buildSrc/src/main/kotlin/npm-multiplatform.gradle.kts +++ b/buildSrc/src/main/kotlin/npm-multiplatform.gradle.kts @@ -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) diff --git a/buildSrc/src/main/kotlin/npm-publish.gradle.kts b/buildSrc/src/main/kotlin/npm-publish.gradle.kts index 316a1c65..851348ba 100644 --- a/buildSrc/src/main/kotlin/npm-publish.gradle.kts +++ b/buildSrc/src/main/kotlin/npm-publish.gradle.kts @@ -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().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()) }