Loboda Deni
11/07/2022, 10:32 AMOleksandr Karpovich [JB]
12/21/2022, 3:21 PMDavid Herman
12/22/2022, 12:45 AMDavid Herman
12/22/2022, 12:47 AMtasks.named("jsJar", Jar::class.java).configure {
val classpathProvider = configurations.named("jsRuntimeClasspath")
inputs.files(classpathProvider)
doFirst {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
from(classpathProvider.get().map { if (it.isDirectory) it else project.zipTree(it).matching(patterns) })
}
}
CLOVIS
12/22/2022, 9:40 AMCopy
task. Assuming project :b
uses resources from project :a
:
// b/build.gradle.kts
val jsWorkspace = "${rootProject.buildDir}/js"
val jsProjectDir = "$jsWorkspace/packages/${rootProject.name}-${project.name}"
val kotlinNpmInstall by rootProject.tasks.getting(org.jetbrains.kotlin.gradle.targets.js.npm.tasks.KotlinNpmInstallTask::class)
val copyAResources by tasks.registering(Copy::class) {
description = "Copies the resources from :a"
from("$[project(":a").projectDir}/src/main/resources")
into(jsProjectDir)
dependsOn(kotlinNpmInstall)
}
val developmentExecutableCompileSync: Task by tasks.getting {
dependsOn(copyAResources)
}
// also add the dependency for your production task
Full example: https://gitlab.com/opensavvy/decouple/-/blob/main/demo/web/build.gradle.kts#L35
To access resources declared in an external module, you can use a similar trick:
// b/build.gradle.kts
val expandedArchives = "${rootProject.buildDir}/tmp/expandedArchives"
val jsProjectDir = "${rootProject.buildDir}/js/packages/${rootProject.name}"
val kotlinNpmInstall by rootProject.tasks.getting()
val configureAResources by tasks.registering(Copy::class) {
description = "Copies the ressources of :a"
from(expandedArchives) {
include("/a-js-*/")
exclude("/a-js-*/package.json", "/a-js-*/default", "/a-js-*/META-INF")
}
into(jsProjectDir)
eachFile {
path = path.substringAfter("/")
}
includeEmptyDirs = false
dependsOn(kotlinNpmInstall)
}
Full example: https://opensavvy.gitlab.io/decouple/documentation/style/material/index.htmlCLOVIS
12/22/2022, 9:42 AMCLOVIS
12/22/2022, 9:42 AM