aboutsummaryrefslogtreecommitdiff
path: root/buildSrc
diff options
context:
space:
mode:
authorRobert Jaros <rjaros@finn.pl>2020-03-11 16:18:17 +0100
committerRobert Jaros <rjaros@finn.pl>2020-03-11 16:18:17 +0100
commit9e243a469ae6544e8cf523ad09b959f541c3f565 (patch)
treebe9c7447e221af49180c9e98434df7f988b940b8 /buildSrc
parentec6084c42c13a621e17b17bd40d90b5c7879f0ec (diff)
downloadkvision-9e243a469ae6544e8cf523ad09b959f541c3f565.tar.gz
kvision-9e243a469ae6544e8cf523ad09b959f541c3f565.tar.bz2
kvision-9e243a469ae6544e8cf523ad09b959f541c3f565.zip
Upgrade to Kotlin 1.3.70 + other dependencies (Coroutinse, Serialization, Spring Boot)
Major refactoring of build architecture.
Diffstat (limited to 'buildSrc')
-rw-r--r--buildSrc/build.gradle.kts13
-rw-r--r--buildSrc/src/main/kotlin/Shared.kt121
2 files changed, 134 insertions, 0 deletions
diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts
new file mode 100644
index 00000000..5d2c5a5d
--- /dev/null
+++ b/buildSrc/build.gradle.kts
@@ -0,0 +1,13 @@
+plugins {
+ `kotlin-dsl`
+}
+
+repositories {
+ jcenter()
+ mavenLocal()
+}
+
+dependencies {
+ implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.70")
+ implementation(gradleApi())
+}
diff --git a/buildSrc/src/main/kotlin/Shared.kt b/buildSrc/src/main/kotlin/Shared.kt
new file mode 100644
index 00000000..b72e7663
--- /dev/null
+++ b/buildSrc/src/main/kotlin/Shared.kt
@@ -0,0 +1,121 @@
+import org.gradle.api.Project
+import org.gradle.api.publish.PublishingExtension
+import org.gradle.api.publish.maven.MavenPom
+import org.gradle.api.publish.maven.MavenPublication
+import org.gradle.kotlin.dsl.extra
+import org.gradle.kotlin.dsl.getByType
+import org.gradle.kotlin.dsl.repositories
+import org.gradle.kotlin.dsl.withType
+import org.jetbrains.kotlin.gradle.dsl.KotlinJsProjectExtension
+import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
+import org.jetbrains.kotlin.gradle.targets.js.KotlinJsTarget
+
+fun Project.repositories() {
+ repositories {
+ mavenCentral()
+ jcenter()
+ maven { url = uri("https://dl.bintray.com/kotlin/kotlin-eap") }
+ maven { url = uri("https://kotlin.bintray.com/kotlinx") }
+ maven { url = uri("https://dl.bintray.com/kotlin/kotlin-js-wrappers") }
+ maven {
+ url = uri("https://dl.bintray.com/gbaldeck/kotlin")
+ metadataSources {
+ mavenPom()
+ artifact()
+ }
+ }
+ maven { url = uri("https://dl.bintray.com/rjaros/kotlin") }
+ mavenLocal()
+ }
+}
+
+fun KotlinJsProjectExtension.kotlinJsTargets() {
+ target {
+ val isProductionBuild = project.extra.get("production") as Boolean
+ kotlinJsTargets(isProductionBuild)
+ }
+}
+
+fun KotlinMultiplatformExtension.kotlinJsTargets() {
+ js {
+ val isProductionBuild = project.extra.get("production") as Boolean
+ kotlinJsTargets(isProductionBuild)
+ }
+}
+
+private fun KotlinJsTarget.kotlinJsTargets(isProductionBuild: Boolean) {
+ compilations.all {
+ kotlinOptions {
+ moduleKind = "umd"
+ sourceMap = !isProductionBuild
+ if (!isProductionBuild) {
+ sourceMapEmbedSources = "always"
+ }
+ }
+ }
+ browser {
+ testTask {
+ useKarma {
+ useChromeHeadless()
+ }
+ }
+ }
+}
+
+fun KotlinMultiplatformExtension.kotlinJvmTargets() {
+ jvm {
+ compilations.all {
+ kotlinOptions {
+ jvmTarget = "1.8"
+ freeCompilerArgs = listOf("-Xjsr305=strict")
+ }
+ }
+ }
+}
+
+fun MavenPom.defaultPom() {
+ name.set("KVision")
+ description.set("Object oriented web framework for Kotlin/JS")
+ url.set("https://github.com/rjaros/kvision")
+ licenses {
+ license {
+ name.set("MIT")
+ url.set("https://opensource.org/licenses/MIT")
+ }
+ }
+ developers {
+ developer {
+ id.set("rjaros")
+ name.set("Robert Jaros")
+ organization.set("Treksoft")
+ organizationUrl.set("http://www.treksoft.pl")
+ }
+ }
+ scm {
+ url.set("https://github.com/rjaros/kvision.git")
+ connection.set("scm:git:git://github.com/rjaros/kvision.git")
+ developerConnection.set("scm:git:git://github.com/rjaros/kvision.git")
+ }
+}
+
+fun Project.setupPublication() {
+ plugins.apply("maven-publish")
+
+ extensions.getByType<PublishingExtension>().run {
+ publications.withType<MavenPublication>().all {
+ pom {
+ defaultPom()
+ }
+ }
+
+ repositories {
+ maven {
+ url = uri("https://api.bintray.com/maven/rjaros/kotlin/${project.name}/;publish=0;override=1")
+ credentials {
+ username = findProperty("buser")?.toString()
+ password = findProperty("bkey")?.toString()
+ }
+ }
+ }
+ }
+}