kmath/build.gradle.kts

221 lines
7.5 KiB
Plaintext
Raw Normal View History

2019-04-07 09:18:06 +03:00
import com.moowork.gradle.node.NodeExtension
import com.moowork.gradle.node.npm.NpmTask
import com.moowork.gradle.node.task.NodeTask
2019-01-31 18:19:02 +03:00
buildscript {
2019-02-12 11:58:58 +03:00
val kotlinVersion: String by rootProject.extra("1.3.21")
2019-02-20 12:54:39 +03:00
val ioVersion: String by rootProject.extra("0.1.5")
2019-01-26 19:38:18 +03:00
val coroutinesVersion: String by rootProject.extra("1.1.1")
2019-02-03 13:07:35 +03:00
val atomicfuVersion: String by rootProject.extra("0.12.1")
2019-02-22 13:52:35 +03:00
val dokkaVersion: String by rootProject.extra("0.9.17")
2019-04-07 09:18:06 +03:00
val serializationVersion: String by rootProject.extra("0.10.0")
repositories {
jcenter()
2019-04-07 09:18:06 +03:00
maven("https://dl.bintray.com/kotlin/kotlin-eap")
}
dependencies {
2018-11-21 09:55:39 +03:00
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
classpath("org.jfrog.buildinfo:build-info-extractor-gradle:4+")
2019-02-21 08:58:55 +03:00
classpath("com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4")
2019-02-22 13:52:35 +03:00
classpath("org.jetbrains.dokka:dokka-gradle-plugin:$dokkaVersion")
2019-04-07 09:18:06 +03:00
//classpath("org.jetbrains.kotlin:kotlin-frontend-plugin:0.0.45")
//classpath("org.openjfx:javafx-plugin:0.0.7")
}
}
plugins {
2019-02-12 14:14:16 +03:00
id("com.jfrog.artifactory") version "4.9.1" apply false
2019-04-07 09:18:06 +03:00
id("com.moowork.node") version "1.3.1" apply false
}
2019-04-07 09:18:06 +03:00
val kmathVersion by extra("0.1.2-dev-1")
2019-02-22 13:52:35 +03:00
allprojects {
2019-04-07 09:18:06 +03:00
apply(plugin = "maven")
apply(plugin = "maven-publish")
apply(plugin = "com.jfrog.artifactory")
2018-12-24 15:19:35 +03:00
2019-01-04 18:12:28 +03:00
repositories {
2018-12-24 15:19:35 +03:00
jcenter()
2019-04-07 09:18:06 +03:00
maven("https://kotlin.bintray.com/kotlinx")
2018-12-24 15:19:35 +03:00
}
2019-04-07 09:18:06 +03:00
group = "scientifik"
version = kmathVersion
}
2019-01-31 18:19:02 +03:00
2019-04-07 09:18:06 +03:00
subprojects {
if(name.startsWith("kmath")) {
// apply bintray configuration
apply(from = "${rootProject.rootDir}/gradle/bintray.gradle")
2019-02-22 13:52:35 +03:00
2019-04-07 09:18:06 +03:00
//apply artifactory configuration
apply(from = "${rootProject.rootDir}/gradle/artifactory.gradle")
}
// dokka {
// outputFormat = "html"
// outputDirectory = javadoc.destinationDir
// }
//
// task dokkaJar (type: Jar, dependsOn: dokka) {
// from javadoc . destinationDir
// classifier = "javadoc"
// }
// 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)
}
2019-02-22 13:52:35 +03:00
2019-04-07 09:18:06 +03:00
// Create empty jar for javadoc classifier to satisfy maven requirements
val stubJavadoc by tasks.registering(Jar::class) {
archiveClassifier.set("javadoc")
}
2019-02-22 13:52:35 +03:00
2019-04-07 09:18:06 +03:00
tasks.withType<KotlinCompile> {
kotlinOptions {
jvmTarget = "1.8"
}
}
2019-02-22 13:52:35 +03:00
2019-04-07 09:18:06 +03:00
afterEvaluate {
extensions.findByType<KotlinMultiplatformExtension>()?.apply {
jvm {
compilations.all {
kotlinOptions {
jvmTarget = "1.8"
}
2019-01-31 18:19:02 +03:00
}
}
2019-02-21 08:58:55 +03:00
2019-04-07 09:18:06 +03:00
js {
compilations.all {
tasks.getByName(compileKotlinTaskName) {
kotlinOptions {
metaInfo = true
sourceMap = true
sourceMapEmbedSources = "always"
moduleKind = "commonjs"
}
}
}
configure(listOf(compilations["main"])) {
tasks.getByName(compileKotlinTaskName) {
kotlinOptions {
main = "call"
}
}
}
val runJsTests by ext(false)
if(runJsTests) {
apply(plugin = "com.moowork.node")
configure<NodeExtension> {
nodeModulesDir = file("$buildDir/node_modules")
}
val compileKotlinJs by tasks.getting(Kotlin2JsCompile::class)
val compileTestKotlinJs by tasks.getting(Kotlin2JsCompile::class)
val populateNodeModules by tasks.registering(Copy::class) {
dependsOn(compileKotlinJs)
from(compileKotlinJs.destinationDir)
2019-02-21 08:58:55 +03:00
2019-04-07 09:18:06 +03:00
compilations["test"].runtimeDependencyFiles.forEach {
if (it.exists() && !it.isDirectory) {
from(zipTree(it.absolutePath).matching { include("*.js") })
}
}
into("$buildDir/node_modules")
}
val installMocha by tasks.registering(NpmTask::class) {
setWorkingDir(buildDir)
setArgs(listOf("install", "mocha"))
}
val runMocha by tasks.registering(NodeTask::class) {
dependsOn(compileTestKotlinJs, populateNodeModules, installMocha)
setScript(file("$buildDir/node_modules/mocha/bin/mocha"))
setArgs(listOf(compileTestKotlinJs.outputFile))
}
tasks["jsTest"].dependsOn(runMocha)
2019-02-22 13:52:35 +03:00
}
}
2019-02-21 08:58:55 +03:00
2019-04-07 09:18:06 +03:00
sourceSets {
val commonMain by getting {
dependencies {
api(kotlin("stdlib"))
}
}
val commonTest by getting {
dependencies {
implementation(kotlin("test-common"))
implementation(kotlin("test-annotations-common"))
}
}
val jvmMain by getting {
dependencies {
api(kotlin("stdlib-jdk8"))
}
}
val jvmTest by getting {
dependencies {
implementation(kotlin("test"))
implementation(kotlin("test-junit"))
}
}
val jsMain by getting {
dependencies {
api(kotlin("stdlib-js"))
}
}
val jsTest by getting {
dependencies {
implementation(kotlin("test-js"))
}
}
2019-02-22 13:52:35 +03:00
}
2019-04-07 09:18:06 +03:00
targets.all {
sourceSets.all {
languageSettings.progressiveMode = true
2019-04-07 12:27:49 +03:00
languageSettings.enableLanguageFeature("InlineClasses")
languageSettings.useExperimentalAnnotation("ExperimentalContracts")
//languageSettings.enableLanguageFeature("Contracts")
2019-04-07 09:18:06 +03:00
}
2019-02-22 13:52:35 +03:00
}
2019-04-07 09:18:06 +03:00
configure<PublishingExtension> {
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}"
}
}
2019-02-22 13:52:35 +03:00
2019-04-07 09:18:06 +03:00
targets.all {
val publication = publications.findByName(name) as MavenPublication
2019-02-22 13:52:35 +03:00
// Patch publications with fake javadoc
2019-04-07 09:18:06 +03:00
publication.artifact(stubJavadoc.get())
2019-02-22 13:52:35 +03:00
}
}
2019-02-21 08:58:55 +03:00
}
}
2019-02-22 13:52:35 +03:00
2019-04-07 09:18:06 +03:00
}