From 5b88c2c5ad98baaab1c426ac4ee6916dbf347a83 Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Thu, 4 Nov 2021 12:59:13 +0300 Subject: [PATCH 1/2] 0.10.6 with kotlin 1.6-RC2 --- CHANGELOG.md | 1 + build.gradle.kts | 4 ++- gradle/libs.versions.toml | 12 ++++----- .../mipt/npm/gradle/KScienceProjectPlugin.kt | 2 +- .../npm/gradle/KScienceReadmeExtension.kt | 27 ++++++++++++++++--- 5 files changed, 35 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5a8dca9..8d60f9f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ### Added +- html builders for readme ### Changed diff --git a/build.gradle.kts b/build.gradle.kts index a9b22ac..7915526 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -33,6 +33,8 @@ dependencies { implementation(libs.dokka.gradle) implementation(libs.kotlin.jupyter.gradle) implementation(libs.kotlin.serialization) + @Suppress("UnstableApiUsage") + implementation(libs.kotlinx.html) implementation("org.tomlj:tomlj:1.0.0") // // nexus publishing plugin // implementation("io.github.gradle-nexus:publish-plugin:1.1.0") @@ -210,6 +212,6 @@ afterEvaluate { } tasks.processResources.configure { - duplicatesStrategy = org.gradle.api.file.DuplicatesStrategy.INCLUDE + duplicatesStrategy = DuplicatesStrategy.INCLUDE from("gradle/libs.versions.toml") } \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 3dc1993..32c3e5c 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,16 +1,16 @@ [versions] -tools = "0.10.5" -kotlin = "1.6.0-M1" +tools = "0.10.6" +kotlin = "1.6.0-RC2" atomicfu = "0.16.2" binary-compatibility-validator = "0.7.1" changelog = "1.3.0" dokka = "1.5.0" -kotlin-jupyter = "0.10.0-227" +kotlin-jupyter = "0.10.3-31" kotlinx-benchmark = "0.3.1" -kotlinx-cli = "0.3.2" +kotlinx-cli = "0.3.3" kotlinx-collections-immutable = "0.3.4" kotlinx-coroutines = "1.5.2" -kotlinx-datetime = "0.2.1" +kotlinx-datetime = "0.3.1" kotlinx-html = "0.7.3" kotlinx-knit = "0.2.3" kotlinx-nodejs = "0.0.7" @@ -18,7 +18,7 @@ kotlinx-serialization = "1.3.0" ktor = "1.6.3" xmlutil = "0.83.0" yamlkt = "0.10.2" -jsBom = "0.0.1-pre.248-kotlin-1.5.31" +jsBom = "0.0.1-pre.263-kotlin-1.5.31" [libraries] atomicfu-gradle = { module = "org.jetbrains.kotlinx:atomicfu-gradle-plugin", version.ref = "atomicfu" } diff --git a/src/main/kotlin/ru/mipt/npm/gradle/KScienceProjectPlugin.kt b/src/main/kotlin/ru/mipt/npm/gradle/KScienceProjectPlugin.kt index a6224f7..5eae110 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/KScienceProjectPlugin.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/KScienceProjectPlugin.kt @@ -240,7 +240,7 @@ public open class KScienceProjectPlugin : Plugin { //val patchChangelog by tasks.getting - val release by tasks.creating { + @Suppress("UNUSED_VARIABLE") val release by tasks.creating { group = RELEASE_GROUP description = "Publish development or production release based on version suffix" dependsOn(generateReadme) diff --git a/src/main/kotlin/ru/mipt/npm/gradle/KScienceReadmeExtension.kt b/src/main/kotlin/ru/mipt/npm/gradle/KScienceReadmeExtension.kt index 4edb9ca..9d2b283 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/KScienceReadmeExtension.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/KScienceReadmeExtension.kt @@ -1,16 +1,23 @@ package ru.mipt.npm.gradle import groovy.text.SimpleTemplateEngine +import kotlinx.html.TagConsumer +import kotlinx.html.div +import kotlinx.html.stream.createHTML import kotlinx.validation.ApiValidationExtension import org.gradle.api.Project -import org.gradle.kotlin.dsl.* +import org.gradle.kotlin.dsl.findByType import java.io.File +import kotlin.collections.component1 +import kotlin.collections.component2 +import kotlin.collections.set public enum class Maturity { PROTOTYPE, EXPERIMENTAL, DEVELOPMENT, - STABLE + STABLE, + DEPRECATED } @@ -48,6 +55,20 @@ public class KScienceReadmeExtension(public val project: Project) { features += Feature(id, description(), ref, name) } + public fun featureWithHtml( + id: String, + ref: String? = null, + name: String = id, + htmlBuilder: TagConsumer.() -> Unit, + ) { + val text = createHTML().apply { + div("readme-feature") { + htmlBuilder() + } + }.finalize() + features += Feature(id, text, ref, name) + } + private val properties: MutableMap Any?> = mutableMapOf( "name" to { project.name }, "group" to { project.group }, @@ -82,7 +103,7 @@ public class KScienceReadmeExtension(public val project: Project) { /** * Generate a markdown string listing features */ - public fun featuresString(itemPrefix: String = " - ", pathPrefix: String = ""): String = buildString { + internal fun featuresString(itemPrefix: String = " - ", pathPrefix: String = ""): String = buildString { features.forEach { appendLine("$itemPrefix[${it.name}]($pathPrefix${it.ref ?: "#"}) : ${it.description}") } -- 2.34.1 From b5270617fc1cc8506212a4650fe253adb4dc33a3 Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Tue, 16 Nov 2021 12:19:03 +0300 Subject: [PATCH 2/2] 0.10.7 with kotlin 1.6 and indy lambdas --- CHANGELOG.md | 2 ++ build.gradle.kts | 1 + gradle/libs.versions.toml | 19 ++++++++++--------- .../mipt/npm/gradle/KScienceCommonPlugin.kt | 13 +++++++++---- .../ru/mipt/npm/gradle/KScienceVersions.kt | 1 + 5 files changed, 23 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d60f9f..a8f271e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - html builders for readme ### Changed +- Kotlin 1.6.0 +- Use indy lambdas by default #32 ### Deprecated diff --git a/build.gradle.kts b/build.gradle.kts index 7915526..863a158 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -96,6 +96,7 @@ gradlePlugin { //publishing version catalog +@Suppress("UnstableApiUsage") catalog.versionCatalog { from(files("gradle/libs.versions.toml")) } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 32c3e5c..0ff079c 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,11 +1,11 @@ [versions] -tools = "0.10.6" -kotlin = "1.6.0-RC2" -atomicfu = "0.16.2" -binary-compatibility-validator = "0.7.1" -changelog = "1.3.0" -dokka = "1.5.0" -kotlin-jupyter = "0.10.3-31" +tools = "0.10.7" +kotlin = "1.6.0" +atomicfu = "0.16.3" +binary-compatibility-validator = "0.8.0" +changelog = "1.3.1" +dokka = "1.5.30" +kotlin-jupyter = "0.10.3-36" kotlinx-benchmark = "0.3.1" kotlinx-cli = "0.3.3" kotlinx-collections-immutable = "0.3.4" @@ -14,11 +14,12 @@ kotlinx-datetime = "0.3.1" kotlinx-html = "0.7.3" kotlinx-knit = "0.2.3" kotlinx-nodejs = "0.0.7" -kotlinx-serialization = "1.3.0" +kotlinx-serialization = "1.3.1" ktor = "1.6.3" xmlutil = "0.83.0" yamlkt = "0.10.2" -jsBom = "0.0.1-pre.263-kotlin-1.5.31" +jsBom = "0.0.1-pre.265-kotlin-1.5.31" +junit = "5.8.1" [libraries] atomicfu-gradle = { module = "org.jetbrains.kotlinx:atomicfu-gradle-plugin", version.ref = "atomicfu" } diff --git a/src/main/kotlin/ru/mipt/npm/gradle/KScienceCommonPlugin.kt b/src/main/kotlin/ru/mipt/npm/gradle/KScienceCommonPlugin.kt index 1ee4e43..ee8db3a 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/KScienceCommonPlugin.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/KScienceCommonPlugin.kt @@ -17,6 +17,11 @@ import ru.mipt.npm.gradle.internal.fromJsDependencies @Suppress("UNUSED_VARIABLE") public open class KScienceCommonPlugin : Plugin { + public companion object{ + public val defaultJvmArgs: List = listOf("-Xjvm-default=all","-Xlambdas=indy") + } + + override fun apply(project: Project): Unit = project.run { //Common configuration registerKScienceExtension() @@ -35,14 +40,14 @@ public open class KScienceCommonPlugin : Plugin { sourceSets["test"].apply { dependencies { implementation(kotlin("test-junit5")) - implementation("org.junit.jupiter:junit-jupiter:5.6.1") + implementation("org.junit.jupiter:junit-jupiter:${KScienceVersions.junit}") } } } tasks.withType { kotlinOptions { jvmTarget = KScienceVersions.JVM_TARGET.toString() - freeCompilerArgs = freeCompilerArgs + "-Xjvm-default=all" + freeCompilerArgs = freeCompilerArgs + defaultJvmArgs } } @@ -99,7 +104,7 @@ public open class KScienceCommonPlugin : Plugin { compilations.all { kotlinOptions { jvmTarget = KScienceVersions.JVM_TARGET.toString() - freeCompilerArgs = freeCompilerArgs + "-Xjvm-default=all" + freeCompilerArgs = freeCompilerArgs + defaultJvmArgs } } } @@ -128,7 +133,7 @@ public open class KScienceCommonPlugin : Plugin { val jvmTest by getting { dependencies { implementation(kotlin("test-junit5")) - implementation("org.junit.jupiter:junit-jupiter:5.7.2") + implementation("org.junit.jupiter:junit-jupiter:${KScienceVersions.junit}") } } val jsMain by getting diff --git a/src/main/kotlin/ru/mipt/npm/gradle/KScienceVersions.kt b/src/main/kotlin/ru/mipt/npm/gradle/KScienceVersions.kt index e871acd..296ad2d 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/KScienceVersions.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/KScienceVersions.kt @@ -22,6 +22,7 @@ public object KScienceVersions { public val htmlVersion: String get() = toml.getString("versions.kotlinx-html")!! public val dateTimeVersion: String get() = toml.getString("versions.kotlinx-datetime")!! public val jsBom: String get() = toml.getString("versions.jsBom")!! + internal val junit: String get() = toml.getString("versions.junit")!! public val JVM_TARGET: JavaVersion = JavaVersion.VERSION_11 -- 2.34.1