From be571a90282679fee415e748e9647b46ca19ab1d Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Wed, 25 Nov 2020 15:25:46 +0300 Subject: [PATCH] Fix dependency configuration --- .../mipt/npm/gradle/KScienceCommonPlugin.kt | 2 +- .../kotlin/ru/mipt/npm/gradle/dependencies.kt | 97 ++++++++++--------- 2 files changed, 54 insertions(+), 45 deletions(-) diff --git a/src/main/kotlin/ru/mipt/npm/gradle/KScienceCommonPlugin.kt b/src/main/kotlin/ru/mipt/npm/gradle/KScienceCommonPlugin.kt index ace2634..fdf6f90 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/KScienceCommonPlugin.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/KScienceCommonPlugin.kt @@ -112,7 +112,7 @@ open class KScienceCommonPlugin : Plugin { afterEvaluate { extensions.findByType()?.apply { targetCompatibility = KScienceVersions.JVM_TARGET - withSourcesJar() + //withSourcesJar() //withJavadocJar() } diff --git a/src/main/kotlin/ru/mipt/npm/gradle/dependencies.kt b/src/main/kotlin/ru/mipt/npm/gradle/dependencies.kt index 472d82a..78dc949 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/dependencies.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/dependencies.kt @@ -3,6 +3,8 @@ package ru.mipt.npm.gradle import org.gradle.api.Project import org.gradle.kotlin.dsl.configure import org.gradle.kotlin.dsl.invoke +import org.jetbrains.kotlin.gradle.dsl.KotlinJsProjectExtension +import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension enum class DependencyConfiguration { @@ -37,39 +39,41 @@ internal fun Project.useDependency( } } } + } + } - - pairs.find { it.first == "jvm" }?.let { dep -> - pluginManager.withPlugin("org.jetbrains.kotlin.jvm") { - sourceSets.findByName(dependencySourceSet.setName)?.apply { - dependencies.apply { - val configurationName = when (dependencyConfiguration) { - DependencyConfiguration.API -> apiConfigurationName - DependencyConfiguration.IMPLEMENTATION -> implementationConfigurationName - DependencyConfiguration.COMPILE_ONLY -> compileOnlyConfigurationName - } - add(configurationName, dep.second) - } - } - } - } - - pairs.find { it.first == "js" }?.let { dep -> - pluginManager.withPlugin("org.jetbrains.kotlin.js") { - sourceSets.findByName(dependencySourceSet.setName)?.apply { - dependencies.apply { - val configurationName = when (dependencyConfiguration) { - DependencyConfiguration.API -> apiConfigurationName - DependencyConfiguration.IMPLEMENTATION -> implementationConfigurationName - DependencyConfiguration.COMPILE_ONLY -> compileOnlyConfigurationName - } - add(configurationName, dep.second) + pairs.find { it.first == "jvm" }?.let { dep -> + pluginManager.withPlugin("org.jetbrains.kotlin.jvm") { + configure { + sourceSets.findByName(dependencySourceSet.setName)?.apply { + dependencies.apply { + val configurationName = when (dependencyConfiguration) { + DependencyConfiguration.API -> apiConfigurationName + DependencyConfiguration.IMPLEMENTATION -> implementationConfigurationName + DependencyConfiguration.COMPILE_ONLY -> compileOnlyConfigurationName } + add(configurationName, dep.second) } } } } + } + pairs.find { it.first == "js" }?.let { dep -> + pluginManager.withPlugin("org.jetbrains.kotlin.js") { + configure { + sourceSets.findByName(dependencySourceSet.setName)?.apply { + dependencies.apply { + val configurationName = when (dependencyConfiguration) { + DependencyConfiguration.API -> apiConfigurationName + DependencyConfiguration.IMPLEMENTATION -> implementationConfigurationName + DependencyConfiguration.COMPILE_ONLY -> compileOnlyConfigurationName + } + add(configurationName, dep.second) + } + } + } + } } } @@ -89,29 +93,34 @@ internal fun Project.useCommonDependency( } } } + } + } - withPlugin("org.jetbrains.kotlin.jvm") { - sourceSets.findByName(dependencySourceSet.setName)?.apply { - dependencies.apply { - val configurationName = when (dependencyConfiguration) { - DependencyConfiguration.API -> apiConfigurationName - DependencyConfiguration.IMPLEMENTATION -> implementationConfigurationName - DependencyConfiguration.COMPILE_ONLY -> compileOnlyConfigurationName - } - add(configurationName, dep) + + withPlugin("org.jetbrains.kotlin.jvm") { + configure { + sourceSets.findByName(dependencySourceSet.setName)?.apply { + dependencies.apply { + val configurationName = when (dependencyConfiguration) { + DependencyConfiguration.API -> apiConfigurationName + DependencyConfiguration.IMPLEMENTATION -> implementationConfigurationName + DependencyConfiguration.COMPILE_ONLY -> compileOnlyConfigurationName } + add(configurationName, dep) } } - withPlugin("org.jetbrains.kotlin.js") { - sourceSets.findByName(dependencySourceSet.setName)?.apply { - dependencies.apply { - val configurationName = when (dependencyConfiguration) { - DependencyConfiguration.API -> apiConfigurationName - DependencyConfiguration.IMPLEMENTATION -> implementationConfigurationName - DependencyConfiguration.COMPILE_ONLY -> compileOnlyConfigurationName - } - add(configurationName, dep) + } + } + withPlugin("org.jetbrains.kotlin.js") { + configure { + sourceSets.findByName(dependencySourceSet.setName)?.apply { + dependencies.apply { + val configurationName = when (dependencyConfiguration) { + DependencyConfiguration.API -> apiConfigurationName + DependencyConfiguration.IMPLEMENTATION -> implementationConfigurationName + DependencyConfiguration.COMPILE_ONLY -> compileOnlyConfigurationName } + add(configurationName, dep) } } }