From 100f7cd55ff04b540caa7260078bb68fa76b8afe Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Wed, 21 Jul 2021 13:01:29 +0300 Subject: [PATCH] 0.10.2 --- CHANGELOG.md | 15 ++++++++++ README.md | 3 -- build.gradle.kts | 2 +- .../ru/mipt/npm/gradle/internal/common.kt | 30 +++++++++++++++++++ 4 files changed, 46 insertions(+), 4 deletions(-) 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 bb08d99..8aa1a85 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,7 +8,7 @@ plugins { } group = "ru.mipt.npm" -version = "0.10.1" +version = "0.10.2" description = "Build tools for DataForge and kscience projects" 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