From a22bd9f889480f64c99bf645e683c3f0ab5cd3a8 Mon Sep 17 00:00:00 2001 From: Shagen Ogandzhanian Date: Tue, 17 Aug 2021 23:39:47 +0200 Subject: [PATCH] Reintroduce printBundleSize for samples --- web/build.gradle.kts | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/web/build.gradle.kts b/web/build.gradle.kts index 606211d12d..4f4cf4d854 100644 --- a/web/build.gradle.kts +++ b/web/build.gradle.kts @@ -6,7 +6,15 @@ val COMPOSE_WEB_BUILD_WITH_SAMPLES = project.property("compose.web.buildSamples" apply() -subprojects { +fun Project.isSampleProject() = projectDir.parentFile.name == "examples" + +tasks.register("printBundleSize") { + dependsOn( + subprojects.filter { it.isSampleProject() }.map { ":examples:${it.name}:printBundleSize" } + ) +} + +subprojects { apply(plugin = "maven-publish") group = "org.jetbrains.compose.web" @@ -27,6 +35,21 @@ subprojects { } } + if (isSampleProject()) { + val printBundleSize by tasks.registering { + dependsOn(tasks.named("jsBrowserDistribution")) + doLast { + val jsFile = buildDir.resolve("distributions/${project.name}.js") + val size = jsFile.length() + println("##teamcity[buildStatisticValue key='bundleSize::${project.name}' value='$size']") + } + } + + afterEvaluate { + tasks.named("build") { finalizedBy(printBundleSize) } + } + } + if (COMPOSE_WEB_BUILD_WITH_SAMPLES) { println("substituting published artifacts with projects ones in project $name") configurations.all {