Merge pull request #14 from mipt-npm/dev

Dev
This commit is contained in:
Alexander Nozik 2021-04-26 19:19:52 +03:00 committed by GitHub
commit dad49b0c66
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 95 additions and 73 deletions

View File

@ -9,9 +9,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added ### Added
### Changed ### Changed
- `publication.platform` changed to `publishing.platform`
- Dokka version to `1.4.30`
- `useDateTime` in extension
### Deprecated ### Deprecated
@ -21,6 +18,27 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Security ### Security
## [0.9.5]
### Added
- Disable API validation for snapshots
- `-Xjvm-default=all` on JVM
### Changed
- `publication.platform` changed to `publishing.platform`
- Dokka version to `1.4.30`
- `useDateTime` in extension
- Kotlin 1.5
### Deprecated
### Removed
- Publish plugin. Use MavenPublish instead
### Fixed
- Removed unnecessary `afterEvaluate` for compatibility with gradle 7.0
### Security
## [0.9.0] ## [0.9.0]
### Added ### Added
- Skip sonatype publishing for dev versions - Skip sonatype publishing for dev versions

View File

@ -4,23 +4,25 @@ plugins {
`maven-publish` `maven-publish`
signing signing
id("org.jetbrains.changelog") version "1.1.2" id("org.jetbrains.changelog") version "1.1.2"
id("org.jetbrains.dokka") version "1.4.30" id("org.jetbrains.dokka") version "1.4.32"
} }
group = "ru.mipt.npm" group = "ru.mipt.npm"
version = "0.9.3" version = "0.9.5"
description = "Build tools for DataForge and kscience projects" description = "Build tools for DataForge and kscience projects"
repositories { changelog{
gradlePluginPortal() version = project.version.toString()
jcenter()
maven("https://repo.kotlin.link")
maven("https://kotlin.bintray.com/kotlinx")
maven("https://dl.bintray.com/kotlin/kotlin-dev")
} }
val kotlinVersion = "1.4.32" repositories {
mavenCentral()
gradlePluginPortal()
maven("https://repo.kotlin.link")
}
val kotlinVersion = "1.5.0"
java { java {
targetCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8
@ -30,8 +32,8 @@ 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.2") implementation("org.jetbrains.kotlinx:atomicfu-gradle-plugin:0.16.1")
implementation("org.jetbrains.dokka:dokka-gradle-plugin:1.4.30") implementation("org.jetbrains.dokka:dokka-gradle-plugin:1.4.32")
implementation("org.jetbrains.intellij.plugins:gradle-changelog-plugin:1.1.2") implementation("org.jetbrains.intellij.plugins:gradle-changelog-plugin:1.1.2")
implementation("org.jetbrains.kotlinx:binary-compatibility-validator:0.5.0") implementation("org.jetbrains.kotlinx:binary-compatibility-validator:0.5.0")
} }

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.8.3-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-7.0-bin.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists

View File

@ -42,6 +42,7 @@ open class KScienceCommonPlugin : Plugin<Project> {
kotlinOptions { kotlinOptions {
useIR = true useIR = true
jvmTarget = KScienceVersions.JVM_TARGET.toString() jvmTarget = KScienceVersions.JVM_TARGET.toString()
freeCompilerArgs = freeCompilerArgs + "-Xjvm-default=all"
} }
} }
@ -96,6 +97,7 @@ open class KScienceCommonPlugin : Plugin<Project> {
kotlinOptions { kotlinOptions {
useIR = true useIR = true
jvmTarget = KScienceVersions.JVM_TARGET.toString() jvmTarget = KScienceVersions.JVM_TARGET.toString()
freeCompilerArgs = freeCompilerArgs + "-Xjvm-default=all"
} }
} }
} }

View File

@ -2,6 +2,7 @@ package ru.mipt.npm.gradle
import org.gradle.api.Project import org.gradle.api.Project
import org.gradle.api.plugins.ApplicationPlugin import org.gradle.api.plugins.ApplicationPlugin
import org.gradle.api.publish.maven.plugins.MavenPublishPlugin
import org.gradle.kotlin.dsl.apply import org.gradle.kotlin.dsl.apply
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
@ -101,6 +102,16 @@ class KScienceExtension(val project: Project) {
platform: FXPlatform = defaultPlatform platform: FXPlatform = defaultPlatform
) = project.useFx(modules.toList(), configuration, version, platform) ) = project.useFx(modules.toList(), configuration, version, platform)
fun useHtml(
version: String = KScienceVersions.atomicVersion,
sourceSet: DependencySourceSet = DependencySourceSet.MAIN,
configuration: DependencyConfiguration = DependencyConfiguration.IMPLEMENTATION
): Unit = project.useCommonDependency(
"org.jetbrains.kotlinx:kotlinx-html:$version",
dependencySourceSet = sourceSet,
dependencyConfiguration = configuration
)
/** /**
* Use kotlinx-datetime library with default version or [version] * Use kotlinx-datetime library with default version or [version]
*/ */
@ -137,7 +148,7 @@ class KScienceExtension(val project: Project) {
} }
fun publish() { fun publish() {
project.plugins.apply(KSciencePublishingPlugin::class) project.plugins.apply(MavenPublishPlugin::class)
} }
} }

View File

@ -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.ApiValidationExtension
import kotlinx.validation.BinaryCompatibilityValidatorPlugin import kotlinx.validation.BinaryCompatibilityValidatorPlugin
import org.gradle.api.Plugin import org.gradle.api.Plugin
import org.gradle.api.Project import org.gradle.api.Project
@ -8,17 +9,14 @@ 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 ru.mipt.npm.gradle.internal.addGithubPublishing import ru.mipt.npm.gradle.internal.*
import ru.mipt.npm.gradle.internal.addSonatypePublishing
import ru.mipt.npm.gradle.internal.addSpacePublishing
import ru.mipt.npm.gradle.internal.setupPublication
@Suppress("unused") @Suppress("unused")
class KSciencePublishingExtension(val project: Project) { class KSciencePublishingExtension(val project: Project) {
private var initializedFlag = false private var initializedFlag = false
fun configurePublications(vcsUrl: String){ fun configurePublications(vcsUrl: String) {
if(!initializedFlag) { if (!initializedFlag) {
project.setupPublication(vcsUrl) project.setupPublication(vcsUrl)
initializedFlag = true initializedFlag = true
} }
@ -29,7 +27,7 @@ class KSciencePublishingExtension(val project: Project) {
*/ */
fun github(githubProject: String, githubOrg: String = "mipt-npm") { fun github(githubProject: String, githubOrg: String = "mipt-npm") {
//automatically initialize vcs using github //automatically initialize vcs using github
if(!initializedFlag){ if (!initializedFlag) {
configurePublications("https://github.com/$githubOrg/$githubProject") configurePublications("https://github.com/$githubOrg/$githubProject")
} }
project.addGithubPublishing(githubOrg, githubProject) project.addGithubPublishing(githubOrg, githubProject)
@ -39,7 +37,7 @@ class KSciencePublishingExtension(val project: Project) {
* Space publishing * Space publishing
*/ */
fun space(spaceRepo: String = "https://maven.pkg.jetbrains.space/mipt-npm/p/sci/maven") { fun space(spaceRepo: String = "https://maven.pkg.jetbrains.space/mipt-npm/p/sci/maven") {
require(initializedFlag){"The publishing is not set up use 'configurePublications' method to do so"} require(initializedFlag) { "The publishing is not set up use 'configurePublications' method to do so" }
project.addSpacePublishing(spaceRepo) project.addSpacePublishing(spaceRepo)
} }
@ -52,8 +50,8 @@ class KSciencePublishingExtension(val project: Project) {
/** /**
* Sonatype publishing * Sonatype publishing
*/ */
fun sonatype(){ fun sonatype() {
require(initializedFlag){"The publishing is not set up use 'configurePublications' method to do so"} require(initializedFlag) { "The publishing is not set up use 'configurePublications' method to do so" }
project.addSonatypePublishing() project.addSonatypePublishing()
} }
} }
@ -139,19 +137,19 @@ open class KScienceProjectPlugin : Plugin<Project> {
val name = subproject.name val name = subproject.name
val path = subproject.path.replaceFirst(":", "").replace(":", "/") val path = subproject.path.replaceFirst(":", "").replace(":", "/")
val ext = subproject.extensions.findByType<KScienceReadmeExtension>() val ext = subproject.extensions.findByType<KScienceReadmeExtension>()
appendln("<hr/>") appendLine("<hr/>")
appendln("\n* ### [$name]($path)") appendLine("\n* ### [$name]($path)")
if (ext != null) { if (ext != null) {
appendln("> ${ext.description}") appendLine("> ${ext.description}")
appendln(">\n> **Maturity**: ${ext.maturity}") appendLine(">\n> **Maturity**: ${ext.maturity}")
val featureString = ext.featuresString(itemPrefix = "> - ", pathPrefix = "$path/") val featureString = ext.featuresString(itemPrefix = "> - ", pathPrefix = "$path/")
if (featureString.isNotBlank()) { if (featureString.isNotBlank()) {
appendln(">\n> **Features:**") appendLine(">\n> **Features:**")
appendln(featureString) appendLine(featureString)
} }
} }
} }
appendln("<hr/>") appendLine("<hr/>")
} }
val rootReadmeProperties: Map<String, Any?> = val rootReadmeProperties: Map<String, Any?> =
@ -170,13 +168,21 @@ open class KScienceProjectPlugin : Plugin<Project> {
dependsOn(generateReadme) dependsOn(generateReadme)
} }
val patchChangelog by tasks.getting //val patchChangelog by tasks.getting
val release by tasks.creating { val release by tasks.creating {
group = RELEASE_GROUP group = RELEASE_GROUP
description = "Publish development or production release based on version suffix" description = "Publish development or production release based on version suffix"
dependsOn(generateReadme) dependsOn(generateReadme)
} }
// Disable API validation for snapshots
if (isSnapshot()) {
extensions.findByType<ApiValidationExtension>()?.apply {
validationDisabled = true
logger.warn("API validation is disabled for snapshot or dev version")
}
}
} }
companion object { companion object {

View File

@ -1,17 +0,0 @@
package ru.mipt.npm.gradle
import org.gradle.api.Plugin
import org.gradle.api.Project
@Deprecated("To be replaced by maven-publish")
open class KSciencePublishingPlugin : Plugin<Project> {
override fun apply(project: Project): Unit = project.run {
if (plugins.findPlugin("maven-publish") == null) {
plugins.apply("maven-publish")
}
}
}

View File

@ -38,6 +38,7 @@ class KScienceReadmeExtension(val project: Project) {
val features = ArrayList<Feature>() val features = ArrayList<Feature>()
@Deprecated("Use lambda builder instead")
fun feature(id: String, description: String, ref: String? = null, name: String = id) { fun feature(id: String, description: String, ref: String? = null, name: String = id) {
features.add(Feature(id, description, ref, name)) features.add(Feature(id, description, ref, name))
} }
@ -80,7 +81,7 @@ class KScienceReadmeExtension(val project: Project) {
*/ */
fun featuresString(itemPrefix: String = " - ", pathPrefix: String = "") = buildString { fun featuresString(itemPrefix: String = " - ", pathPrefix: String = "") = buildString {
features.forEach { features.forEach {
appendln("$itemPrefix[${it.name}]($pathPrefix${it.ref ?: "#"}) : ${it.description}") appendLine("$itemPrefix[${it.name}]($pathPrefix${it.ref ?: "#"}) : ${it.description}")
} }
} }

View File

@ -6,19 +6,19 @@ import org.gradle.api.JavaVersion
* Build constants * Build constants
*/ */
object KScienceVersions { object KScienceVersions {
const val kotlinVersion = "1.4.32" const val kotlinVersion = "1.5.0"
const val kotlinxNodeVersion = "0.0.7" const val kotlinxNodeVersion = "0.0.7"
const val coroutinesVersion = "1.4.3" const val coroutinesVersion = "1.4.3"
const val serializationVersion = "1.1.0" const val serializationVersion = "1.1.0"
const val atomicVersion = "0.15.1" const val atomicVersion = "0.16.1"
const val ktorVersion = "1.5.2" const val ktorVersion = "1.5.3"
const val htmlVersion = "0.7.2" const val htmlVersion = "0.7.3"
const val dateTimeVersion = "0.1.1" const val dateTimeVersion = "0.1.1"
val JVM_TARGET = JavaVersion.VERSION_11 val JVM_TARGET = JavaVersion.VERSION_11
object Serialization{ object Serialization{
const val xmlVersion = "0.81.1" const val xmlVersion = "0.81.2"
const val bsonVersion = "0.4.4" const val bsonVersion = "0.4.4"
const val yamlKtVersion = "0.9.0" const val yamlKtVersion = "0.9.0"
} }

View File

@ -8,9 +8,9 @@ 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" languageVersion = "1.5"
apiVersion = "1.5"
progressiveMode = true progressiveMode = true
enableLanguageFeature("InlineClasses")
useExperimentalAnnotation("kotlin.Experimental") useExperimentalAnnotation("kotlin.Experimental")
useExperimentalAnnotation("kotlin.ExperimentalUnsignedTypes") useExperimentalAnnotation("kotlin.ExperimentalUnsignedTypes")
useExperimentalAnnotation("kotlin.ExperimentalStdlibApi") useExperimentalAnnotation("kotlin.ExperimentalStdlibApi")
@ -22,31 +22,30 @@ internal fun LanguageSettingsBuilder.applySettings(): Unit {
internal fun RepositoryHandler.applyRepos(): Unit { internal fun RepositoryHandler.applyRepos(): Unit {
mavenCentral() mavenCentral()
maven("https://repo.kotlin.link") maven("https://repo.kotlin.link")
maven("https://maven.pkg.jetbrains.space/public/p/kotlinx-html/maven")
maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/kotlin-js-wrappers") maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/kotlin-js-wrappers")
} }
internal fun Copy.fromJsDependencies(configurationName: String) = project.afterEvaluate { internal fun Copy.fromJsDependencies(configurationName: String) = project.run {
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 {
it.dependencyProject it.dependencyProject
} }
projectDeps.forEach { dep -> projectDeps.forEach { dep ->
dep.afterEvaluate { dep.pluginManager.withPlugin("org.jetbrains.kotlin.multiplatform") {
dep.pluginManager.withPlugin("org.jetbrains.kotlin.multiplatform") { dep.tasks.findByName("jsProcessResources")?.let { task ->
dep.tasks.findByName("jsProcessResources")?.let { task -> dependsOn(task)
dependsOn(task) from(task)
from(task)
}
}
dep.pluginManager.withPlugin("org.jetbrains.kotlin.js") {
dep.tasks.findByName("processResources")?.let { task ->
dependsOn(task)
from(task)
}
} }
} }
} dep.pluginManager.withPlugin("org.jetbrains.kotlin.js") {
dep.tasks.findByName("processResources")?.let { task ->
dependsOn(task)
from(task)
}
}
}
} }