Skip to content

Commit

Permalink
Merged build config changes from dataforge
Browse files Browse the repository at this point in the history
  • Loading branch information
altavir committed May 31, 2019
1 parent 82e4ea8 commit 5be5556
Show file tree
Hide file tree
Showing 15 changed files with 236 additions and 206 deletions.
17 changes: 3 additions & 14 deletions build.gradle.kts
@@ -1,4 +1,4 @@
val kmathVersion by extra("0.1.2-dev-4")
val kmathVersion by extra("0.1.2")

allprojects {
repositories {
Expand All @@ -11,19 +11,8 @@ allprojects {
}

subprojects {
// Actually, probably we should apply it to plugins explicitly
// We also can merge them to single kmath-publish plugin
apply(plugin = "dokka-publish")
if (name.startsWith("kmath")) {
apply(plugin = "bintray-config")
apply(plugin = "artifactory-config")
apply(plugin = "npm-publish")
}
// dokka {
// outputFormat = "html"
// outputDirectory = javadoc.destinationDir
// }
//
// task dokkaJar (type: Jar, dependsOn: dokka) {
// from javadoc . destinationDir
// classifier = "javadoc"
// }
}
4 changes: 3 additions & 1 deletion buildSrc/build.gradle.kts
Expand Up @@ -12,7 +12,9 @@ val kotlinVersion = "1.3.31"
// Add plugins used in buildSrc as dependencies, also we should specify version only here
dependencies {
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
implementation("org.jfrog.buildinfo:build-info-extractor-gradle:4.9.5")
implementation("org.jfrog.buildinfo:build-info-extractor-gradle:4.9.6")
implementation("com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4")
implementation("org.jetbrains.dokka:dokka-gradle-plugin:0.9.18")
implementation("com.moowork.gradle:gradle-node-plugin:1.3.1")
implementation("org.openjfx:javafx-plugin:0.0.7")
}
3 changes: 1 addition & 2 deletions buildSrc/src/main/kotlin/Versions.kt
Expand Up @@ -5,6 +5,5 @@ object Versions {
val ioVersion = "0.1.8"
val coroutinesVersion = "1.2.1"
val atomicfuVersion = "0.12.6"
// This version is not used and IDEA shows this property as unused
val dokkaVersion = "0.9.18"
val serializationVersion = "0.11.0"
}
38 changes: 0 additions & 38 deletions buildSrc/src/main/kotlin/artifactory-config.gradle.kts

This file was deleted.

97 changes: 0 additions & 97 deletions buildSrc/src/main/kotlin/bintray-config.gradle.kts

This file was deleted.

74 changes: 74 additions & 0 deletions buildSrc/src/main/kotlin/dokka-publish.gradle.kts
@@ -0,0 +1,74 @@
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension

plugins {
id("org.jetbrains.dokka")
`maven-publish`
}

afterEvaluate {

extensions.findByType<KotlinMultiplatformExtension>()?.apply{
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 kdocJar 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(kdocJar.get())
}
}
}


extensions.findByType<KotlinJvmProjectExtension>()?.apply{
val dokka by tasks.getting(DokkaTask::class) {
outputFormat = "html"
outputDirectory = "$buildDir/javadoc"
jdkVersion = 8
}

val kdocJar by tasks.registering(Jar::class) {
group = JavaBasePlugin.DOCUMENTATION_GROUP
dependsOn(dokka)
archiveClassifier.set("javadoc")
from("$buildDir/javadoc")
}

configure<PublishingExtension> {
publications.filterIsInstance<MavenPublication>().forEach { publication ->
publication.artifact(kdocJar.get())
}
}
}
}
@@ -1,5 +1,3 @@
import org.gradle.kotlin.dsl.*

plugins {
kotlin("multiplatform")
`maven-publish`
Expand All @@ -11,8 +9,6 @@ kotlin {
compilations.all {
kotlinOptions {
jvmTarget = "1.8"
// This was used in kmath-koma, but probably if we need it better to apply it for all modules
freeCompilerArgs = listOf("-progressive")
}
}
}
Expand All @@ -34,35 +30,35 @@ kotlin {
}
}

sourceSets.invoke {
commonMain {
sourceSets {
val commonMain by getting {
dependencies {
api(kotlin("stdlib"))
}
}
commonTest {
val commonTest by getting {
dependencies {
implementation(kotlin("test-common"))
implementation(kotlin("test-annotations-common"))
}
}
"jvmMain" {
val jvmMain by getting {
dependencies {
api(kotlin("stdlib-jdk8"))
}
}
"jvmTest" {
val jvmTest by getting {
dependencies {
implementation(kotlin("test"))
implementation(kotlin("test-junit"))
}
}
"jsMain" {
val jsMain by getting {
dependencies {
api(kotlin("stdlib-js"))
}
}
"jsTest" {
val jsTest by getting {
dependencies {
implementation(kotlin("test-js"))
}
Expand All @@ -76,38 +72,6 @@ kotlin {
}
}

// Create empty jar for sources classifier to satisfy maven requirements
val stubSources by tasks.registering(Jar::class){
archiveClassifier.set("sources")
//from(sourceSets.main.get().allSource)
}

// Create empty jar for javadoc classifier to satisfy maven requirements
val stubJavadoc by tasks.registering(Jar::class) {
archiveClassifier.set("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
publication.artifact(stubJavadoc.get())
}
}

// Apply JS test configuration
val runJsTests by ext(false)

Expand Down

0 comments on commit 5be5556

Please sign in to comment.