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