Dev #5

Merged
altavir merged 24 commits from dev into master 2020-12-28 09:44:15 +03:00
5 changed files with 62 additions and 62 deletions
Showing only changes of commit 723a959a0b - Show all commits

View File

@ -19,6 +19,7 @@ open class KScienceCommonPlugin : Plugin<Project> {
//Configuration for K-JVM plugin
pluginManager.withPlugin("org.jetbrains.kotlin.jvm") {
//logger.info("Applying KScience configuration for JVM project")
configure<KotlinJvmProjectExtension> {
explicitApiWarning()
@ -37,6 +38,7 @@ open class KScienceCommonPlugin : Plugin<Project> {
}
pluginManager.withPlugin("org.jetbrains.kotlin.js") {
//logger.info("Applying KScience configuration for JS project")
configure<KotlinJsProjectExtension> {
explicitApiWarning()

View File

@ -3,14 +3,12 @@ package ru.mipt.npm.gradle
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.apply
import org.gradle.kotlin.dsl.findPlugin
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinMultiplatformPlugin
open class KScienceMPPlugin : Plugin<Project> {
override fun apply(project: Project): Unit = project.run {
if (plugins.findPlugin(KotlinMultiplatformPlugin::class) == null) {
if (plugins.findPlugin("org.jetbrains.kotlin.multiplatform") == null) {
logger.info("Kotlin multiplatform plugin is not resolved. Adding it automatically")
pluginManager.apply(KotlinMultiplatformPlugin::class)
pluginManager.apply("org.jetbrains.kotlin.multiplatform")
}
plugins.apply(KScienceCommonPlugin::class)
}

View File

@ -5,14 +5,13 @@ import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.*
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinMultiplatformPlugin
class KScienceNativePlugin : Plugin<Project> {
override fun apply(target: Project) = target.run {
//Apply multiplatform plugin is not applied, apply it
if (plugins.findPlugin(KotlinMultiplatformPlugin::class) == null) {
if (plugins.findPlugin("org.jetbrains.kotlin.multiplatform") == null) {
logger.info("Kotlin multiplatform plugin is not resolved. Adding it automatically")
pluginManager.apply(KotlinMultiplatformPlugin::class)
pluginManager.apply("org.jetbrains.kotlin.multiplatform")
}
if (plugins.findPlugin(KScienceCommonPlugin::class) == null) {
logger.info("KScience plugin is not resolved. Adding it automatically")

View File

@ -4,7 +4,6 @@ import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.*
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinMultiplatformPlugin
/**
* Create a separate target for node
@ -12,9 +11,9 @@ import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinMultiplatformPlugin
class KScienceNodePlugin : Plugin<Project> {
override fun apply(target: Project) = target.run {
//Apply multiplatform plugin is not applied, apply it
if (plugins.findPlugin(KotlinMultiplatformPlugin::class) == null) {
if (plugins.findPlugin("org.jetbrains.kotlin.multiplatform") == null) {
logger.info("Kotlin multiplatform plugin is not resolved. Adding it automatically")
pluginManager.apply(KotlinMultiplatformPlugin::class)
pluginManager.apply("org.jetbrains.kotlin.multiplatform")
}
if (plugins.findPlugin(KScienceCommonPlugin::class) == null) {
logger.info("KScience plugin is not resolved. Adding it automatically")

View File

@ -1,8 +1,7 @@
package ru.mipt.npm.gradle
import kotlinx.atomicfu.plugin.gradle.sourceSets
import org.gradle.api.Project
import org.gradle.kotlin.dsl.findByType
import org.gradle.kotlin.dsl.configure
import org.gradle.kotlin.dsl.invoke
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
@ -23,7 +22,7 @@ internal fun Project.useDependency(
dependencyConfiguration: DependencyConfiguration = DependencyConfiguration.IMPLEMENTATION
) {
pluginManager.withPlugin("org.jetbrains.kotlin.multiplatform") {
extensions.findByType<KotlinMultiplatformExtension>()?.apply {
configure<KotlinMultiplatformExtension> {
sourceSets {
pairs.forEach { (target, dep) ->
val name = target + dependencySourceSet.suffix
@ -38,8 +37,7 @@ internal fun Project.useDependency(
}
}
}
}
}
pairs.find { it.first == "jvm" }?.let { dep ->
pluginManager.withPlugin("org.jetbrains.kotlin.jvm") {
@ -72,13 +70,16 @@ internal fun Project.useDependency(
}
}
}
}
internal fun Project.useCommonDependency(
dep: String,
dependencySourceSet: DependencySourceSet = DependencySourceSet.MAIN,
dependencyConfiguration: DependencyConfiguration = DependencyConfiguration.IMPLEMENTATION
): Unit = pluginManager.run {
withPlugin("org.jetbrains.kotlin.multiplatform") {
extensions.findByType<KotlinMultiplatformExtension>()?.apply {
configure<KotlinMultiplatformExtension> {
sourceSets.findByName("common${dependencySourceSet.suffix}")?.apply {
dependencies {
when (dependencyConfiguration) {
@ -88,8 +89,7 @@ internal fun Project.useCommonDependency(
}
}
}
}
}
withPlugin("org.jetbrains.kotlin.jvm") {
sourceSets.findByName(dependencySourceSet.setName)?.apply {
dependencies.apply {
@ -115,3 +115,5 @@ internal fun Project.useCommonDependency(
}
}
}
}
}