Dev #5
25
CHANGELOG.md
25
CHANGELOG.md
@ -7,19 +7,24 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
### Added
|
### Added
|
||||||
- Changelog plugin automatically applied to `project`
|
- Changelog plugin automatically applied to `project`.
|
||||||
- Feature matrix and Readme generation task for a `project` plugin
|
- Feature matrix and Readme generation task for a `project` plugin.
|
||||||
|
- Add `binary-compatibility-validator` to the `project` plugin.
|
||||||
|
- Separate `yamlKt` serialization target
|
||||||
|
- Separate `ain` plugin
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- Remove node plugin and make node binaries available by default
|
- Remove node plugin. Node binaries should be turned on manually.
|
||||||
- Use default webpack distribution path
|
- Use default webpack distribution path.
|
||||||
- `ru.mipt.npm.base` -> `ru.mipt.npm.project`
|
- `ru.mipt.npm.base` -> `ru.mipt.npm.project`.
|
||||||
- Move publishing out of general extension and apply it to project plugin instead.
|
- Move publishing out of general extension and apply it to project plugin instead.
|
||||||
|
- Platform plugins are now simple references to common plugin
|
||||||
|
|
||||||
### Deprecated
|
### Deprecated
|
||||||
|
- Support of `kaml` and `snake-yaml` in favor of `yamlKt`
|
||||||
|
|
||||||
### Removed
|
### Removed
|
||||||
- Node plugin
|
- Node plugin.
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
@ -28,14 +33,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
### Added
|
### Added
|
||||||
- Migrate to kotlin 1.4.0
|
- Migrate to kotlin 1.4.0
|
||||||
- Separate Native (current platform) and nodeJs plugins
|
- Separate Native (current platform) and nodeJs plugins.
|
||||||
- Add `application()` toggle in plugin configuration to produce binaries on JS and applicaion plugin on jvm.
|
- Add `application()` toggle in plugin configuration to produce binaries on JS and applicaion plugin on jvm.
|
||||||
- Add `publish` to expose publishing configuration
|
- Add `publish` to expose publishing configuration.
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
-Publishing in bintray now is automatic
|
-Publishing in bintray now is automatic.
|
||||||
|
|
||||||
## [0.5.2]
|
## [0.5.2]
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
- Copy resources for jvm modules and jvm source sets in mpp
|
- Copy resources for jvm modules and jvm source sets in mpp.
|
@ -2,11 +2,11 @@ plugins {
|
|||||||
`java-gradle-plugin`
|
`java-gradle-plugin`
|
||||||
`kotlin-dsl`
|
`kotlin-dsl`
|
||||||
`maven-publish`
|
`maven-publish`
|
||||||
id("org.jetbrains.changelog") version "0.5.0"
|
id("org.jetbrains.changelog") version "0.6.2"
|
||||||
}
|
}
|
||||||
|
|
||||||
group = "ru.mipt.npm"
|
group = "ru.mipt.npm"
|
||||||
version = "0.6.1"
|
version = "0.7.0"
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
gradlePluginPortal()
|
gradlePluginPortal()
|
||||||
@ -16,7 +16,7 @@ repositories {
|
|||||||
maven("https://dl.bintray.com/kotlin/kotlin-dev")
|
maven("https://dl.bintray.com/kotlin/kotlin-dev")
|
||||||
}
|
}
|
||||||
|
|
||||||
val kotlinVersion = "1.4.10"
|
val kotlinVersion = "1.4.20"
|
||||||
|
|
||||||
java {
|
java {
|
||||||
targetCompatibility = JavaVersion.VERSION_1_8
|
targetCompatibility = JavaVersion.VERSION_1_8
|
||||||
@ -27,13 +27,19 @@ dependencies {
|
|||||||
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
|
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
|
||||||
implementation("org.jetbrains.kotlin:kotlin-serialization:$kotlinVersion")
|
implementation("org.jetbrains.kotlin:kotlin-serialization:$kotlinVersion")
|
||||||
implementation("org.jetbrains.kotlinx:atomicfu-gradle-plugin:0.14.4")
|
implementation("org.jetbrains.kotlinx:atomicfu-gradle-plugin:0.14.4")
|
||||||
implementation("org.jetbrains.dokka:dokka-gradle-plugin:1.4.10")
|
implementation("org.jetbrains.dokka:dokka-gradle-plugin:1.4.10.2")
|
||||||
implementation("org.jetbrains.dokka:dokka-base:1.4.10")
|
implementation("org.jetbrains.dokka:dokka-base:1.4.10")
|
||||||
implementation("org.jetbrains.intellij.plugins:gradle-changelog-plugin:0.5.0")
|
implementation("org.jetbrains.intellij.plugins:gradle-changelog-plugin:0.6.2")
|
||||||
|
implementation("org.jetbrains.kotlinx:binary-compatibility-validator:0.2.4")
|
||||||
}
|
}
|
||||||
|
|
||||||
gradlePlugin {
|
gradlePlugin {
|
||||||
plugins {
|
plugins {
|
||||||
|
create("kscience.common"){
|
||||||
|
id = "ru.mipt.npm.kscience"
|
||||||
|
description = "The generalized kscience plugin that works in conjunction with any kotlin plugin"
|
||||||
|
implementationClass = "ru.mipt.npm.gradle.KScienceCommonPlugin"
|
||||||
|
}
|
||||||
create("kscience.project"){
|
create("kscience.project"){
|
||||||
id = "ru.mipt.npm.project"
|
id = "ru.mipt.npm.project"
|
||||||
description = "The root plugin for multimodule project infrastructure"
|
description = "The root plugin for multimodule project infrastructure"
|
||||||
@ -68,6 +74,12 @@ gradlePlugin {
|
|||||||
description = "Additional native targets to be use alongside mpp"
|
description = "Additional native targets to be use alongside mpp"
|
||||||
implementationClass = "ru.mipt.npm.gradle.KScienceNativePlugin"
|
implementationClass = "ru.mipt.npm.gradle.KScienceNativePlugin"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
create("kscience.node") {
|
||||||
|
id = "ru.mipt.npm.node"
|
||||||
|
description = "Additional nodejs target to be use alongside mpp"
|
||||||
|
implementationClass = "ru.mipt.npm.gradle.KScienceNodePlugin"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
140
src/main/kotlin/ru/mipt/npm/gradle/KScienceCommonPlugin.kt
Normal file
140
src/main/kotlin/ru/mipt/npm/gradle/KScienceCommonPlugin.kt
Normal file
@ -0,0 +1,140 @@
|
|||||||
|
package ru.mipt.npm.gradle
|
||||||
|
|
||||||
|
import org.gradle.api.Plugin
|
||||||
|
import org.gradle.api.Project
|
||||||
|
import org.gradle.api.plugins.JavaPluginExtension
|
||||||
|
import org.gradle.api.tasks.Copy
|
||||||
|
import org.gradle.api.tasks.testing.Test
|
||||||
|
import org.gradle.kotlin.dsl.*
|
||||||
|
import org.jetbrains.kotlin.gradle.dsl.KotlinJsProjectExtension
|
||||||
|
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmCompile
|
||||||
|
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension
|
||||||
|
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
|
||||||
|
|
||||||
|
open class KScienceCommonPlugin : Plugin<Project> {
|
||||||
|
override fun apply(project: Project): Unit = project.run {
|
||||||
|
//Common configuration
|
||||||
|
registerKScienceExtension()
|
||||||
|
repositories.applyRepos()
|
||||||
|
|
||||||
|
//Configuration for K-JVM plugin
|
||||||
|
pluginManager.withPlugin("org.jetbrains.kotlin.jvm") {
|
||||||
|
//logger.info("Applying KScience configuration for JVM project")
|
||||||
|
configure<KotlinJvmProjectExtension> {
|
||||||
|
explicitApiWarning()
|
||||||
|
|
||||||
|
sourceSets["main"].apply {
|
||||||
|
languageSettings.applySettings()
|
||||||
|
}
|
||||||
|
|
||||||
|
sourceSets["test"].apply {
|
||||||
|
languageSettings.applySettings()
|
||||||
|
dependencies {
|
||||||
|
implementation(kotlin("test-junit5"))
|
||||||
|
implementation("org.junit.jupiter:junit-jupiter:5.6.1")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pluginManager.withPlugin("org.jetbrains.kotlin.js") {
|
||||||
|
//logger.info("Applying KScience configuration for JS project")
|
||||||
|
configure<KotlinJsProjectExtension> {
|
||||||
|
explicitApiWarning()
|
||||||
|
|
||||||
|
js(IR) {
|
||||||
|
browser()
|
||||||
|
}
|
||||||
|
|
||||||
|
sourceSets["main"].apply {
|
||||||
|
languageSettings.applySettings()
|
||||||
|
}
|
||||||
|
|
||||||
|
sourceSets["test"].apply {
|
||||||
|
languageSettings.applySettings()
|
||||||
|
dependencies {
|
||||||
|
implementation(kotlin("test-js"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pluginManager.withPlugin("org.jetbrains.kotlin.multiplatform") {
|
||||||
|
configure<KotlinMultiplatformExtension> {
|
||||||
|
explicitApiWarning()
|
||||||
|
|
||||||
|
jvm {
|
||||||
|
compilations.all {
|
||||||
|
kotlinOptions {
|
||||||
|
// useIR = true
|
||||||
|
jvmTarget = KScienceVersions.JVM_TARGET.toString()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
js(IR) {
|
||||||
|
browser()
|
||||||
|
}
|
||||||
|
|
||||||
|
sourceSets.invoke {
|
||||||
|
val commonMain by getting
|
||||||
|
val commonTest by getting {
|
||||||
|
dependencies {
|
||||||
|
implementation(kotlin("test-common"))
|
||||||
|
implementation(kotlin("test-annotations-common"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
val jvmMain by getting
|
||||||
|
val jvmTest by getting {
|
||||||
|
dependencies {
|
||||||
|
implementation(kotlin("test-junit5"))
|
||||||
|
implementation("org.junit.jupiter:junit-jupiter:5.6.1")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
val jsMain by getting
|
||||||
|
val jsTest by getting {
|
||||||
|
dependencies {
|
||||||
|
implementation(kotlin("test-js"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
afterEvaluate {
|
||||||
|
targets.all {
|
||||||
|
sourceSets.all {
|
||||||
|
languageSettings.applySettings()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
afterEvaluate {
|
||||||
|
extensions.findByType<JavaPluginExtension>()?.apply {
|
||||||
|
targetCompatibility = KScienceVersions.JVM_TARGET
|
||||||
|
//withSourcesJar()
|
||||||
|
//withJavadocJar()
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.apply {
|
||||||
|
withType<KotlinJvmCompile> {
|
||||||
|
kotlinOptions {
|
||||||
|
// useIR = true
|
||||||
|
jvmTarget = KScienceVersions.JVM_TARGET.toString()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
withType<Test> {
|
||||||
|
useJUnitPlatform()
|
||||||
|
}
|
||||||
|
|
||||||
|
(findByName("processResources") as? Copy)?.apply {
|
||||||
|
fromDependencies("runtimeClasspath")
|
||||||
|
}
|
||||||
|
|
||||||
|
(findByName("jsProcessResources") as? Copy)?.apply {
|
||||||
|
fromDependencies("jsRuntimeClasspath")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,7 @@
|
|||||||
package ru.mipt.npm.gradle
|
package ru.mipt.npm.gradle
|
||||||
|
|
||||||
import org.gradle.api.Project
|
import org.gradle.api.Project
|
||||||
|
import org.gradle.api.plugins.ApplicationPlugin
|
||||||
import org.gradle.kotlin.dsl.findByType
|
import org.gradle.kotlin.dsl.findByType
|
||||||
import org.jetbrains.kotlin.gradle.dsl.KotlinJsProjectExtension
|
import org.jetbrains.kotlin.gradle.dsl.KotlinJsProjectExtension
|
||||||
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
|
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
|
||||||
@ -70,14 +71,17 @@ class KScienceExtension(val project: Project) {
|
|||||||
project.extensions.findByType<KotlinProjectExtension>()?.apply {
|
project.extensions.findByType<KotlinProjectExtension>()?.apply {
|
||||||
explicitApi = null
|
explicitApi = null
|
||||||
}
|
}
|
||||||
|
|
||||||
project.pluginManager.withPlugin("org.jetbrains.kotlin.jvm") {
|
project.pluginManager.withPlugin("org.jetbrains.kotlin.jvm") {
|
||||||
project.plugins.apply("org.gradle.application")
|
project.plugins.apply(ApplicationPlugin::class.java)
|
||||||
}
|
}
|
||||||
|
|
||||||
project.extensions.findByType<KotlinJsProjectExtension>()?.apply {
|
project.extensions.findByType<KotlinJsProjectExtension>()?.apply {
|
||||||
js {
|
js {
|
||||||
binaries.executable()
|
binaries.executable()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
project.extensions.findByType<KotlinMultiplatformExtension>()?.apply {
|
project.extensions.findByType<KotlinMultiplatformExtension>()?.apply {
|
||||||
js {
|
js {
|
||||||
binaries.executable()
|
binaries.executable()
|
||||||
@ -86,7 +90,6 @@ class KScienceExtension(val project: Project) {
|
|||||||
binaries.executable()
|
binaries.executable()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,47 +2,15 @@ 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.api.tasks.Copy
|
import org.gradle.kotlin.dsl.apply
|
||||||
import org.gradle.kotlin.dsl.configure
|
|
||||||
import org.gradle.kotlin.dsl.get
|
|
||||||
import org.gradle.kotlin.dsl.getValue
|
|
||||||
import org.gradle.kotlin.dsl.getting
|
|
||||||
import org.jetbrains.kotlin.gradle.dsl.KotlinJsProjectExtension
|
|
||||||
|
|
||||||
open class KScienceJSPlugin : Plugin<Project> {
|
open class KScienceJSPlugin : Plugin<Project> {
|
||||||
override fun apply(project: Project): Unit = project.run {
|
override fun apply(project: Project): Unit = project.run {
|
||||||
plugins.apply("org.jetbrains.kotlin.js")
|
if (plugins.findPlugin("org.jetbrains.kotlin.js") == null) {
|
||||||
registerKScienceExtension()
|
pluginManager.apply("org.jetbrains.kotlin.js")
|
||||||
|
} else {
|
||||||
repositories.applyRepos()
|
logger.info("Kotlin JS plugin is already present")
|
||||||
|
|
||||||
configure<KotlinJsProjectExtension> {
|
|
||||||
explicitApiWarning()
|
|
||||||
js(IR) {
|
|
||||||
browser()
|
|
||||||
nodejs()
|
|
||||||
}
|
|
||||||
sourceSets["main"].apply {
|
|
||||||
languageSettings.applySettings()
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
api(kotlin("stdlib-js"))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sourceSets["test"].apply {
|
|
||||||
languageSettings.applySettings()
|
|
||||||
dependencies {
|
|
||||||
implementation(kotlin("test-js"))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.apply {
|
|
||||||
|
|
||||||
val processResources by getting(Copy::class)
|
|
||||||
processResources.copyJSResources(configurations["runtimeClasspath"])
|
|
||||||
}
|
}
|
||||||
|
plugins.apply(KScienceCommonPlugin::class)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -2,86 +2,16 @@ 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.api.plugins.JavaPluginExtension
|
import org.gradle.kotlin.dsl.apply
|
||||||
import org.gradle.api.publish.PublishingExtension
|
|
||||||
import org.gradle.api.publish.maven.MavenPublication
|
|
||||||
import org.gradle.api.tasks.Copy
|
|
||||||
import org.gradle.api.tasks.bundling.Jar
|
|
||||||
import org.gradle.api.tasks.testing.Test
|
|
||||||
import org.gradle.kotlin.dsl.*
|
|
||||||
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension
|
|
||||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
|
||||||
|
|
||||||
open class KScienceJVMPlugin : Plugin<Project> {
|
open class KScienceJVMPlugin : Plugin<Project> {
|
||||||
override fun apply(project: Project): Unit = project.run {
|
override fun apply(project: Project): Unit = project.run {
|
||||||
plugins.apply("org.jetbrains.kotlin.jvm")
|
if (plugins.findPlugin("org.jetbrains.kotlin.jvm") == null) {
|
||||||
registerKScienceExtension()
|
pluginManager.apply("org.jetbrains.kotlin.jvm")
|
||||||
|
} else {
|
||||||
repositories.applyRepos()
|
logger.info("Kotlin JVM plugin is already present")
|
||||||
|
|
||||||
extensions.findByType<JavaPluginExtension>()?.apply {
|
|
||||||
targetCompatibility = KScienceVersions.JVM_TARGET
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.withType<KotlinCompile> {
|
|
||||||
kotlinOptions {
|
|
||||||
// useIR = true
|
|
||||||
jvmTarget = KScienceVersions.JVM_TARGET.toString()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
configure<KotlinJvmProjectExtension> {
|
|
||||||
explicitApiWarning()
|
|
||||||
val sourceSet = sourceSets["main"].apply {
|
|
||||||
languageSettings.applySettings()
|
|
||||||
}
|
|
||||||
|
|
||||||
sourceSets["test"].apply {
|
|
||||||
languageSettings.applySettings()
|
|
||||||
dependencies {
|
|
||||||
implementation(kotlin("test-junit5"))
|
|
||||||
implementation("org.junit.jupiter:junit-jupiter:5.6.1")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
val sourcesJar by tasks.registering(Jar::class) {
|
|
||||||
archiveClassifier.set("sources")
|
|
||||||
from(sourceSet.kotlin.srcDirs.first())
|
|
||||||
}
|
|
||||||
|
|
||||||
pluginManager.withPlugin("maven-publish") {
|
|
||||||
|
|
||||||
configure<PublishingExtension> {
|
|
||||||
publications {
|
|
||||||
register("jvm", MavenPublication::class) {
|
|
||||||
from(components["java"])
|
|
||||||
artifact(sourcesJar.get())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// pluginManager.withPlugin("org.jetbrains.dokka") {
|
|
||||||
// logger.info("Adding dokka functionality to project ${project.name}")
|
|
||||||
|
|
||||||
// val dokkaHtml by tasks.getting(DokkaTask::class){
|
|
||||||
// dokkaSourceSets {
|
|
||||||
// configureEach {
|
|
||||||
// jdkVersion.set(11)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.apply {
|
|
||||||
withType<Test>() {
|
|
||||||
useJUnitPlatform()
|
|
||||||
}
|
|
||||||
|
|
||||||
val processResources by getting(Copy::class)
|
|
||||||
processResources.copyJVMResources(configurations["runtimeClasspath"])
|
|
||||||
}
|
}
|
||||||
|
plugins.apply(KScienceCommonPlugin::class)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,101 +2,14 @@ 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.api.tasks.Copy
|
import org.gradle.kotlin.dsl.apply
|
||||||
import org.gradle.api.tasks.testing.Test
|
|
||||||
import org.gradle.kotlin.dsl.*
|
|
||||||
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
|
|
||||||
|
|
||||||
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 {
|
||||||
plugins.apply("org.jetbrains.kotlin.multiplatform")
|
if (plugins.findPlugin("org.jetbrains.kotlin.multiplatform") == null) {
|
||||||
registerKScienceExtension()
|
logger.info("Kotlin multiplatform plugin is not resolved. Adding it automatically")
|
||||||
repositories.applyRepos()
|
pluginManager.apply("org.jetbrains.kotlin.multiplatform")
|
||||||
|
|
||||||
configure<KotlinMultiplatformExtension> {
|
|
||||||
explicitApiWarning()
|
|
||||||
|
|
||||||
jvm {
|
|
||||||
compilations.all {
|
|
||||||
kotlinOptions {
|
|
||||||
// useIR = true
|
|
||||||
jvmTarget = KScienceVersions.JVM_TARGET.toString()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
js(IR) {
|
|
||||||
browser()
|
|
||||||
nodejs()
|
|
||||||
}
|
|
||||||
|
|
||||||
sourceSets.invoke {
|
|
||||||
val commonMain by getting
|
|
||||||
val commonTest by getting {
|
|
||||||
dependencies {
|
|
||||||
implementation(kotlin("test-common"))
|
|
||||||
implementation(kotlin("test-annotations-common"))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
val jvmMain by getting
|
|
||||||
val jvmTest by getting {
|
|
||||||
dependencies {
|
|
||||||
implementation(kotlin("test-junit5"))
|
|
||||||
implementation("org.junit.jupiter:junit-jupiter:5.6.1")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
val jsMain by getting
|
|
||||||
val jsTest by getting {
|
|
||||||
dependencies {
|
|
||||||
implementation(kotlin("test-js"))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
afterEvaluate {
|
|
||||||
targets.all {
|
|
||||||
sourceSets.all {
|
|
||||||
languageSettings.applySettings()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// pluginManager.withPlugin("org.jetbrains.dokka") {
|
|
||||||
// logger.info("Adding dokka functionality to project ${this@run.name}")
|
|
||||||
//
|
|
||||||
// val dokkaHtml by tasks.getting(DokkaTask::class) {
|
|
||||||
// dokkaSourceSets {
|
|
||||||
// register("commonMain") {
|
|
||||||
// displayName = "common"
|
|
||||||
// platform = "common"
|
|
||||||
// }
|
|
||||||
// register("jvmMain") {
|
|
||||||
// displayName = "jvm"
|
|
||||||
// platform = "jvm"
|
|
||||||
// }
|
|
||||||
// register("jsMain") {
|
|
||||||
// displayName = "js"
|
|
||||||
// platform = "js"
|
|
||||||
// }
|
|
||||||
// configureEach {
|
|
||||||
// jdkVersion = 11
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
tasks.apply {
|
|
||||||
withType<Test> {
|
|
||||||
useJUnitPlatform()
|
|
||||||
}
|
|
||||||
|
|
||||||
val jsProcessResources by getting(Copy::class)
|
|
||||||
jsProcessResources.copyJSResources(configurations["jsRuntimeClasspath"])
|
|
||||||
|
|
||||||
val jvmProcessResources by getting(Copy::class)
|
|
||||||
jvmProcessResources.copyJVMResources(configurations["jvmRuntimeClasspath"])
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
plugins.apply(KScienceCommonPlugin::class)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,9 +9,13 @@ import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
|
|||||||
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(KScienceMPPlugin::class) == null) {
|
if (plugins.findPlugin("org.jetbrains.kotlin.multiplatform") == null) {
|
||||||
logger.info("Multiplatform KScience plugin is not resolved. Adding it automatically")
|
logger.info("Kotlin multiplatform plugin is not resolved. Adding it automatically")
|
||||||
pluginManager.apply(KScienceMPPlugin::class)
|
pluginManager.apply("org.jetbrains.kotlin.multiplatform")
|
||||||
|
}
|
||||||
|
if (plugins.findPlugin(KScienceCommonPlugin::class) == null) {
|
||||||
|
logger.info("KScience plugin is not resolved. Adding it automatically")
|
||||||
|
pluginManager.apply(KScienceCommonPlugin::class)
|
||||||
}
|
}
|
||||||
|
|
||||||
configure<KotlinMultiplatformExtension> {
|
configure<KotlinMultiplatformExtension> {
|
||||||
|
46
src/main/kotlin/ru/mipt/npm/gradle/KScienceNodePlugin.kt
Normal file
46
src/main/kotlin/ru/mipt/npm/gradle/KScienceNodePlugin.kt
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
package ru.mipt.npm.gradle
|
||||||
|
|
||||||
|
import org.gradle.api.Plugin
|
||||||
|
import org.gradle.api.Project
|
||||||
|
import org.gradle.kotlin.dsl.*
|
||||||
|
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a separate target for node
|
||||||
|
*/
|
||||||
|
class KScienceNodePlugin : Plugin<Project> {
|
||||||
|
override fun apply(target: Project) = target.run {
|
||||||
|
//Apply multiplatform plugin is not applied, apply it
|
||||||
|
if (plugins.findPlugin("org.jetbrains.kotlin.multiplatform") == null) {
|
||||||
|
logger.info("Kotlin multiplatform plugin is not resolved. Adding it automatically")
|
||||||
|
pluginManager.apply("org.jetbrains.kotlin.multiplatform")
|
||||||
|
}
|
||||||
|
if (plugins.findPlugin(KScienceCommonPlugin::class) == null) {
|
||||||
|
logger.info("KScience plugin is not resolved. Adding it automatically")
|
||||||
|
pluginManager.apply(KScienceCommonPlugin::class)
|
||||||
|
}
|
||||||
|
|
||||||
|
configure<KotlinMultiplatformExtension> {
|
||||||
|
js(name = "node", compiler = IR) {
|
||||||
|
nodejs()
|
||||||
|
}
|
||||||
|
sourceSets {
|
||||||
|
val commonMain by getting
|
||||||
|
val nodeMain by creating {
|
||||||
|
dependsOn(commonMain)
|
||||||
|
dependencies{
|
||||||
|
api("org.jetbrains.kotlinx:kotlinx-nodejs:${KScienceVersions.kotlinxNodeVersion}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val commonTest by getting
|
||||||
|
|
||||||
|
val nodeTest by creating {
|
||||||
|
dependsOn(nodeMain)
|
||||||
|
dependsOn(commonTest)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,7 @@
|
|||||||
package ru.mipt.npm.gradle
|
package ru.mipt.npm.gradle
|
||||||
|
|
||||||
import groovy.text.SimpleTemplateEngine
|
import groovy.text.SimpleTemplateEngine
|
||||||
|
import kotlinx.validation.BinaryCompatibilityValidatorPlugin
|
||||||
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.*
|
import org.gradle.kotlin.dsl.*
|
||||||
@ -101,6 +102,8 @@ open class KScienceProjectPlugin : Plugin<Project> {
|
|||||||
override fun apply(target: Project): Unit = target.run {
|
override fun apply(target: Project): Unit = target.run {
|
||||||
apply<ChangelogPlugin>()
|
apply<ChangelogPlugin>()
|
||||||
apply<DokkaPlugin>()
|
apply<DokkaPlugin>()
|
||||||
|
apply<BinaryCompatibilityValidatorPlugin>()
|
||||||
|
|
||||||
val rootReadmeExtension = KScienceReadmeExtension(this)
|
val rootReadmeExtension = KScienceReadmeExtension(this)
|
||||||
extensions.add("ksciencePublish", KSciencePublishingExtension(this))
|
extensions.add("ksciencePublish", KSciencePublishingExtension(this))
|
||||||
extensions.add("readme", rootReadmeExtension)
|
extensions.add("readme", rootReadmeExtension)
|
||||||
|
@ -6,15 +6,19 @@ import org.gradle.api.JavaVersion
|
|||||||
* Build constants
|
* Build constants
|
||||||
*/
|
*/
|
||||||
object KScienceVersions {
|
object KScienceVersions {
|
||||||
const val coroutinesVersion = "1.3.9"
|
const val kotlinVersion = "1.4.20"
|
||||||
const val serializationVersion = "1.0.0-RC"
|
const val kotlinxNodeVersion = "0.0.7"
|
||||||
|
const val coroutinesVersion = "1.4.1"
|
||||||
|
const val serializationVersion = "1.0.1"
|
||||||
const val atomicVersion = "0.14.4"
|
const val atomicVersion = "0.14.4"
|
||||||
|
|
||||||
val JVM_TARGET = JavaVersion.VERSION_11
|
val JVM_TARGET = JavaVersion.VERSION_11
|
||||||
|
|
||||||
object Serialization{
|
object Serialization{
|
||||||
const val xmlVersion = "0.80.0-RC"//to be fixed
|
const val xmlVersion = "0.80.1"
|
||||||
|
@Deprecated("Use yamlKt instead")
|
||||||
const val yamlVersion = "0.21.0"
|
const val yamlVersion = "0.21.0"
|
||||||
const val bsonVersion = "0.4.1-rc"
|
const val bsonVersion = "0.4.2"
|
||||||
|
const val yamlKtVersion = "0.7.4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,17 @@ class SerializationTargets(
|
|||||||
val sourceSet: DependencySourceSet,
|
val sourceSet: DependencySourceSet,
|
||||||
val configuration: DependencyConfiguration
|
val configuration: DependencyConfiguration
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
fun Project.json(
|
||||||
|
version: String = KScienceVersions.serializationVersion
|
||||||
|
) {
|
||||||
|
useCommonDependency(
|
||||||
|
"org.jetbrains.kotlinx:kotlinx-serialization-json:$version",
|
||||||
|
dependencySourceSet = sourceSet,
|
||||||
|
dependencyConfiguration = configuration
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
fun Project.cbor(
|
fun Project.cbor(
|
||||||
version: String = KScienceVersions.serializationVersion
|
version: String = KScienceVersions.serializationVersion
|
||||||
) {
|
) {
|
||||||
@ -34,15 +45,14 @@ class SerializationTargets(
|
|||||||
repositories {
|
repositories {
|
||||||
maven("https://dl.bintray.com/pdvrieze/maven")
|
maven("https://dl.bintray.com/pdvrieze/maven")
|
||||||
}
|
}
|
||||||
useDependency(
|
useCommonDependency(
|
||||||
"common" to "net.devrieze:xmlutil-serialization:$version",
|
"net.devrieze:xmlutil-serialization:$version",
|
||||||
"jvm" to "net.devrieze:xmlutil-serialization:$version",
|
|
||||||
"js" to "net.devrieze:xmlutil-serialization:$version",
|
|
||||||
dependencySourceSet = sourceSet,
|
dependencySourceSet = sourceSet,
|
||||||
dependencyConfiguration = configuration
|
dependencyConfiguration = configuration
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated("Use multiplatform yamlKt instead")
|
||||||
fun Project.yaml(
|
fun Project.yaml(
|
||||||
version: String = KScienceVersions.Serialization.yamlVersion
|
version: String = KScienceVersions.Serialization.yamlVersion
|
||||||
) {
|
) {
|
||||||
@ -53,6 +63,16 @@ class SerializationTargets(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun Project.yamlKt(
|
||||||
|
version: String = KScienceVersions.Serialization.yamlVersion
|
||||||
|
) {
|
||||||
|
useCommonDependency(
|
||||||
|
"net.mamoe.yamlkt:yamlkt:$version",
|
||||||
|
dependencySourceSet = sourceSet,
|
||||||
|
dependencyConfiguration = configuration
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
fun Project.bson(
|
fun Project.bson(
|
||||||
version: String = KScienceVersions.Serialization.bsonVersion
|
version: String = KScienceVersions.Serialization.bsonVersion
|
||||||
) {
|
) {
|
@ -1,9 +1,9 @@
|
|||||||
package ru.mipt.npm.gradle
|
package ru.mipt.npm.gradle
|
||||||
|
|
||||||
import org.gradle.api.artifacts.Configuration
|
|
||||||
import org.gradle.api.artifacts.ProjectDependency
|
import org.gradle.api.artifacts.ProjectDependency
|
||||||
import org.gradle.api.artifacts.dsl.RepositoryHandler
|
import org.gradle.api.artifacts.dsl.RepositoryHandler
|
||||||
import org.gradle.api.tasks.Copy
|
import org.gradle.api.tasks.Copy
|
||||||
|
import org.gradle.kotlin.dsl.get
|
||||||
import org.gradle.kotlin.dsl.maven
|
import org.gradle.kotlin.dsl.maven
|
||||||
import org.jetbrains.kotlin.gradle.plugin.LanguageSettingsBuilder
|
import org.jetbrains.kotlin.gradle.plugin.LanguageSettingsBuilder
|
||||||
|
|
||||||
@ -15,6 +15,7 @@ internal fun LanguageSettingsBuilder.applySettings(): Unit {
|
|||||||
useExperimentalAnnotation("kotlin.ExperimentalStdlibApi")
|
useExperimentalAnnotation("kotlin.ExperimentalStdlibApi")
|
||||||
useExperimentalAnnotation("kotlin.time.ExperimentalTime")
|
useExperimentalAnnotation("kotlin.time.ExperimentalTime")
|
||||||
useExperimentalAnnotation("kotlin.contracts.ExperimentalContracts")
|
useExperimentalAnnotation("kotlin.contracts.ExperimentalContracts")
|
||||||
|
useExperimentalAnnotation("kotlin.js.ExperimentalJsExport")
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun RepositoryHandler.applyRepos(): Unit {
|
internal fun RepositoryHandler.applyRepos(): Unit {
|
||||||
@ -29,59 +30,54 @@ internal fun RepositoryHandler.applyRepos(): Unit {
|
|||||||
maven("https://dl.bintray.com/mipt-npm/dataforge")
|
maven("https://dl.bintray.com/mipt-npm/dataforge")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal fun Copy.fromDependencies(configurationName: String) = project.afterEvaluate {
|
||||||
internal fun Copy.copyJSResources(configuration: Configuration): Unit = project.afterEvaluate {
|
val configuration = configurations[configurationName]
|
||||||
val projectDeps = configuration
|
?: error("Configuration with name $configurationName could not be resolved.")
|
||||||
.allDependencies
|
val projectDeps = configuration.allDependencies.filterIsInstance<ProjectDependency>().map {
|
||||||
.filterIsInstance<ProjectDependency>()
|
it.dependencyProject
|
||||||
.map { it.dependencyProject }
|
}
|
||||||
|
into(buildDir.resolve("processedResources/js"))
|
||||||
val destination = destinationDir
|
|
||||||
|
|
||||||
projectDeps.forEach { dep ->
|
projectDeps.forEach { dep ->
|
||||||
dep.pluginManager.withPlugin("org.jetbrains.kotlin.multiplatform") {
|
dep.afterEvaluate {
|
||||||
dep.tasks.findByName("jsProcessResources")?.let { task ->
|
dep.pluginManager.withPlugin("org.jetbrains.kotlin.multiplatform") {
|
||||||
val sourceDir = (task as Copy).destinationDir
|
dep.tasks.findByName("jsProcessResources")?.let { task ->
|
||||||
inputs.files(sourceDir)
|
dependsOn(task)
|
||||||
dependsOn(task)
|
from(task)
|
||||||
from(sourceDir)
|
//from(dep.buildDir.resolve("processedResources/js"))
|
||||||
|
}
|
||||||
|
//from(dep.buildDir.resolve("processedResources/js"))
|
||||||
}
|
}
|
||||||
}
|
dep.pluginManager.withPlugin("org.jetbrains.kotlin.js") {
|
||||||
dep.pluginManager.withPlugin("org.jetbrains.kotlin.js") {
|
dep.tasks.findByName("processResources")?.let { task ->
|
||||||
dep.tasks.findByName("processResources")?.let { task ->
|
dependsOn(task)
|
||||||
val sourceDir = (task as Copy).destinationDir
|
from(task)
|
||||||
inputs.files(sourceDir)
|
//from(dep.buildDir.resolve("processedResources/js"))
|
||||||
dependsOn(task)
|
}
|
||||||
from(sourceDir)
|
// from(dep.buildDir.resolve("processedResources/js"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun Copy.copyJVMResources(configuration: Configuration): Unit = project.afterEvaluate {
|
|
||||||
val projectDeps = configuration
|
|
||||||
.allDependencies
|
|
||||||
.filterIsInstance<ProjectDependency>()
|
|
||||||
.map { it.dependencyProject }
|
|
||||||
|
|
||||||
val destination = destinationDir
|
//
|
||||||
|
//internal fun Copy.copyJVMResources(configuration: Configuration): Unit = project.afterEvaluate {
|
||||||
projectDeps.forEach { dep ->
|
// val projectDeps = configuration.allDependencies
|
||||||
dep.pluginManager.withPlugin("org.jetbrains.kotlin.multiplatform") {
|
// .filterIsInstance<ProjectDependency>()
|
||||||
dep.tasks.findByName("jvmProcessResources")?.let { task ->
|
// .map { it.dependencyProject }
|
||||||
val sourceDir = (task as Copy).destinationDir
|
//
|
||||||
inputs.files(sourceDir)
|
// projectDeps.forEach { dep ->
|
||||||
dependsOn(task)
|
// dep.pluginManager.withPlugin("org.jetbrains.kotlin.multiplatform") {
|
||||||
from(sourceDir)
|
// dep.tasks.findByName("jvmProcessResources")?.let { task ->
|
||||||
}
|
// dependsOn(task)
|
||||||
}
|
// from(task)
|
||||||
dep.pluginManager.withPlugin("org.jetbrains.kotlin.jvm") {
|
// }
|
||||||
dep.tasks.findByName("processResources")?.let { task ->
|
// }
|
||||||
val sourceDir = (task as Copy).destinationDir
|
// dep.pluginManager.withPlugin("org.jetbrains.kotlin.jvm") {
|
||||||
inputs.files(sourceDir)
|
// dep.tasks.findByName("processResources")?.let { task ->
|
||||||
dependsOn(task)
|
// dependsOn(task)
|
||||||
from(sourceDir)
|
// from(task)
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
//}
|
@ -1,9 +1,10 @@
|
|||||||
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.KotlinJsProjectExtension
|
||||||
|
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension
|
||||||
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
|
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
|
||||||
|
|
||||||
enum class DependencyConfiguration {
|
enum class DependencyConfiguration {
|
||||||
@ -23,7 +24,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
|
||||||
@ -43,14 +44,16 @@ 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") {
|
||||||
sourceSets.findByName(dependencySourceSet.setName)?.apply {
|
configure<KotlinJvmProjectExtension> {
|
||||||
dependencies.apply {
|
sourceSets.findByName(dependencySourceSet.setName)?.apply {
|
||||||
val configurationName = when (dependencyConfiguration) {
|
dependencies.apply {
|
||||||
DependencyConfiguration.API -> apiConfigurationName
|
val configurationName = when (dependencyConfiguration) {
|
||||||
DependencyConfiguration.IMPLEMENTATION -> implementationConfigurationName
|
DependencyConfiguration.API -> apiConfigurationName
|
||||||
DependencyConfiguration.COMPILE_ONLY -> compileOnlyConfigurationName
|
DependencyConfiguration.IMPLEMENTATION -> implementationConfigurationName
|
||||||
|
DependencyConfiguration.COMPILE_ONLY -> compileOnlyConfigurationName
|
||||||
|
}
|
||||||
|
add(configurationName, dep.second)
|
||||||
}
|
}
|
||||||
add(configurationName, dep.second)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -58,14 +61,16 @@ internal fun Project.useDependency(
|
|||||||
|
|
||||||
pairs.find { it.first == "js" }?.let { dep ->
|
pairs.find { it.first == "js" }?.let { dep ->
|
||||||
pluginManager.withPlugin("org.jetbrains.kotlin.js") {
|
pluginManager.withPlugin("org.jetbrains.kotlin.js") {
|
||||||
sourceSets.findByName(dependencySourceSet.setName)?.apply {
|
configure<KotlinJsProjectExtension> {
|
||||||
dependencies.apply {
|
sourceSets.findByName(dependencySourceSet.setName)?.apply {
|
||||||
val configurationName = when (dependencyConfiguration) {
|
dependencies.apply {
|
||||||
DependencyConfiguration.API -> apiConfigurationName
|
val configurationName = when (dependencyConfiguration) {
|
||||||
DependencyConfiguration.IMPLEMENTATION -> implementationConfigurationName
|
DependencyConfiguration.API -> apiConfigurationName
|
||||||
DependencyConfiguration.COMPILE_ONLY -> compileOnlyConfigurationName
|
DependencyConfiguration.IMPLEMENTATION -> implementationConfigurationName
|
||||||
|
DependencyConfiguration.COMPILE_ONLY -> compileOnlyConfigurationName
|
||||||
|
}
|
||||||
|
add(configurationName, dep.second)
|
||||||
}
|
}
|
||||||
add(configurationName, dep.second)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -76,9 +81,9 @@ 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) {
|
||||||
@ -90,27 +95,33 @@ internal fun Project.useCommonDependency(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
withPlugin("org.jetbrains.kotlin.jvm") {
|
withPlugin("org.jetbrains.kotlin.jvm") {
|
||||||
sourceSets.findByName(dependencySourceSet.setName)?.apply {
|
configure<KotlinJvmProjectExtension> {
|
||||||
dependencies.apply {
|
sourceSets.findByName(dependencySourceSet.setName)?.apply {
|
||||||
val configurationName = when (dependencyConfiguration) {
|
dependencies.apply {
|
||||||
DependencyConfiguration.API -> apiConfigurationName
|
val configurationName = when (dependencyConfiguration) {
|
||||||
DependencyConfiguration.IMPLEMENTATION -> implementationConfigurationName
|
DependencyConfiguration.API -> apiConfigurationName
|
||||||
DependencyConfiguration.COMPILE_ONLY -> compileOnlyConfigurationName
|
DependencyConfiguration.IMPLEMENTATION -> implementationConfigurationName
|
||||||
|
DependencyConfiguration.COMPILE_ONLY -> compileOnlyConfigurationName
|
||||||
|
}
|
||||||
|
add(configurationName, dep)
|
||||||
}
|
}
|
||||||
add(configurationName, dep)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
withPlugin("org.jetbrains.kotlin.js") {
|
withPlugin("org.jetbrains.kotlin.js") {
|
||||||
sourceSets.findByName(dependencySourceSet.setName)?.apply {
|
configure<KotlinJsProjectExtension> {
|
||||||
dependencies.apply {
|
sourceSets.findByName(dependencySourceSet.setName)?.apply {
|
||||||
val configurationName = when (dependencyConfiguration) {
|
dependencies.apply {
|
||||||
DependencyConfiguration.API -> apiConfigurationName
|
val configurationName = when (dependencyConfiguration) {
|
||||||
DependencyConfiguration.IMPLEMENTATION -> implementationConfigurationName
|
DependencyConfiguration.API -> apiConfigurationName
|
||||||
DependencyConfiguration.COMPILE_ONLY -> compileOnlyConfigurationName
|
DependencyConfiguration.IMPLEMENTATION -> implementationConfigurationName
|
||||||
|
DependencyConfiguration.COMPILE_ONLY -> compileOnlyConfigurationName
|
||||||
|
}
|
||||||
|
add(configurationName, dep)
|
||||||
}
|
}
|
||||||
add(configurationName, dep)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user