Removed afterEvaluate from libraries definition
This commit is contained in:
parent
b7b42b18f2
commit
7b45e253b4
@ -7,7 +7,7 @@ plugins {
|
||||
}
|
||||
|
||||
group = "scientifik"
|
||||
version = "0.2.0"
|
||||
version = "0.2.1"
|
||||
|
||||
repositories {
|
||||
gradlePluginPortal()
|
||||
|
@ -1,15 +1,49 @@
|
||||
package scientifik
|
||||
|
||||
import Scientifik
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.kotlin.dsl.apply
|
||||
import org.gradle.kotlin.dsl.create
|
||||
import org.gradle.kotlin.dsl.findByType
|
||||
import org.gradle.kotlin.dsl.get
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinJsProjectExtension
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
|
||||
|
||||
private fun Project.applyMPPDependency(vararg pairs: Pair<String, String>) {
|
||||
val map = mapOf(*pairs)
|
||||
extensions.findByType<KotlinMultiplatformExtension>()?.apply {
|
||||
pairs.forEach{(target,depString)->
|
||||
sourceSets[target].apply {
|
||||
dependencies {
|
||||
api(depString)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
extensions.findByType<KotlinJvmProjectExtension>()?.apply {
|
||||
sourceSets["main"].apply {
|
||||
dependencies {
|
||||
api(map["jvmMain"] ?: error("jvmMain dependency not found"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extensions.findByType<KotlinJsProjectExtension>()?.apply {
|
||||
sourceSets["main"].apply {
|
||||
dependencies {
|
||||
api(map["jsMain"] ?: error("jsMain dependency not found"))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
open class ScientifikExtension {
|
||||
fun Project.withDokka() {
|
||||
apply(plugin = "org.jetbrains.dokka")
|
||||
subprojects {
|
||||
this.scientifik.apply{
|
||||
scientifik.apply {
|
||||
withDokka()
|
||||
}
|
||||
}
|
||||
@ -17,27 +51,31 @@ open class ScientifikExtension {
|
||||
|
||||
fun Project.withSerialization() {
|
||||
apply(plugin = "kotlinx-serialization")
|
||||
serialization = true
|
||||
applyMPPDependency(
|
||||
"commonMain" to "org.jetbrains.kotlinx:kotlinx-serialization-runtime-common:${Scientifik.serializationVersion}",
|
||||
"jvmMain" to "org.jetbrains.kotlinx:kotlinx-serialization-runtime:${Scientifik.serializationVersion}",
|
||||
"jsMain" to "org.jetbrains.kotlinx:kotlinx-serialization-runtime-js:${Scientifik.serializationVersion}"
|
||||
)
|
||||
//recursively apply to all subprojecs
|
||||
subprojects {
|
||||
this.scientifik.apply{
|
||||
scientifik.apply {
|
||||
withSerialization()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var serialization = false
|
||||
private set
|
||||
|
||||
fun Project.withIO() {
|
||||
io = true
|
||||
applyMPPDependency(
|
||||
"commonMain" to "org.jetbrains.kotlinx:kotlinx-io:${Scientifik.ioVersion}",
|
||||
"jvmMain" to "org.jetbrains.kotlinx:kotlinx-io-jvm:${Scientifik.ioVersion}",
|
||||
"jsMain" to "org.jetbrains.kotlinx:kotlinx-io-js:${Scientifik.ioVersion}"
|
||||
)
|
||||
subprojects {
|
||||
scientifik.apply {
|
||||
withIO()
|
||||
}
|
||||
}
|
||||
|
||||
var io = false
|
||||
private set
|
||||
}
|
||||
}
|
||||
|
||||
internal val Project.scientifik: ScientifikExtension
|
||||
|
@ -1,6 +1,5 @@
|
||||
package scientifik
|
||||
|
||||
import Scientifik
|
||||
import org.gradle.api.Plugin
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.tasks.Copy
|
||||
@ -30,14 +29,6 @@ open class ScientifikJSPlugin : Plugin<Project> {
|
||||
|
||||
dependencies {
|
||||
api(kotlin("stdlib-js"))
|
||||
afterEvaluate {
|
||||
if (extension.serialization) {
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-serialization-runtime:${Scientifik.serializationVersion}")
|
||||
}
|
||||
if (extension.io) {
|
||||
api("org.jetbrains.kotlinx:kotlinx-io-js:${Scientifik.ioVersion}")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package scientifik
|
||||
|
||||
import Scientifik
|
||||
import org.gradle.api.Plugin
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.plugins.JavaBasePlugin
|
||||
@ -31,17 +30,8 @@ open class ScientifikJVMPlugin : Plugin<Project> {
|
||||
configure<KotlinJvmProjectExtension> {
|
||||
val sourceSet = sourceSets["main"].apply {
|
||||
languageSettings.applySettings()
|
||||
|
||||
dependencies {
|
||||
api(kotlin("stdlib-jdk8"))
|
||||
afterEvaluate {
|
||||
if (extension.serialization) {
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-serialization-runtime:${Scientifik.serializationVersion}")
|
||||
}
|
||||
if (extension.io) {
|
||||
api("org.jetbrains.kotlinx:kotlinx-io-jvm:${Scientifik.ioVersion}")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
package scientifik
|
||||
|
||||
import Scientifik
|
||||
import org.gradle.api.Plugin
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.plugins.JavaBasePlugin
|
||||
@ -42,14 +41,6 @@ open class ScientifikMPPlugin : Plugin<Project> {
|
||||
val commonMain by getting {
|
||||
dependencies {
|
||||
api(kotlin("stdlib"))
|
||||
project.afterEvaluate {
|
||||
if (extension.serialization) {
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-serialization-runtime-common:${Scientifik.serializationVersion}")
|
||||
}
|
||||
if (extension.io) {
|
||||
api("org.jetbrains.kotlinx:kotlinx-io:${Scientifik.ioVersion}")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
val commonTest by getting {
|
||||
@ -61,15 +52,6 @@ open class ScientifikMPPlugin : Plugin<Project> {
|
||||
val jvmMain by getting {
|
||||
dependencies {
|
||||
api(kotlin("stdlib-jdk8"))
|
||||
project.afterEvaluate {
|
||||
if (extension.serialization) {
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-serialization-runtime:${Scientifik.serializationVersion}")
|
||||
}
|
||||
|
||||
if (extension.io) {
|
||||
api("org.jetbrains.kotlinx:kotlinx-io-jvm:${Scientifik.ioVersion}")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
val jvmTest by getting {
|
||||
@ -81,15 +63,6 @@ open class ScientifikMPPlugin : Plugin<Project> {
|
||||
val jsMain by getting {
|
||||
dependencies {
|
||||
api(kotlin("stdlib-js"))
|
||||
project.afterEvaluate {
|
||||
if (extension.serialization) {
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-serialization-runtime-js:${Scientifik.serializationVersion}")
|
||||
}
|
||||
|
||||
if (extension.io) {
|
||||
api("org.jetbrains.kotlinx:kotlinx-io-js:${Scientifik.ioVersion}")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
val jsTest by getting {
|
||||
|
Loading…
Reference in New Issue
Block a user