0.7.6 #6

Merged
altavir merged 11 commits from dev into master 2021-02-06 16:25:34 +03:00
12 changed files with 158 additions and 119 deletions

View File

@ -7,18 +7,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased] ## [Unreleased]
### Added ### Added
- Ktor version to versions
### Changed ### Changed
- Kotlin to 1.4.30 stable
- Added intermediate jsCommon main/test sourcesSet for node plugin
### Deprecated ### Deprecated
### Removed ### Removed
- kaml
### Fixed ### Fixed
### Security ### Security
## [0.7.0] ## [0.7.4]
### Added ### Added
- Changelog plugin automatically applied to `project`. - 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. - Add `binary-compatibility-validator` to the `project` plugin.
- Separate `yamlKt` serialization target - Separate `yamlKt` serialization target
- Moved all logic to a common plugin, leaving only proxies for platform plugins - Moved all logic to a common plugin, leaving only proxies for platform plugins
- Suppress API validation for modules with maturity below DEVELOPMENT
### Changed ### Changed
- Remove node plugin. Node binaries should be turned on manually. - 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 - Platform plugins are now simple references to common plugin
- FX configuration moved to extension - FX configuration moved to extension
- Moved internals to internals - Moved internals to internals
- Kotlin 1.4.30-RC
### Deprecated ### Deprecated
- Support of `kaml` and `snake-yaml` in favor of `yamlKt` - Support of `kaml` and `snake-yaml` in favor of `yamlKt`

View File

@ -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.6.2" id("org.jetbrains.changelog") version "1.0.0"
} }
group = "ru.mipt.npm" group = "ru.mipt.npm"
version = "0.7.1" version = "0.7.6"
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.21" val kotlinVersion = "1.4.30"
java { java {
targetCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8
@ -26,11 +26,11 @@ java {
dependencies { 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.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-gradle-plugin:1.4.20")
implementation("org.jetbrains.dokka:dokka-base: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.intellij.plugins:gradle-changelog-plugin:1.0.0")
implementation("org.jetbrains.kotlinx:binary-compatibility-validator:0.2.4") implementation("org.jetbrains.kotlinx:binary-compatibility-validator:0.4.0")
} }
gradlePlugin { gradlePlugin {

View File

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists 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 zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists

View File

@ -12,7 +12,7 @@ import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
import ru.mipt.npm.gradle.internal.applyRepos import ru.mipt.npm.gradle.internal.applyRepos
import ru.mipt.npm.gradle.internal.applySettings 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<Project> { open class KScienceCommonPlugin : Plugin<Project> {
override fun apply(project: Project): Unit = project.run { override fun apply(project: Project): Unit = project.run {
@ -67,7 +67,7 @@ open class KScienceCommonPlugin : Plugin<Project> {
} }
(tasks.findByName("processResources") as? Copy)?.apply { (tasks.findByName("processResources") as? Copy)?.apply {
fromDependencies("runtimeClasspath") fromJsDependencies("runtimeClasspath")
} }
} }
@ -79,7 +79,7 @@ open class KScienceCommonPlugin : Plugin<Project> {
jvm { jvm {
compilations.all { compilations.all {
kotlinOptions { kotlinOptions {
// useIR = true useIR = true
jvmTarget = KScienceVersions.JVM_TARGET.toString() jvmTarget = KScienceVersions.JVM_TARGET.toString()
} }
} }
@ -121,7 +121,7 @@ open class KScienceCommonPlugin : Plugin<Project> {
} }
(tasks.findByName("jsProcessResources") as? Copy)?.apply { (tasks.findByName("jsProcessResources") as? Copy)?.apply {
fromDependencies("jsRuntimeClasspath") fromJsDependencies("jsRuntimeClasspath")
} }
} }
} }
@ -134,7 +134,7 @@ open class KScienceCommonPlugin : Plugin<Project> {
tasks.apply { tasks.apply {
withType<KotlinJvmCompile> { withType<KotlinJvmCompile> {
kotlinOptions { kotlinOptions {
// useIR = true useIR = true
jvmTarget = KScienceVersions.JVM_TARGET.toString() jvmTarget = KScienceVersions.JVM_TARGET.toString()
} }
} }

View File

@ -39,14 +39,13 @@ class KScienceNativePlugin : Plugin<Project> {
sourceSets{ sourceSets{
val commonMain by getting val commonMain by getting
val commonTest by getting
val nativeMain by creating{ val nativeMain by creating{
dependsOn(commonMain) dependsOn(commonMain)
} }
val commonTest by getting
val nativeTest by creating{ val nativeTest by creating{
dependsOn(nativeMain)
dependsOn(commonTest) dependsOn(commonTest)
} }

View File

@ -26,18 +26,33 @@ class KScienceNodePlugin : Plugin<Project> {
} }
sourceSets { sourceSets {
val commonMain by getting val commonMain by getting
val nodeMain by creating { val commonTest by getting
val jsCommonMain by creating{
dependsOn(commonMain) 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{ dependencies{
api("org.jetbrains.kotlinx:kotlinx-nodejs:${KScienceVersions.kotlinxNodeVersion}") api("org.jetbrains.kotlinx:kotlinx-nodejs:${KScienceVersions.kotlinxNodeVersion}")
} }
} }
val commonTest by getting
val nodeTest by creating { val nodeTest by creating {
dependsOn(nodeMain) dependsOn(jsCommonTest)
dependsOn(commonTest)
} }
} }
} }

View File

@ -8,11 +8,11 @@ import org.gradle.kotlin.dsl.*
import org.jetbrains.changelog.ChangelogPlugin import org.jetbrains.changelog.ChangelogPlugin
import org.jetbrains.dokka.gradle.DokkaPlugin import org.jetbrains.dokka.gradle.DokkaPlugin
import org.jetbrains.dokka.gradle.DokkaTask import org.jetbrains.dokka.gradle.DokkaTask
import java.io.File
import kotlin.collections.component1 import kotlin.collections.component1
import kotlin.collections.component2 import kotlin.collections.component2
class KSciencePublishingExtension(val project: Project) { class KSciencePublishingExtension(val project: Project) {
var vcs: String? by project.extra
var githubOrg: String? by project.extra var githubOrg: String? by project.extra
var githubProject: String? by project.extra var githubProject: String? by project.extra
var spaceRepo: 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 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<Feature>()
fun feature(id: String, ref: String, description: String, name: String = id) {
features.add(Feature(id, ref, description, name))
}
val properties: MutableMap<String, () -> 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<File>()
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 * Apply extension and repositories

View File

@ -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<ApiValidationExtension>().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<Feature>()
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<String, () -> 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<File>()
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
}
}
}

View File

@ -6,19 +6,19 @@ import org.gradle.api.JavaVersion
* Build constants * Build constants
*/ */
object KScienceVersions { object KScienceVersions {
const val kotlinVersion = "1.4.21" const val kotlinVersion = "1.4.30"
const val kotlinxNodeVersion = "0.0.7" const val kotlinxNodeVersion = "0.0.7"
const val coroutinesVersion = "1.4.2" const val coroutinesVersion = "1.4.2"
const val serializationVersion = "1.0.1" const val serializationVersion = "1.1.0-RC"
const val atomicVersion = "0.14.4" const val atomicVersion = "0.15.1"
const val ktorVersion = "1.5.1"
const val htmlVersion = "0.7.2"
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 bsonVersion = "0.4.4" const val bsonVersion = "0.4.4"
const val yamlKtVersion = "0.7.5" const val yamlKtVersion = "0.9.0"
} }
} }

View File

@ -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( fun Project.yamlKt(
version: String = KScienceVersions.Serialization.yamlKtVersion version: String = KScienceVersions.Serialization.yamlKtVersion
) { ) {

View File

@ -8,6 +8,7 @@ import org.gradle.kotlin.dsl.maven
import org.jetbrains.kotlin.gradle.plugin.LanguageSettingsBuilder import org.jetbrains.kotlin.gradle.plugin.LanguageSettingsBuilder
internal fun LanguageSettingsBuilder.applySettings(): Unit { internal fun LanguageSettingsBuilder.applySettings(): Unit {
languageVersion = "1.4"
progressiveMode = true progressiveMode = true
enableLanguageFeature("InlineClasses") enableLanguageFeature("InlineClasses")
useExperimentalAnnotation("kotlin.Experimental") useExperimentalAnnotation("kotlin.Experimental")
@ -20,7 +21,6 @@ internal fun LanguageSettingsBuilder.applySettings(): Unit {
internal fun RepositoryHandler.applyRepos(): Unit { internal fun RepositoryHandler.applyRepos(): Unit {
mavenCentral() mavenCentral()
jcenter()
maven("https://dl.bintray.com/kotlin/kotlin-eap") maven("https://dl.bintray.com/kotlin/kotlin-eap")
maven("https://dl.bintray.com/kotlin/kotlin-dev") maven("https://dl.bintray.com/kotlin/kotlin-dev")
maven("https://kotlin.bintray.com/kotlinx") 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/kscience")
maven("https://dl.bintray.com/mipt-npm/dev") maven("https://dl.bintray.com/mipt-npm/dev")
maven("https://dl.bintray.com/mipt-npm/dataforge") 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] val configuration = configurations[configurationName]
?: error("Configuration with name $configurationName could not be resolved.") ?: error("Configuration with name $configurationName could not be resolved.")
val projectDeps = configuration.allDependencies.filterIsInstance<ProjectDependency>().map { val projectDeps = configuration.allDependencies.filterIsInstance<ProjectDependency>().map {

View File

@ -18,10 +18,10 @@ internal fun Project.configurePublishing() {
val vcs = findProperty("vcs") as? String val vcs = findProperty("vcs") as? String
?: githubProject?.let { "https://github.com/$githubOrg/$it" } ?: githubProject?.let { "https://github.com/$githubOrg/$it" }
if (vcs == null) { // if (vcs == null) {
project.logger.warn("[${project.name}] Missing deployment configuration. Skipping publish.") // project.logger.warn("[${project.name}] Missing deployment configuration. Skipping publish.")
return // return
} // }
project.configure<PublishingExtension> { project.configure<PublishingExtension> {
plugins.withId("org.jetbrains.kotlin.js") { plugins.withId("org.jetbrains.kotlin.js") {
@ -62,7 +62,7 @@ internal fun Project.configurePublishing() {
publication.pom { publication.pom {
name.set(project.name) name.set(project.name)
description.set(project.description) description.set(project.description)
url.set(vcs) vcs?.let{url.set(vcs)}
licenses { licenses {
license { license {
@ -80,9 +80,11 @@ internal fun Project.configurePublishing() {
} }
} }
scm { vcs?.let {
url.set(vcs) scm {
tag.set(project.version.toString()) url.set(vcs)
tag.set(project.version.toString())
}
} }
} }
} }