Added JVM and JS plugins

This commit is contained in:
Alexander Nozik 2019-07-21 17:40:08 +03:00
parent 1a98759c2b
commit 64eaabb443
5 changed files with 163 additions and 4 deletions

View File

@ -12,6 +12,7 @@ version = "0.1.4-dev"
repositories {
gradlePluginPortal()
jcenter()
maven("https://kotlin.bintray.com/kotlinx")
maven("https://dl.bintray.com/kotlin/kotlin-eap")
}
@ -21,6 +22,7 @@ val kotlinVersion = "1.3.50-eap-5"
dependencies {
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
implementation("org.jetbrains.kotlin:kotlin-serialization:$kotlinVersion")
implementation("org.jetbrains.kotlinx:atomicfu-gradle-plugin:0.12.9")
implementation("org.jfrog.buildinfo:build-info-extractor-gradle:4.9.7")
implementation("com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4")
implementation("org.jetbrains.dokka:dokka-gradle-plugin:0.9.18")
@ -33,11 +35,24 @@ gradlePlugin {
description = "The publication plugin for bintray and artifactory"
implementationClass = "scientifik.ScientifikPublishPlugin"
}
create("scientifik-mpp") {
id = "scientifik.mpp"
description = "Pre-configured multiplatform project"
implementationClass = "scientifik.ScientifikMPPlugin"
}
create("scientifik-jvm") {
id = "scientifik.jvm"
description = "Pre-configured JVM project"
implementationClass = "scientifik.ScientifikJVMPlugin"
}
create("scientifik-js") {
id = "scientifik.js"
description = "Pre-configured JS project"
implementationClass = "scientifik.ScientifikJSPlugin"
}
}
}

View File

@ -9,8 +9,10 @@ open class ScientifikExtension {
var vcs: String? = null
var bintrayRepo: String? = null
var kdoc: Boolean = true
var native = false
internal var native = false
var serialization = false
var atomicfu = false
var io = false
}
internal val Project.scientifik: ScientifikExtension

View File

@ -0,0 +1,62 @@
package scientifik
import Scientifik
import kotlinx.atomicfu.plugin.gradle.sourceSets
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.*
import org.jetbrains.kotlin.gradle.dsl.KotlinJsProjectExtension
import org.jetbrains.kotlin.gradle.plugin.KotlinDependencyHandler
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet
open class ScientifikJSPlugin : Plugin<Project> {
override fun apply(project: Project) {
val extension = project.scientifik
with(project) {
plugins.apply("org.jetbrains.kotlin.js")
plugins.apply("kotlinx-serialization")
plugins.apply("kotlinx-atomicfu")
repositories {
mavenCentral()
jcenter()
maven("https://dl.bintray.com/kotlin/kotlin-eap")
maven("https://kotlin.bintray.com/kotlinx")
maven("https://dl.bintray.com/mipt-npm/dev")
}
configure<KotlinJsProjectExtension>{
target{
browser()
}
}
sourceSets["main"].apply {
this as KotlinSourceSet
languageSettings.apply {
progressiveMode = true
enableLanguageFeature("InlineClasses")
useExperimentalAnnotation("ExperimentalUnsignedType")
}
}
dependencies {
this as KotlinDependencyHandler
api(kotlin("stdlib-jdk8"))
if (extension.serialization) {
implementation("org.jetbrains.kotlinx:kotlinx-serialization-runtime:${Scientifik.serializationVersion}")
}
if (extension.atomicfu) {
implementation("org.jetbrains.kotlinx:atomicfu-js:${Scientifik.atomicfuVersion}")
}
if (extension.io) {
api("org.jetbrains.kotlinx:kotlinx-io-js:${Scientifik.ioVersion}")
}
}
}
}
}

View File

@ -0,0 +1,61 @@
package scientifik
import Scientifik
import kotlinx.atomicfu.plugin.gradle.sourceSets
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.*
import org.jetbrains.kotlin.gradle.plugin.KotlinDependencyHandler
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
open class ScientifikJVMPlugin : Plugin<Project> {
override fun apply(project: Project) {
val extension = project.scientifik
with(project) {
plugins.apply("org.jetbrains.kotlin.jvm")
plugins.apply("kotlinx-serialization")
plugins.apply("kotlinx-atomicfu")
repositories {
mavenCentral()
jcenter()
maven("https://dl.bintray.com/kotlin/kotlin-eap")
maven("https://kotlin.bintray.com/kotlinx")
maven("https://dl.bintray.com/mipt-npm/dev")
}
tasks.withType<KotlinCompile> {
kotlinOptions {
jvmTarget = "1.8"
}
}
sourceSets["main"].apply {
this as KotlinSourceSet
languageSettings.apply {
progressiveMode = true
enableLanguageFeature("InlineClasses")
useExperimentalAnnotation("ExperimentalUnsignedType")
}
}
dependencies {
this as KotlinDependencyHandler
api(kotlin("stdlib-jdk8"))
if (extension.serialization) {
implementation("org.jetbrains.kotlinx:kotlinx-serialization-runtime:${Scientifik.serializationVersion}")
}
if (extension.atomicfu) {
implementation("org.jetbrains.kotlinx:atomicfu:${Scientifik.atomicfuVersion}")
}
if (extension.io) {
api("org.jetbrains.kotlinx:kotlinx-io-jvm:${Scientifik.ioVersion}")
}
}
}
}
}

View File

@ -12,6 +12,7 @@ open class ScientifikMPPlugin : Plugin<Project> {
project.plugins.apply("org.jetbrains.kotlin.multiplatform")
project.plugins.apply("kotlinx-serialization")
project.plugins.apply("kotlinx-atomicfu")
project.repositories {
mavenCentral()
@ -30,8 +31,8 @@ open class ScientifikMPPlugin : Plugin<Project> {
}
}
js{
browser{}
js {
browser {}
}
if (extension.native) {
@ -45,7 +46,13 @@ open class ScientifikMPPlugin : Plugin<Project> {
api(kotlin("stdlib"))
project.afterEvaluate {
if (extension.serialization) {
api("org.jetbrains.kotlinx:kotlinx-serialization-runtime:${Scientifik.serializationVersion}")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-runtime:${Scientifik.serializationVersion}")
}
if(extension.atomicfu){
implementation("org.jetbrains.kotlinx:atomicfu-common:${Scientifik.atomicfuVersion}")
}
if(extension.io){
api("org.jetbrains.kotlinx:kotlinx-io-common:${Scientifik.ioVersion}")
}
}
}
@ -59,6 +66,12 @@ open class ScientifikMPPlugin : Plugin<Project> {
val jvmMain by getting {
dependencies {
api(kotlin("stdlib-jdk8"))
if(extension.atomicfu){
implementation("org.jetbrains.kotlinx:atomicfu:${Scientifik.atomicfuVersion}")
}
if(extension.io){
api("org.jetbrains.kotlinx:kotlinx-io-jvm:${Scientifik.ioVersion}")
}
}
}
val jvmTest by getting {
@ -70,6 +83,12 @@ open class ScientifikMPPlugin : Plugin<Project> {
val jsMain by getting {
dependencies {
api(kotlin("stdlib-js"))
if(extension.atomicfu){
implementation("org.jetbrains.kotlinx:atomicfu-common-js:${Scientifik.atomicfuVersion}")
}
if(extension.io){
api("org.jetbrains.kotlinx:kotlinx-io-js:${Scientifik.ioVersion}")
}
}
}
val jsTest by getting {