Fix dependency configuration
This commit is contained in:
parent
f456be46d4
commit
723a959a0b
@ -19,6 +19,7 @@ open class KScienceCommonPlugin : Plugin<Project> {
|
|||||||
|
|
||||||
//Configuration for K-JVM plugin
|
//Configuration for K-JVM plugin
|
||||||
pluginManager.withPlugin("org.jetbrains.kotlin.jvm") {
|
pluginManager.withPlugin("org.jetbrains.kotlin.jvm") {
|
||||||
|
//logger.info("Applying KScience configuration for JVM project")
|
||||||
configure<KotlinJvmProjectExtension> {
|
configure<KotlinJvmProjectExtension> {
|
||||||
explicitApiWarning()
|
explicitApiWarning()
|
||||||
|
|
||||||
@ -37,6 +38,7 @@ open class KScienceCommonPlugin : Plugin<Project> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pluginManager.withPlugin("org.jetbrains.kotlin.js") {
|
pluginManager.withPlugin("org.jetbrains.kotlin.js") {
|
||||||
|
//logger.info("Applying KScience configuration for JS project")
|
||||||
configure<KotlinJsProjectExtension> {
|
configure<KotlinJsProjectExtension> {
|
||||||
explicitApiWarning()
|
explicitApiWarning()
|
||||||
|
|
||||||
|
@ -3,14 +3,12 @@ package ru.mipt.npm.gradle
|
|||||||
import org.gradle.api.Plugin
|
import org.gradle.api.Plugin
|
||||||
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.findPlugin
|
|
||||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinMultiplatformPlugin
|
|
||||||
|
|
||||||
open class KScienceMPPlugin : Plugin<Project> {
|
open class KScienceMPPlugin : Plugin<Project> {
|
||||||
override fun apply(project: Project): Unit = project.run {
|
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")
|
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)
|
plugins.apply(KScienceCommonPlugin::class)
|
||||||
}
|
}
|
||||||
|
@ -5,14 +5,13 @@ import org.gradle.api.Plugin
|
|||||||
import org.gradle.api.Project
|
import org.gradle.api.Project
|
||||||
import org.gradle.kotlin.dsl.*
|
import org.gradle.kotlin.dsl.*
|
||||||
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
|
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
|
||||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinMultiplatformPlugin
|
|
||||||
|
|
||||||
class KScienceNativePlugin : Plugin<Project> {
|
class KScienceNativePlugin : Plugin<Project> {
|
||||||
override fun apply(target: Project) = target.run {
|
override fun apply(target: Project) = target.run {
|
||||||
//Apply multiplatform plugin is not applied, apply it
|
//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")
|
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) {
|
if (plugins.findPlugin(KScienceCommonPlugin::class) == null) {
|
||||||
logger.info("KScience plugin is not resolved. Adding it automatically")
|
logger.info("KScience plugin is not resolved. Adding it automatically")
|
||||||
|
@ -4,7 +4,6 @@ import org.gradle.api.Plugin
|
|||||||
import org.gradle.api.Project
|
import org.gradle.api.Project
|
||||||
import org.gradle.kotlin.dsl.*
|
import org.gradle.kotlin.dsl.*
|
||||||
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
|
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
|
||||||
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinMultiplatformPlugin
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a separate target for node
|
* Create a separate target for node
|
||||||
@ -12,9 +11,9 @@ import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinMultiplatformPlugin
|
|||||||
class KScienceNodePlugin : Plugin<Project> {
|
class KScienceNodePlugin : Plugin<Project> {
|
||||||
override fun apply(target: Project) = target.run {
|
override fun apply(target: Project) = target.run {
|
||||||
//Apply multiplatform plugin is not applied, apply it
|
//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")
|
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) {
|
if (plugins.findPlugin(KScienceCommonPlugin::class) == null) {
|
||||||
logger.info("KScience plugin is not resolved. Adding it automatically")
|
logger.info("KScience plugin is not resolved. Adding it automatically")
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
package ru.mipt.npm.gradle
|
package ru.mipt.npm.gradle
|
||||||
|
|
||||||
import kotlinx.atomicfu.plugin.gradle.sourceSets
|
|
||||||
import org.gradle.api.Project
|
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.gradle.kotlin.dsl.invoke
|
||||||
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
|
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
|
||||||
|
|
||||||
@ -23,7 +22,7 @@ internal fun Project.useDependency(
|
|||||||
dependencyConfiguration: DependencyConfiguration = DependencyConfiguration.IMPLEMENTATION
|
dependencyConfiguration: DependencyConfiguration = DependencyConfiguration.IMPLEMENTATION
|
||||||
) {
|
) {
|
||||||
pluginManager.withPlugin("org.jetbrains.kotlin.multiplatform") {
|
pluginManager.withPlugin("org.jetbrains.kotlin.multiplatform") {
|
||||||
extensions.findByType<KotlinMultiplatformExtension>()?.apply {
|
configure<KotlinMultiplatformExtension> {
|
||||||
sourceSets {
|
sourceSets {
|
||||||
pairs.forEach { (target, dep) ->
|
pairs.forEach { (target, dep) ->
|
||||||
val name = target + dependencySourceSet.suffix
|
val name = target + dependencySourceSet.suffix
|
||||||
@ -38,8 +37,7 @@ internal fun Project.useDependency(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pairs.find { it.first == "jvm" }?.let { dep ->
|
pairs.find { it.first == "jvm" }?.let { dep ->
|
||||||
pluginManager.withPlugin("org.jetbrains.kotlin.jvm") {
|
pluginManager.withPlugin("org.jetbrains.kotlin.jvm") {
|
||||||
@ -72,13 +70,16 @@ internal fun Project.useDependency(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
internal fun Project.useCommonDependency(
|
internal fun Project.useCommonDependency(
|
||||||
dep: String,
|
dep: String,
|
||||||
dependencySourceSet: DependencySourceSet = DependencySourceSet.MAIN,
|
dependencySourceSet: DependencySourceSet = DependencySourceSet.MAIN,
|
||||||
dependencyConfiguration: DependencyConfiguration = DependencyConfiguration.IMPLEMENTATION
|
dependencyConfiguration: DependencyConfiguration = DependencyConfiguration.IMPLEMENTATION
|
||||||
): Unit = pluginManager.run {
|
): Unit = pluginManager.run {
|
||||||
withPlugin("org.jetbrains.kotlin.multiplatform") {
|
withPlugin("org.jetbrains.kotlin.multiplatform") {
|
||||||
extensions.findByType<KotlinMultiplatformExtension>()?.apply {
|
configure<KotlinMultiplatformExtension> {
|
||||||
sourceSets.findByName("common${dependencySourceSet.suffix}")?.apply {
|
sourceSets.findByName("common${dependencySourceSet.suffix}")?.apply {
|
||||||
dependencies {
|
dependencies {
|
||||||
when (dependencyConfiguration) {
|
when (dependencyConfiguration) {
|
||||||
@ -88,8 +89,7 @@ internal fun Project.useCommonDependency(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
withPlugin("org.jetbrains.kotlin.jvm") {
|
withPlugin("org.jetbrains.kotlin.jvm") {
|
||||||
sourceSets.findByName(dependencySourceSet.setName)?.apply {
|
sourceSets.findByName(dependencySourceSet.setName)?.apply {
|
||||||
dependencies.apply {
|
dependencies.apply {
|
||||||
@ -115,3 +115,5 @@ internal fun Project.useCommonDependency(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user