diff --git a/CHANGELOG.md b/CHANGELOG.md index cc955e8..e9f2715 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,18 +7,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ### Added +- Ktor version to versions ### Changed +- Kotlin to 1.4.30 stable +- Added intermediate jsCommon main/test sourcesSet for node plugin ### Deprecated ### Removed +- kaml ### Fixed ### Security -## [0.7.0] +## [0.7.4] ### Added - Changelog plugin automatically applied to `project`. @@ -26,6 +30,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Add `binary-compatibility-validator` to the `project` plugin. - Separate `yamlKt` serialization target - Moved all logic to a common plugin, leaving only proxies for platform plugins +- Suppress API validation for modules with maturity below DEVELOPMENT ### Changed - Remove node plugin. Node binaries should be turned on manually. @@ -35,6 +40,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Platform plugins are now simple references to common plugin - FX configuration moved to extension - Moved internals to internals +- Kotlin 1.4.30-RC ### Deprecated - Support of `kaml` and `snake-yaml` in favor of `yamlKt` diff --git a/build.gradle.kts b/build.gradle.kts index 1a5dbd4..7573a8c 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -2,11 +2,11 @@ plugins { `java-gradle-plugin` `kotlin-dsl` `maven-publish` - id("org.jetbrains.changelog") version "0.6.2" + id("org.jetbrains.changelog") version "1.0.0" } group = "ru.mipt.npm" -version = "0.7.1" +version = "0.7.6" repositories { gradlePluginPortal() @@ -16,7 +16,7 @@ repositories { maven("https://dl.bintray.com/kotlin/kotlin-dev") } -val kotlinVersion = "1.4.21" +val kotlinVersion = "1.4.30" java { targetCompatibility = JavaVersion.VERSION_1_8 @@ -26,11 +26,11 @@ java { dependencies { implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion") implementation("org.jetbrains.kotlin:kotlin-serialization:$kotlinVersion") - implementation("org.jetbrains.kotlinx:atomicfu-gradle-plugin:0.15.0") + implementation("org.jetbrains.kotlinx:atomicfu-gradle-plugin:0.15.1") implementation("org.jetbrains.dokka:dokka-gradle-plugin:1.4.20") implementation("org.jetbrains.dokka:dokka-base:1.4.20") - implementation("org.jetbrains.intellij.plugins:gradle-changelog-plugin:0.6.2") - implementation("org.jetbrains.kotlinx:binary-compatibility-validator:0.2.4") + implementation("org.jetbrains.intellij.plugins:gradle-changelog-plugin:1.0.0") + implementation("org.jetbrains.kotlinx:binary-compatibility-validator:0.4.0") } gradlePlugin { diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 4d9ca16..28ff446 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/src/main/kotlin/ru/mipt/npm/gradle/KScienceCommonPlugin.kt b/src/main/kotlin/ru/mipt/npm/gradle/KScienceCommonPlugin.kt index 405b3a5..d355726 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/KScienceCommonPlugin.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/KScienceCommonPlugin.kt @@ -12,7 +12,7 @@ import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension import ru.mipt.npm.gradle.internal.applyRepos import ru.mipt.npm.gradle.internal.applySettings -import ru.mipt.npm.gradle.internal.fromDependencies +import ru.mipt.npm.gradle.internal.fromJsDependencies open class KScienceCommonPlugin : Plugin { override fun apply(project: Project): Unit = project.run { @@ -67,7 +67,7 @@ open class KScienceCommonPlugin : Plugin { } (tasks.findByName("processResources") as? Copy)?.apply { - fromDependencies("runtimeClasspath") + fromJsDependencies("runtimeClasspath") } } @@ -79,7 +79,7 @@ open class KScienceCommonPlugin : Plugin { jvm { compilations.all { kotlinOptions { -// useIR = true + useIR = true jvmTarget = KScienceVersions.JVM_TARGET.toString() } } @@ -121,7 +121,7 @@ open class KScienceCommonPlugin : Plugin { } (tasks.findByName("jsProcessResources") as? Copy)?.apply { - fromDependencies("jsRuntimeClasspath") + fromJsDependencies("jsRuntimeClasspath") } } } @@ -134,7 +134,7 @@ open class KScienceCommonPlugin : Plugin { tasks.apply { withType { kotlinOptions { - // useIR = true + useIR = true jvmTarget = KScienceVersions.JVM_TARGET.toString() } } diff --git a/src/main/kotlin/ru/mipt/npm/gradle/KScienceNativePlugin.kt b/src/main/kotlin/ru/mipt/npm/gradle/KScienceNativePlugin.kt index c507d49..2eaeb6e 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/KScienceNativePlugin.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/KScienceNativePlugin.kt @@ -39,14 +39,13 @@ class KScienceNativePlugin : Plugin { sourceSets{ val commonMain by getting + val commonTest by getting + val nativeMain by creating{ dependsOn(commonMain) } - val commonTest by getting - val nativeTest by creating{ - dependsOn(nativeMain) dependsOn(commonTest) } diff --git a/src/main/kotlin/ru/mipt/npm/gradle/KScienceNodePlugin.kt b/src/main/kotlin/ru/mipt/npm/gradle/KScienceNodePlugin.kt index 473424e..e1367bc 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/KScienceNodePlugin.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/KScienceNodePlugin.kt @@ -26,18 +26,33 @@ class KScienceNodePlugin : Plugin { } sourceSets { val commonMain by getting - val nodeMain by creating { + val commonTest by getting + + val jsCommonMain by creating{ dependsOn(commonMain) + } + + val jsCommonTest by creating{ + dependsOn(commonTest) + } + + val jsMain by getting{ + dependsOn(jsCommonMain) + } + + val jsTest by getting{ + dependsOn(jsCommonTest) + } + + val nodeMain by creating { + dependsOn(jsCommonMain) dependencies{ api("org.jetbrains.kotlinx:kotlinx-nodejs:${KScienceVersions.kotlinxNodeVersion}") } } - val commonTest by getting - val nodeTest by creating { - dependsOn(nodeMain) - dependsOn(commonTest) + dependsOn(jsCommonTest) } } } diff --git a/src/main/kotlin/ru/mipt/npm/gradle/KScienceProjectPlugin.kt b/src/main/kotlin/ru/mipt/npm/gradle/KScienceProjectPlugin.kt index 942334a..c5ccd8f 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/KScienceProjectPlugin.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/KScienceProjectPlugin.kt @@ -8,11 +8,11 @@ import org.gradle.kotlin.dsl.* import org.jetbrains.changelog.ChangelogPlugin import org.jetbrains.dokka.gradle.DokkaPlugin import org.jetbrains.dokka.gradle.DokkaTask -import java.io.File import kotlin.collections.component1 import kotlin.collections.component2 class KSciencePublishingExtension(val project: Project) { + var vcs: String? by project.extra var githubOrg: String? by project.extra var githubProject: String? by project.extra var spaceRepo: String? by project.extra @@ -24,76 +24,6 @@ class KSciencePublishingExtension(val project: Project) { var bintrayRepo: String? by project.extra } -enum class Maturity { - PROTOTYPE, - EXPERIMENTAL, - DEVELOPMENT, - PRODUCTION -} - -class KScienceReadmeExtension(val project: Project) { - var description: String = "" - var maturity: Maturity = Maturity.EXPERIMENTAL - - var readmeTemplate: File = project.file("docs/README-TEMPLATE.md") - - data class Feature(val id: String, val ref: String, val description: String, val name: String = id) - - val features = ArrayList() - - fun feature(id: String, ref: String, description: String, name: String = id) { - features.add(Feature(id, ref, description, name)) - } - - val properties: MutableMap Any?> = mutableMapOf( - "name" to { project.name }, - "group" to { project.group }, - "version" to { project.version }, - "features" to { featuresString() } - ) - - private fun getActualizedProperties() = properties.mapValues { (_, value) -> - value.invoke() - } - - fun property(key: String, value: Any?) { - properties[key] = {value} - } - - fun propertyByTemplate(key: String, template: String) { - val actual = getActualizedProperties() - properties[key] = {SimpleTemplateEngine().createTemplate(template).make(actual).toString()} - } - - internal val additionalFiles = ArrayList() - - fun propertyByTemplate(key: String, template: File) { - val actual = getActualizedProperties() - properties[key] = {SimpleTemplateEngine().createTemplate(template).make(actual).toString()} - additionalFiles.add(template) - } - - /** - * Generate a markdown string listing features - */ - fun featuresString(itemPrefix: String = " - ", pathPrefix: String = "") = buildString { - features.forEach { - appendln("$itemPrefix[${it.id}]($pathPrefix${it.ref}) : ${it.description}") - } - } - - /** - * Generate a readme string from the stub - */ - fun readmeString(): String? { - return if (readmeTemplate.exists()) { - val actual = getActualizedProperties() - SimpleTemplateEngine().createTemplate(readmeTemplate).make(actual).toString() - } else { - null - } - } -} /** * Apply extension and repositories diff --git a/src/main/kotlin/ru/mipt/npm/gradle/KScienceReadmeExtension.kt b/src/main/kotlin/ru/mipt/npm/gradle/KScienceReadmeExtension.kt new file mode 100644 index 0000000..cf8c027 --- /dev/null +++ b/src/main/kotlin/ru/mipt/npm/gradle/KScienceReadmeExtension.kt @@ -0,0 +1,97 @@ +package ru.mipt.npm.gradle + +import groovy.text.SimpleTemplateEngine +import kotlinx.validation.ApiValidationExtension +import org.gradle.api.Project +import org.gradle.kotlin.dsl.getByType +import java.io.File + +enum class Maturity { + PROTOTYPE, + EXPERIMENTAL, + DEVELOPMENT, + STABLE +} + + +class KScienceReadmeExtension(val project: Project) { + var description: String = project.description ?: "" + var maturity: Maturity = Maturity.EXPERIMENTAL + set(value) { + field = value + val projectName = project.name + if (value == Maturity.EXPERIMENTAL || value == Maturity.PROTOTYPE) { + project.rootProject.run { + plugins.withId("org.jetbrains.kotlinx.binary-compatibility-validator") { + extensions.getByType().apply { + project.logger.warn("$value project $projectName is excluded from API validation") + ignoredProjects.add(projectName) + } + } + } + } + } + + var readmeTemplate: File = project.file("docs/README-TEMPLATE.md") + + data class Feature(val id: String, val description: String, val ref: String?, val name: String = id) + + val features = ArrayList() + + fun feature(id: String, description: String, ref: String? = null, name: String = id) { + features.add(Feature(id, description, ref, name)) + } + + fun feature(id: String, ref: String? = null, name: String = id, description: () -> String) { + features.add(Feature(id, description(), ref, name)) + } + + val properties: MutableMap Any?> = mutableMapOf( + "name" to { project.name }, + "group" to { project.group }, + "version" to { project.version }, + "features" to { featuresString() } + ) + + private fun getActualizedProperties() = properties.mapValues { (_, value) -> + value.invoke() + } + + fun property(key: String, value: Any?) { + properties[key] = { value } + } + + fun propertyByTemplate(key: String, template: String) { + val actual = getActualizedProperties() + properties[key] = { SimpleTemplateEngine().createTemplate(template).make(actual).toString() } + } + + internal val additionalFiles = ArrayList() + + fun propertyByTemplate(key: String, template: File) { + val actual = getActualizedProperties() + properties[key] = { SimpleTemplateEngine().createTemplate(template).make(actual).toString() } + additionalFiles.add(template) + } + + /** + * Generate a markdown string listing features + */ + fun featuresString(itemPrefix: String = " - ", pathPrefix: String = "") = buildString { + features.forEach { + appendln("$itemPrefix[${it.name}]($pathPrefix${it.ref ?: "#"}) : ${it.description}") + } + } + + /** + * Generate a readme string from the stub + */ + fun readmeString(): String? { + return if (readmeTemplate.exists()) { + val actual = getActualizedProperties() + SimpleTemplateEngine().createTemplate(readmeTemplate).make(actual).toString() + } else { + null + } + } +} \ No newline at end of file diff --git a/src/main/kotlin/ru/mipt/npm/gradle/KScienceVersions.kt b/src/main/kotlin/ru/mipt/npm/gradle/KScienceVersions.kt index 7849dda..e867cce 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/KScienceVersions.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/KScienceVersions.kt @@ -6,19 +6,19 @@ import org.gradle.api.JavaVersion * Build constants */ object KScienceVersions { - const val kotlinVersion = "1.4.21" + const val kotlinVersion = "1.4.30" const val kotlinxNodeVersion = "0.0.7" const val coroutinesVersion = "1.4.2" - const val serializationVersion = "1.0.1" - const val atomicVersion = "0.14.4" + const val serializationVersion = "1.1.0-RC" + const val atomicVersion = "0.15.1" + const val ktorVersion = "1.5.1" + const val htmlVersion = "0.7.2" val JVM_TARGET = JavaVersion.VERSION_11 object Serialization{ const val xmlVersion = "0.80.1" - @Deprecated("Use yamlKt instead") - const val yamlVersion = "0.21.0" const val bsonVersion = "0.4.4" - const val yamlKtVersion = "0.7.5" + const val yamlKtVersion = "0.9.0" } } diff --git a/src/main/kotlin/ru/mipt/npm/gradle/SerializationTargets.kt b/src/main/kotlin/ru/mipt/npm/gradle/SerializationTargets.kt index 1f66db2..f9972d3 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/SerializationTargets.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/SerializationTargets.kt @@ -54,17 +54,6 @@ class SerializationTargets( ) } - @Deprecated("Use multiplatform yamlKt instead") - fun Project.yaml( - version: String = KScienceVersions.Serialization.yamlVersion - ) { - useDependency( - "jvm" to "com.charleskorn.kaml:kaml:$version", - dependencySourceSet = sourceSet, - dependencyConfiguration = configuration - ) - } - fun Project.yamlKt( version: String = KScienceVersions.Serialization.yamlKtVersion ) { diff --git a/src/main/kotlin/ru/mipt/npm/gradle/internal/common.kt b/src/main/kotlin/ru/mipt/npm/gradle/internal/common.kt index 6eede47..ab26d38 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/internal/common.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/internal/common.kt @@ -8,6 +8,7 @@ import org.gradle.kotlin.dsl.maven import org.jetbrains.kotlin.gradle.plugin.LanguageSettingsBuilder internal fun LanguageSettingsBuilder.applySettings(): Unit { + languageVersion = "1.4" progressiveMode = true enableLanguageFeature("InlineClasses") useExperimentalAnnotation("kotlin.Experimental") @@ -20,7 +21,6 @@ internal fun LanguageSettingsBuilder.applySettings(): Unit { internal fun RepositoryHandler.applyRepos(): Unit { mavenCentral() - jcenter() maven("https://dl.bintray.com/kotlin/kotlin-eap") maven("https://dl.bintray.com/kotlin/kotlin-dev") maven("https://kotlin.bintray.com/kotlinx") @@ -28,9 +28,10 @@ internal fun RepositoryHandler.applyRepos(): Unit { maven("https://dl.bintray.com/mipt-npm/kscience") maven("https://dl.bintray.com/mipt-npm/dev") maven("https://dl.bintray.com/mipt-npm/dataforge") + maven("https://repo.kotlin.link") } -internal fun Copy.fromDependencies(configurationName: String) = project.afterEvaluate { +internal fun Copy.fromJsDependencies(configurationName: String) = project.afterEvaluate { val configuration = configurations[configurationName] ?: error("Configuration with name $configurationName could not be resolved.") val projectDeps = configuration.allDependencies.filterIsInstance().map { diff --git a/src/main/kotlin/ru/mipt/npm/gradle/internal/publish.kt b/src/main/kotlin/ru/mipt/npm/gradle/internal/publish.kt index 12bb161..58f8b02 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/internal/publish.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/internal/publish.kt @@ -18,10 +18,10 @@ internal fun Project.configurePublishing() { val vcs = findProperty("vcs") as? String ?: githubProject?.let { "https://github.com/$githubOrg/$it" } - if (vcs == null) { - project.logger.warn("[${project.name}] Missing deployment configuration. Skipping publish.") - return - } +// if (vcs == null) { +// project.logger.warn("[${project.name}] Missing deployment configuration. Skipping publish.") +// return +// } project.configure { plugins.withId("org.jetbrains.kotlin.js") { @@ -62,7 +62,7 @@ internal fun Project.configurePublishing() { publication.pom { name.set(project.name) description.set(project.description) - url.set(vcs) + vcs?.let{url.set(vcs)} licenses { license { @@ -80,9 +80,11 @@ internal fun Project.configurePublishing() { } } - scm { - url.set(vcs) - tag.set(project.version.toString()) + vcs?.let { + scm { + url.set(vcs) + tag.set(project.version.toString()) + } } } }