Separated atomic into a plugin
This commit is contained in:
parent
ebbd33aa75
commit
e0ec9a20d7
@ -54,6 +54,12 @@ gradlePlugin {
|
||||
description = "Pre-configured JS project"
|
||||
implementationClass = "scientifik.ScientifikJSPlugin"
|
||||
}
|
||||
|
||||
create("scientifik-atomic") {
|
||||
id = "scientifik.atomic"
|
||||
description = "Add kotlin atomic plugin to any flafor"
|
||||
implementationClass = "scientifik.ScientifikAtomicPlugin"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
68
src/main/kotlin/scientifik/ScientifikAtomicPlugin.kt
Normal file
68
src/main/kotlin/scientifik/ScientifikAtomicPlugin.kt
Normal file
@ -0,0 +1,68 @@
|
||||
package scientifik
|
||||
|
||||
import Scientifik
|
||||
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.dsl.KotlinJvmProjectExtension
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
|
||||
|
||||
class ScientifikAtomicPlugin : Plugin<Project> {
|
||||
override fun apply(target: Project) {
|
||||
with(target) {
|
||||
plugins.apply("kotlinx-atomicfu")
|
||||
|
||||
pluginManager.withPlugin("org.jetbrains.kotlin.multiplatform") {
|
||||
project.configure<KotlinMultiplatformExtension> {
|
||||
sourceSets.invoke {
|
||||
val commonMain by getting {
|
||||
dependencies {
|
||||
implementation("org.jetbrains.kotlinx:atomicfu-common:${Scientifik.atomicfuVersion}")
|
||||
}
|
||||
}
|
||||
|
||||
val jvmMain by getting {
|
||||
dependencies {
|
||||
implementation("org.jetbrains.kotlinx:atomicfu:${Scientifik.atomicfuVersion}")
|
||||
}
|
||||
}
|
||||
val jsMain by getting {
|
||||
dependencies {
|
||||
implementation("org.jetbrains.kotlinx:atomicfu-common-js:${Scientifik.atomicfuVersion}")
|
||||
}
|
||||
}
|
||||
val jsTest by getting {
|
||||
dependencies {
|
||||
implementation(kotlin("test-js"))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//TODO add native clause
|
||||
}
|
||||
|
||||
pluginManager.withPlugin("org.jetbrains.kotlin.jvm") {
|
||||
configure<KotlinJvmProjectExtension> {
|
||||
sourceSets["main"].apply {
|
||||
dependencies {
|
||||
implementation("org.jetbrains.kotlinx:atomicfu:${Scientifik.atomicfuVersion}")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pluginManager.withPlugin("org.jetbrains.kotlin.js") {
|
||||
configure<KotlinJsProjectExtension> {
|
||||
sourceSets["main"].apply {
|
||||
dependencies {
|
||||
implementation("org.jetbrains.kotlinx:atomicfu-js:${Scientifik.atomicfuVersion}")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,6 @@ open class ScientifikExtension {
|
||||
var bintrayRepo: String? = null
|
||||
var kdoc: Boolean = true
|
||||
var serialization = false
|
||||
var atomicfu = false
|
||||
var io = false
|
||||
}
|
||||
|
||||
|
@ -33,9 +33,6 @@ open class ScientifikJSPlugin : Plugin<Project> {
|
||||
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}")
|
||||
}
|
||||
|
@ -16,7 +16,6 @@ open class ScientifikJVMPlugin : Plugin<Project> {
|
||||
with(project) {
|
||||
plugins.apply("org.jetbrains.kotlin.jvm")
|
||||
plugins.apply("kotlinx-serialization")
|
||||
plugins.apply("kotlinx-atomicfu")
|
||||
|
||||
repositories.applyRepos()
|
||||
|
||||
@ -36,9 +35,6 @@ open class ScientifikJVMPlugin : Plugin<Project> {
|
||||
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}")
|
||||
}
|
||||
|
@ -14,7 +14,6 @@ open class ScientifikMPPlugin : Plugin<Project> {
|
||||
|
||||
project.plugins.apply("org.jetbrains.kotlin.multiplatform")
|
||||
project.plugins.apply("kotlinx-serialization")
|
||||
project.plugins.apply("kotlinx-atomicfu")
|
||||
|
||||
project.repositories.applyRepos()
|
||||
|
||||
@ -40,9 +39,6 @@ open class ScientifikMPPlugin : Plugin<Project> {
|
||||
if (extension.serialization) {
|
||||
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:${Scientifik.ioVersion}")
|
||||
}
|
||||
@ -59,9 +55,6 @@ open class ScientifikMPPlugin : Plugin<Project> {
|
||||
dependencies {
|
||||
api(kotlin("stdlib-jdk8"))
|
||||
project.afterEvaluate {
|
||||
if (extension.atomicfu) {
|
||||
implementation("org.jetbrains.kotlinx:atomicfu:${Scientifik.atomicfuVersion}")
|
||||
}
|
||||
if (extension.io) {
|
||||
api("org.jetbrains.kotlinx:kotlinx-io-jvm:${Scientifik.ioVersion}")
|
||||
}
|
||||
@ -78,9 +71,6 @@ open class ScientifikMPPlugin : Plugin<Project> {
|
||||
dependencies {
|
||||
api(kotlin("stdlib-js"))
|
||||
project.afterEvaluate {
|
||||
if (extension.atomicfu) {
|
||||
implementation("org.jetbrains.kotlinx:atomicfu-common-js:${Scientifik.atomicfuVersion}")
|
||||
}
|
||||
if (extension.io) {
|
||||
api("org.jetbrains.kotlinx:kotlinx-io-js:${Scientifik.ioVersion}")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user