Kotlin 1.4.20 #4

Merged
altavir merged 10 commits from kotlin-1.4.20 into dev 2020-11-25 22:20:48 +03:00
11 changed files with 210 additions and 192 deletions
Showing only changes of commit f456be46d4 - Show all commits

View File

@ -10,14 +10,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- 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. - Add `binary-compatibility-validator` to the `project` plugin.
- Separate `yamlKt` serialization target
- Separate `ain` plugin
### Changed ### Changed
- Remove node plugin. Node binaries should be turned on manually. - 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.

View File

@ -6,7 +6,7 @@ plugins {
} }
group = "ru.mipt.npm" group = "ru.mipt.npm"
version = "0.6.4-dev-1.4.20-M2" 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.20-M2" val kotlinVersion = "1.4.20"
java { java {
targetCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8
@ -27,14 +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.3") 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"

View File

@ -0,0 +1,138 @@
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") {
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") {
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")
}
}
}
}
}

View File

@ -2,48 +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()
} }
plugins.apply(KScienceCommonPlugin::class)
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) {
fromDependencies("runtimeClasspath")
}
}
}
}

View File

@ -2,58 +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.tasks.testing.Test
import org.gradle.kotlin.dsl.configure
import org.gradle.kotlin.dsl.findByType
import org.gradle.kotlin.dsl.get
import org.gradle.kotlin.dsl.withType
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
withSourcesJar()
//withJavadocJar()
}
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")
}
}
}
tasks.apply {
withType<Test>() {
useJUnitPlatform()
}
//
// val processResources by getting(Copy::class)
// processResources.copyJVMResources(configurations["runtimeClasspath"])
} }
plugins.apply(KScienceCommonPlugin::class)
} }
} }

View File

@ -2,99 +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.tasks.Copy import org.gradle.kotlin.dsl.apply
import org.gradle.api.tasks.testing.Test import org.gradle.kotlin.dsl.findPlugin
import org.gradle.kotlin.dsl.* import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinMultiplatformPlugin
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(KotlinMultiplatformPlugin::class) == null) {
registerKScienceExtension() logger.info("Kotlin multiplatform plugin is not resolved. Adding it automatically")
repositories.applyRepos() pluginManager.apply(KotlinMultiplatformPlugin::class)
}
configure<KotlinMultiplatformExtension> { plugins.apply(KScienceCommonPlugin::class)
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()
}
}
}
// 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) {
fromDependencies("jsRuntimeClasspath")
}
}
}
} }
} }

View File

@ -5,13 +5,18 @@ 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(KScienceMPPlugin::class) == null) { if (plugins.findPlugin(KotlinMultiplatformPlugin::class) == 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(KotlinMultiplatformPlugin::class)
}
if (plugins.findPlugin(KScienceCommonPlugin::class) == null) {
logger.info("KScience plugin is not resolved. Adding it automatically")
pluginManager.apply(KScienceCommonPlugin::class)
} }
configure<KotlinMultiplatformExtension> { configure<KotlinMultiplatformExtension> {

View File

@ -4,6 +4,7 @@ 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
@ -11,9 +12,13 @@ import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
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(KScienceMPPlugin::class) == null) { if (plugins.findPlugin(KotlinMultiplatformPlugin::class) == 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(KotlinMultiplatformPlugin::class)
}
if (plugins.findPlugin(KScienceCommonPlugin::class) == null) {
logger.info("KScience plugin is not resolved. Adding it automatically")
pluginManager.apply(KScienceCommonPlugin::class)
} }
configure<KotlinMultiplatformExtension> { configure<KotlinMultiplatformExtension> {

View File

@ -6,17 +6,19 @@ import org.gradle.api.JavaVersion
* Build constants * Build constants
*/ */
object KScienceVersions { object KScienceVersions {
const val kotlinVersion = "1.4.20-M2" const val kotlinVersion = "1.4.20"
const val kotlinxNodeVersion = "0.0.7" const val kotlinxNodeVersion = "0.0.7"
const val coroutinesVersion = "1.3.9" const val coroutinesVersion = "1.4.1"
const val serializationVersion = "1.0.0" 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.1" 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.2" const val bsonVersion = "0.4.2"
const val yamlKtVersion = "0.7.4"
} }
} }

View File

@ -1,6 +1,8 @@
package ru.mipt.npm.gradle package ru.mipt.npm.gradle
import org.gradle.api.Project import org.gradle.api.Project
import org.gradle.kotlin.dsl.maven
import org.gradle.kotlin.dsl.repositories
class SerializationTargets( class SerializationTargets(
val sourceSet: DependencySourceSet, val sourceSet: DependencySourceSet,
@ -40,6 +42,9 @@ class SerializationTargets(
fun Project.xml( fun Project.xml(
version: String = KScienceVersions.Serialization.xmlVersion version: String = KScienceVersions.Serialization.xmlVersion
) { ) {
repositories {
maven("https://dl.bintray.com/pdvrieze/maven")
}
useCommonDependency( useCommonDependency(
"net.devrieze:xmlutil-serialization:$version", "net.devrieze:xmlutil-serialization:$version",
dependencySourceSet = sourceSet, dependencySourceSet = sourceSet,
@ -47,6 +52,7 @@ class SerializationTargets(
) )
} }
@Deprecated("Use multiplatform yamlKt instead")
fun Project.yaml( fun Project.yaml(
version: String = KScienceVersions.Serialization.yamlVersion version: String = KScienceVersions.Serialization.yamlVersion
) { ) {
@ -57,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
) { ) {

View File

@ -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 {