diff --git a/CHANGELOG.md b/CHANGELOG.md index a68ea7f..ee5ca99 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,24 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed +### Security +## [0.10.0] +### Added +- Lazy readme properties +- BOM for kotlin-wrappers on JS +- Jupyter loader + +### Changed +- API validation disabled for dev versions +- Kotlin plugins are propagated downstream + +### Deprecated + +### Removed +- bson support + +### Fixed + ### Security ## [0.9.5] diff --git a/build.gradle.kts b/build.gradle.kts index 2d3f61f..6f24dd6 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,7 +8,7 @@ plugins { } group = "ru.mipt.npm" -version = "0.9.5" +version = "0.10.0" description = "Build tools for DataForge and kscience projects" @@ -22,20 +22,20 @@ repositories { maven("https://repo.kotlin.link") } -val kotlinVersion = "1.5.0" +val kotlinVersion = "1.5.10" java { - targetCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_11 } -// Add plugins used in buildSrc as dependencies, also we should specify version only here dependencies { - implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion") + api("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion") + implementation("org.jetbrains.kotlin:kotlin-jupyter-api-gradle-plugin:0.10.0-53") implementation("org.jetbrains.kotlin:kotlin-serialization:$kotlinVersion") implementation("org.jetbrains.kotlinx:atomicfu-gradle-plugin:0.16.1") implementation("org.jetbrains.dokka:dokka-gradle-plugin:1.4.32") 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.6.0") } project.extensions.findByType()?.apply { diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index f371643..0f80bbf 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-7.0-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew old mode 100644 new mode 100755 diff --git a/settings.gradle b/settings.gradle deleted file mode 100644 index bc059c6..0000000 --- a/settings.gradle +++ /dev/null @@ -1,2 +0,0 @@ -rootProject.name = 'gradle-tools' - diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 0000000..666c23d --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1 @@ +rootProject.name = "gradle-tools" \ No newline at end of file diff --git a/src/main/kotlin/ru/mipt/npm/gradle/KScienceCommonPlugin.kt b/src/main/kotlin/ru/mipt/npm/gradle/KScienceCommonPlugin.kt index 33a9556..63d2c37 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/KScienceCommonPlugin.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/KScienceCommonPlugin.kt @@ -14,6 +14,7 @@ import ru.mipt.npm.gradle.internal.applyRepos import ru.mipt.npm.gradle.internal.applySettings import ru.mipt.npm.gradle.internal.fromJsDependencies +@Suppress("UNUSED_VARIABLE") open class KScienceCommonPlugin : Plugin { override fun apply(project: Project): Unit = project.run { //Common configuration @@ -40,7 +41,6 @@ open class KScienceCommonPlugin : Plugin { } tasks.withType { kotlinOptions { - useIR = true jvmTarget = KScienceVersions.JVM_TARGET.toString() freeCompilerArgs = freeCompilerArgs + "-Xjvm-default=all" } @@ -63,7 +63,7 @@ open class KScienceCommonPlugin : Plugin { explicitApiWarning() js(IR) { - browser{ + browser { commonWebpackConfig { cssSupport.enabled = true } @@ -72,6 +72,9 @@ open class KScienceCommonPlugin : Plugin { sourceSets["main"].apply { languageSettings.applySettings() + dependencies { + api(project.dependencies.platform("org.jetbrains.kotlin-wrappers:kotlin-wrappers-bom:${KScienceVersions.jsBom}")) + } } sourceSets["test"].apply { @@ -95,7 +98,6 @@ open class KScienceCommonPlugin : Plugin { jvm { compilations.all { kotlinOptions { - useIR = true jvmTarget = KScienceVersions.JVM_TARGET.toString() freeCompilerArgs = freeCompilerArgs + "-Xjvm-default=all" } @@ -103,7 +105,7 @@ open class KScienceCommonPlugin : Plugin { } js(IR) { - browser{ + browser { commonWebpackConfig { cssSupport.enabled = true } @@ -111,7 +113,11 @@ open class KScienceCommonPlugin : Plugin { } sourceSets.invoke { - val commonMain by getting + val commonMain by getting { + dependencies { + api(project.dependencies.platform("org.jetbrains.kotlin-wrappers:kotlin-wrappers-bom:${KScienceVersions.jsBom}")) + } + } val commonTest by getting { dependencies { implementation(kotlin("test-common")) diff --git a/src/main/kotlin/ru/mipt/npm/gradle/KScienceExtension.kt b/src/main/kotlin/ru/mipt/npm/gradle/KScienceExtension.kt index 110f22d..dee6d7d 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/KScienceExtension.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/KScienceExtension.kt @@ -2,8 +2,6 @@ package ru.mipt.npm.gradle import org.gradle.api.Project 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.findByType import org.jetbrains.kotlin.gradle.dsl.KotlinJsProjectExtension import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension @@ -49,7 +47,7 @@ class KScienceExtension(val project: Project) { fun useCoroutines( version: String = KScienceVersions.coroutinesVersion, sourceSet: DependencySourceSet = DependencySourceSet.MAIN, - configuration: DependencyConfiguration = DependencyConfiguration.API + configuration: DependencyConfiguration = DependencyConfiguration.API, ): Unit = project.useCommonDependency( "org.jetbrains.kotlinx:kotlinx-coroutines-core:$version", dependencySourceSet = sourceSet, @@ -62,7 +60,7 @@ class KScienceExtension(val project: Project) { fun useAtomic( version: String = KScienceVersions.atomicVersion, sourceSet: DependencySourceSet = DependencySourceSet.MAIN, - configuration: DependencyConfiguration = DependencyConfiguration.IMPLEMENTATION + configuration: DependencyConfiguration = DependencyConfiguration.IMPLEMENTATION, ): Unit = project.run { plugins.apply("kotlinx-atomicfu") useCommonDependency( @@ -79,7 +77,7 @@ class KScienceExtension(val project: Project) { version: String = KScienceVersions.serializationVersion, sourceSet: DependencySourceSet = DependencySourceSet.MAIN, configuration: DependencyConfiguration = DependencyConfiguration.API, - block: SerializationTargets.() -> Unit = {} + block: SerializationTargets.() -> Unit = {}, ): Unit = project.run { plugins.apply("org.jetbrains.kotlin.plugin.serialization") val artifactName = if (version.startsWith("0")) { @@ -95,17 +93,23 @@ class KScienceExtension(val project: Project) { SerializationTargets(sourceSet, configuration).apply(block) } + /** + * Add platform-specific JavaFX dependencies with given list of [FXModule]s + */ fun useFx( vararg modules: FXModule, configuration: DependencyConfiguration = DependencyConfiguration.COMPILE_ONLY, version: String = "11", - platform: FXPlatform = defaultPlatform + platform: FXPlatform = defaultPlatform, ) = project.useFx(modules.toList(), configuration, version, platform) + /** + * Add dependency on kotlinx-html library + */ fun useHtml( - version: String = KScienceVersions.atomicVersion, + version: String = KScienceVersions.htmlVersion, sourceSet: DependencySourceSet = DependencySourceSet.MAIN, - configuration: DependencyConfiguration = DependencyConfiguration.IMPLEMENTATION + configuration: DependencyConfiguration = DependencyConfiguration.API, ): Unit = project.useCommonDependency( "org.jetbrains.kotlinx:kotlinx-html:$version", dependencySourceSet = sourceSet, @@ -115,8 +119,23 @@ class KScienceExtension(val project: Project) { /** * Use kotlinx-datetime library with default version or [version] */ - fun useDateTime(version: String = KScienceVersions.dateTimeVersion){ - project.useCommonDependency("org.jetbrains.kotlinx:kotlinx-datetime:$version") + fun useDateTime( + version: String = KScienceVersions.dateTimeVersion, + sourceSet: DependencySourceSet = DependencySourceSet.MAIN, + configuration: DependencyConfiguration = DependencyConfiguration.API, + ) { + project.useCommonDependency( + "org.jetbrains.kotlinx:kotlinx-datetime:$version", + dependencySourceSet = sourceSet, + dependencyConfiguration = configuration + ) + } + + /** + * Apply jupyter plugin + */ + fun useJupyter() { + project.plugins.apply("org.jetbrains.kotlin.jupyter.api") } /** @@ -146,10 +165,6 @@ class KScienceExtension(val project: Project) { } } } - - fun publish() { - project.plugins.apply(MavenPublishPlugin::class) - } } internal fun Project.registerKScienceExtension() { diff --git a/src/main/kotlin/ru/mipt/npm/gradle/KScienceProjectPlugin.kt b/src/main/kotlin/ru/mipt/npm/gradle/KScienceProjectPlugin.kt index 8d33965..16862e9 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/KScienceProjectPlugin.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/KScienceProjectPlugin.kt @@ -7,6 +7,8 @@ import org.gradle.api.Plugin import org.gradle.api.Project import org.gradle.kotlin.dsl.* import org.jetbrains.changelog.ChangelogPlugin +import org.jetbrains.changelog.ChangelogPluginExtension +import org.jetbrains.dokka.gradle.AbstractDokkaTask import org.jetbrains.dokka.gradle.DokkaPlugin import org.jetbrains.dokka.gradle.DokkaTask import ru.mipt.npm.gradle.internal.* @@ -15,7 +17,7 @@ import ru.mipt.npm.gradle.internal.* class KSciencePublishingExtension(val project: Project) { private var initializedFlag = false - fun configurePublications(vcsUrl: String) { + fun vcs(vcsUrl: String) { if (!initializedFlag) { project.setupPublication(vcsUrl) initializedFlag = true @@ -24,21 +26,37 @@ class KSciencePublishingExtension(val project: Project) { /** * github publishing + * @param publish include github packages in release publishing. By default - false */ - fun github(githubProject: String, githubOrg: String = "mipt-npm") { + fun github(githubProject: String, githubOrg: String = "mipt-npm", publish: Boolean = false) { //automatically initialize vcs using github if (!initializedFlag) { - configurePublications("https://github.com/$githubOrg/$githubProject") + vcs("https://github.com/$githubOrg/$githubProject") } project.addGithubPublishing(githubOrg, githubProject) + + if (publish) { + project.tasks.findByName("publish${project.publicationTarget}ToGithubRepository")?.let {publicationTask-> + releaseTask?.dependsOn(publicationTask) + } + } + } + + private val releaseTask by lazy { + project.tasks.findByName("release") } /** * Space publishing */ - 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" } + fun space(spaceRepo: String = "https://maven.pkg.jetbrains.space/mipt-npm/p/sci/maven", publish: Boolean = false) { + require(initializedFlag) { "The project vcs is not set up use 'vcs' method to do so" } project.addSpacePublishing(spaceRepo) + if (publish) { + project.tasks.findByName("publish${project.publicationTarget}ToSpaceRepository")?.let { publicationTask -> + releaseTask?.dependsOn(publicationTask) + } + } } // // Bintray publishing @@ -50,9 +68,15 @@ class KSciencePublishingExtension(val project: Project) { /** * Sonatype publishing */ - fun sonatype() { - require(initializedFlag) { "The publishing is not set up use 'configurePublications' method to do so" } + fun sonatype(publish: Boolean = true) { + require(initializedFlag) { "The project vcs is not set up use 'vcs' method to do so" } project.addSonatypePublishing() + if (publish) { + project.tasks.findByName("publish${project.publicationTarget}ToSonatypeRepository") + ?.let { publicationTask -> + releaseTask?.dependsOn(publicationTask) + } + } } } @@ -63,9 +87,22 @@ class KSciencePublishingExtension(val project: Project) { open class KScienceProjectPlugin : Plugin { override fun apply(target: Project): Unit = target.run { apply() + apply() apply() + afterEvaluate { + if (isSnapshot()) { + configure { + validationDisabled = true + } + } else { + configure { + version = project.version.toString() + } + } + } + val rootReadmeExtension = KScienceReadmeExtension(this) extensions.add("ksciencePublish", KSciencePublishingExtension(this)) extensions.add("readme", rootReadmeExtension) @@ -164,7 +201,7 @@ open class KScienceProjectPlugin : Plugin { } } - tasks.withType { + tasks.withType { 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 53e6e71..874a166 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/KScienceReadmeExtension.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/KScienceReadmeExtension.kt @@ -36,15 +36,15 @@ class KScienceReadmeExtension(val project: Project) { data class Feature(val id: String, val description: String, val ref: String?, val name: String = id) - val features = ArrayList() + val features: MutableList = ArrayList() @Deprecated("Use lambda builder instead") fun feature(id: String, description: String, ref: String? = null, name: String = id) { - features.add(Feature(id, description, ref, name)) + features += Feature(id, description, ref, name) } fun feature(id: String, ref: String? = null, name: String = id, description: () -> String) { - features.add(Feature(id, description(), ref, name)) + features += Feature(id, description(), ref, name) } private val properties: MutableMap Any?> = mutableMapOf( @@ -55,14 +55,16 @@ class KScienceReadmeExtension(val project: Project) { ) val actualizedProperties - get() = properties.mapValues { (_, value) -> - value.invoke() - } + get() = properties.mapValues { (_, value) -> value() } fun property(key: String, value: Any?) { properties[key] = { value } } + fun property(key: String, value: () -> Any?) { + properties[key] = value + } + fun propertyByTemplate(key: String, template: String) { val actual = actualizedProperties properties[key] = { SimpleTemplateEngine().createTemplate(template).make(actual).toString() } @@ -73,7 +75,7 @@ class KScienceReadmeExtension(val project: Project) { fun propertyByTemplate(key: String, template: File) { val actual = actualizedProperties properties[key] = { SimpleTemplateEngine().createTemplate(template).make(actual).toString() } - additionalFiles.add(template) + additionalFiles += template } /** diff --git a/src/main/kotlin/ru/mipt/npm/gradle/KScienceVersions.kt b/src/main/kotlin/ru/mipt/npm/gradle/KScienceVersions.kt index eb8f07e..06ada3c 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/KScienceVersions.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/KScienceVersions.kt @@ -6,20 +6,20 @@ import org.gradle.api.JavaVersion * Build constants */ object KScienceVersions { - const val kotlinVersion = "1.5.0" + const val kotlinVersion = "1.5.10" const val kotlinxNodeVersion = "0.0.7" - const val coroutinesVersion = "1.4.3" - const val serializationVersion = "1.1.0" + const val coroutinesVersion = "1.5.0" + const val serializationVersion = "1.2.1" const val atomicVersion = "0.16.1" - const val ktorVersion = "1.5.3" + const val ktorVersion = "1.6.0" const val htmlVersion = "0.7.3" - const val dateTimeVersion = "0.1.1" + const val dateTimeVersion = "0.2.1" + const val jsBom = "0.0.1-pre.213-kotlin-1.5.10" val JVM_TARGET = JavaVersion.VERSION_11 object Serialization{ - const val xmlVersion = "0.81.2" - const val bsonVersion = "0.4.4" + const val xmlVersion = "0.82.0" 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 f9972d3..62873c0 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/SerializationTargets.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/SerializationTargets.kt @@ -1,10 +1,7 @@ package ru.mipt.npm.gradle import org.gradle.api.Project -import org.gradle.kotlin.dsl.maven -import org.gradle.kotlin.dsl.repositories import ru.mipt.npm.gradle.internal.useCommonDependency -import ru.mipt.npm.gradle.internal.useDependency class SerializationTargets( val sourceSet: DependencySourceSet, @@ -44,11 +41,8 @@ class SerializationTargets( fun Project.xml( version: String = KScienceVersions.Serialization.xmlVersion ) { - repositories { - maven("https://dl.bintray.com/pdvrieze/maven") - } useCommonDependency( - "net.devrieze:xmlutil-serialization:$version", + "io.github.pdvrieze.xmlutil:serialization:$version", dependencySourceSet = sourceSet, dependencyConfiguration = configuration ) @@ -63,14 +57,4 @@ class SerializationTargets( dependencyConfiguration = configuration ) } - - fun Project.bson( - version: String = KScienceVersions.Serialization.bsonVersion - ) { - useDependency( - "jvm" to "com.github.jershell:kbson:$version", - dependencySourceSet = sourceSet, - dependencyConfiguration = configuration - ) - } } 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 775dc2f..9b8b60e 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/internal/common.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/internal/common.kt @@ -22,8 +22,6 @@ internal fun LanguageSettingsBuilder.applySettings(): Unit { internal fun RepositoryHandler.applyRepos(): Unit { mavenCentral() 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") } internal fun Copy.fromJsDependencies(configurationName: String) = project.run { diff --git a/src/main/kotlin/ru/mipt/npm/gradle/internal/publishing.kt b/src/main/kotlin/ru/mipt/npm/gradle/internal/publishing.kt index dbb42a4..94eccc8 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/internal/publishing.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/internal/publishing.kt @@ -20,33 +20,42 @@ internal fun Project.setupPublication(vcs: String) = allprojects { plugins.withId("maven-publish") { configure { - plugins.withId("ru.mipt.npm.gradle.js") { - val kotlin = extensions.findByType()!! + plugins.withId("org.jetbrains.kotlin.js") { + val kotlin: KotlinJsProjectExtension = extensions.findByType()!! val sourcesJar: Jar by tasks.creating(Jar::class) { archiveClassifier.set("sources") - from(kotlin.sourceSets["main"].kotlin) + kotlin.sourceSets.forEach{ + from(it.kotlin) + } } - - publications { - create("js", MavenPublication::class) { - from(components["kotlin"]) - artifact(sourcesJar) + afterEvaluate { + publications { + create("js", MavenPublication::class) { + kotlin.js().components.forEach { + from(it) + } + artifact(sourcesJar) + } } } } - plugins.withId("ru.mipt.npm.gradle.jvm") { + plugins.withId("org.jetbrains.kotlin.jvm") { val kotlin = extensions.findByType()!! val sourcesJar: Jar by tasks.creating(Jar::class) { archiveClassifier.set("sources") - from(kotlin.sourceSets["main"].kotlin) + kotlin.sourceSets.forEach{ + from(it.kotlin) + } } publications { create("jvm", MavenPublication::class) { - from(components["kotlin"]) + kotlin.target.components.forEach { + from(it) + } artifact(sourcesJar) } } @@ -110,7 +119,7 @@ internal val Project.publicationTarget: String internal fun Project.addGithubPublishing( githubOrg: String, - githubProject: String + githubProject: String, ) { if (requestPropertyOrNull("publishing.enabled") != "true") { logger.info("Skipping github publishing because publishing is disabled") @@ -139,8 +148,6 @@ internal fun Project.addGithubPublishing( } } } - val publicationTask = tasks.getByName("publish${publicationTarget}ToGithubRepository") - rootProject.tasks.findByName("release")?.dependsOn(publicationTask) } } } @@ -174,8 +181,6 @@ internal fun Project.addSpacePublishing(spaceRepo: String) { } } } - val publicationTask = tasks.getByName("publish${publicationTarget}ToSpaceRepository") - rootProject.tasks.findByName("release")?.dependsOn(publicationTask) } } } @@ -229,8 +234,6 @@ internal fun Project.addSonatypePublishing() { } } } - val publicationTask = tasks.getByName("publish${publicationTarget}ToSonatypeRepository") - rootProject.tasks.findByName("release")?.dependsOn(publicationTask) } } }