diff --git a/CHANGELOG.md b/CHANGELOG.md index ee5ca99..426e500 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed ### Security +## [0.10.2] +### Added +- Experimental automatic JS project bundling in MPP + +### Changed + +### Deprecated + +### Removed + +### Fixed +-Release task (#19) + +### Security + ## [0.10.0] ### Added - Lazy readme properties diff --git a/README.md b/README.md index d313dda..0a5f396 100644 --- a/README.md +++ b/README.md @@ -8,9 +8,6 @@ A primary plugin. When used with kotlin-jvm, kotlin-js or kotlin-mulitplatform c ## ru.mipt.npm.gradle.project Root project tool including JetBrains changelog plugin an kotlin binary compatibility validator tool. -## ru.mipt.npm.gradle.publish -Enables publishing to maven-central, bintray, Space and github. - ## ru.mipt.npm.gradle.mpp `= kotlin("multiplatform") + ru.mipt.npm.gradle.common` diff --git a/build.gradle.kts b/build.gradle.kts index 6f24dd6..8aa1a85 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -3,17 +3,17 @@ plugins { `kotlin-dsl` `maven-publish` signing - id("org.jetbrains.changelog") version "1.1.2" - id("org.jetbrains.dokka") version "1.4.32" + id("org.jetbrains.changelog") version "1.2.0" + id("org.jetbrains.dokka") version "1.5.0" } group = "ru.mipt.npm" -version = "0.10.0" +version = "0.10.2" description = "Build tools for DataForge and kscience projects" changelog{ - version = project.version.toString() + setVersion(project.version.toString()) } repositories { @@ -22,7 +22,7 @@ repositories { maven("https://repo.kotlin.link") } -val kotlinVersion = "1.5.10" +val kotlinVersion = "1.5.21" java { targetCompatibility = JavaVersion.VERSION_11 @@ -30,11 +30,11 @@ java { dependencies { 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-jupyter-api-gradle-plugin:0.10.0-126-1") 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:atomicfu-gradle-plugin:0.16.2") + implementation("org.jetbrains.dokka:dokka-gradle-plugin:1.5.0") + implementation("org.jetbrains.intellij.plugins:gradle-changelog-plugin:1.2.0") implementation("org.jetbrains.kotlinx:binary-compatibility-validator:0.6.0") } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 0f80bbf..05679dc 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.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.1.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/src/main/kotlin/ru/mipt/npm/gradle/KScienceProjectPlugin.kt b/src/main/kotlin/ru/mipt/npm/gradle/KScienceProjectPlugin.kt index 16862e9..c163c3d 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/KScienceProjectPlugin.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/KScienceProjectPlugin.kt @@ -5,6 +5,7 @@ import kotlinx.validation.ApiValidationExtension import kotlinx.validation.BinaryCompatibilityValidatorPlugin import org.gradle.api.Plugin import org.gradle.api.Project +import org.gradle.api.Task import org.gradle.kotlin.dsl.* import org.jetbrains.changelog.ChangelogPlugin import org.jetbrains.changelog.ChangelogPluginExtension @@ -13,6 +14,8 @@ import org.jetbrains.dokka.gradle.DokkaPlugin import org.jetbrains.dokka.gradle.DokkaTask import ru.mipt.npm.gradle.internal.* +private fun Project.allTasks(): Set = allprojects.flatMapTo(HashSet()) { it.tasks } + @Suppress("unused") class KSciencePublishingExtension(val project: Project) { private var initializedFlag = false @@ -33,13 +36,17 @@ class KSciencePublishingExtension(val project: Project) { if (!initializedFlag) { vcs("https://github.com/$githubOrg/$githubProject") } + project.addGithubPublishing(githubOrg, githubProject) - if (publish) { - project.tasks.findByName("publish${project.publicationTarget}ToGithubRepository")?.let {publicationTask-> - releaseTask?.dependsOn(publicationTask) + if (publish) + project.afterEvaluate { + allTasks() + .find { it.name == "publish${publicationTarget}ToGithubRepository" } + ?.let { publicationTask -> + releaseTask?.dependsOn(publicationTask) + } } - } } private val releaseTask by lazy { @@ -52,11 +59,13 @@ class KSciencePublishingExtension(val project: Project) { 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) + + if (publish) + project.afterEvaluate { + allTasks() + .find { it.name == "publish${publicationTarget}ToSpaceRepository" } + ?.let { publicationTask -> releaseTask?.dependsOn(publicationTask) } } - } } // // Bintray publishing @@ -71,16 +80,16 @@ class KSciencePublishingExtension(val project: Project) { 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) - } - } + + if (publish) + project.afterEvaluate { + allTasks() + .find { it.name == "publish${publicationTarget}ToSonatypeRepository" } + ?.let { publicationTask -> releaseTask?.dependsOn(publicationTask) } + } } } - /** * Apply extension and repositories */ @@ -98,7 +107,7 @@ open class KScienceProjectPlugin : Plugin { } } else { configure { - version = project.version.toString() + version.set(project.version.toString()) } } } @@ -225,4 +234,4 @@ open class KScienceProjectPlugin : Plugin { companion object { const val RELEASE_GROUP = "release" } -} \ 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 06ada3c..b8acdb4 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.10" + const val kotlinVersion = "1.5.21" const val kotlinxNodeVersion = "0.0.7" - const val coroutinesVersion = "1.5.0" - const val serializationVersion = "1.2.1" - const val atomicVersion = "0.16.1" - const val ktorVersion = "1.6.0" + const val coroutinesVersion = "1.5.1" + const val serializationVersion = "1.2.2" + const val atomicVersion = "0.16.2" + const val ktorVersion = "1.6.1" const val htmlVersion = "0.7.3" const val dateTimeVersion = "0.2.1" - const val jsBom = "0.0.1-pre.213-kotlin-1.5.10" + const val jsBom = "0.0.1-pre.216-kotlin-1.5.20" val JVM_TARGET = JavaVersion.VERSION_11 object Serialization{ const val xmlVersion = "0.82.0" - const val yamlKtVersion = "0.9.0" + const val yamlKtVersion = "0.10.0" } } 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 9b8b60e..07b01e8 100644 --- a/src/main/kotlin/ru/mipt/npm/gradle/internal/common.kt +++ b/src/main/kotlin/ru/mipt/npm/gradle/internal/common.kt @@ -2,9 +2,13 @@ package ru.mipt.npm.gradle.internal import org.gradle.api.artifacts.ProjectDependency import org.gradle.api.artifacts.dsl.RepositoryHandler +import org.gradle.api.file.DuplicatesStrategy import org.gradle.api.tasks.Copy import org.gradle.kotlin.dsl.get +import org.gradle.kotlin.dsl.getByName import org.gradle.kotlin.dsl.maven +import org.gradle.language.jvm.tasks.ProcessResources +import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension import org.jetbrains.kotlin.gradle.plugin.LanguageSettingsBuilder internal fun LanguageSettingsBuilder.applySettings(): Unit { @@ -47,6 +51,32 @@ internal fun Copy.fromJsDependencies(configurationName: String) = project.run { } +fun KotlinMultiplatformExtension.bundleJsBinaryAsResource(bundleName: String = "js/bundle.js"){ + js { + binaries.executable() + browser { + webpackTask { + outputFileName = bundleName + } + } + } + + jvm { + val processResourcesTaskName = + compilations[org.jetbrains.kotlin.gradle.plugin.KotlinCompilation.MAIN_COMPILATION_NAME] + .processResourcesTaskName + + val jsBrowserDistribution = project.tasks.getByName("jsBrowserDistribution") + + project.tasks.getByName(processResourcesTaskName) { + duplicatesStrategy = DuplicatesStrategy.WARN + dependsOn(jsBrowserDistribution) + from(jsBrowserDistribution) + } + } + +} + // //internal fun Copy.copyJVMResources(configuration: Configuration): Unit = project.afterEvaluate { // val projectDeps = configuration.allDependencies