https://kotlinlang.org logo
#javascript
Title
# javascript
n

Nacho Ruiz Martin

10/02/2023, 1:35 PM
Hey! 👋 Is there any way to serve a different resource depending on a Gradle property? Basically, I’m creating App links and I need a different
.well-known/assetlinks.json
on
staging
than on
prod
. Thanks!
I’ve seen people using different gradle modules for each environment, but static files will only be served from the
app
module, right?
e

Edoardo Luppi

10/02/2023, 1:37 PM
Just guessing here, you could implement a custom copy task and reference the file under the copy directory.
1
n

Nacho Ruiz Martin

10/02/2023, 1:41 PM
You mean a gradle copy task, right? And having a
staging/assetlinks.json
and a
prod/assetlinks.json
and copy to the root folder depending on the gradle property.
e

Edoardo Luppi

10/02/2023, 1:42 PM
Yes exactly. You can make the task depend on the dev or prod K/JS task.
(theoretically, you may need to find out the correct insertion point for your task)
n

Nacho Ruiz Martin

10/02/2023, 1:43 PM
Ok, I’ll give it a try, thanks for the idea!
You can make the task depend on the dev or prod K/JS task.
Would that be
:Task compileKotlinJs
?
e

Edoardo Luppi

10/02/2023, 3:49 PM
@Nacho Ruiz Martin you may be better off with
jsProcessResources
Make your copy task run before it.
n

Nacho Ruiz Martin

10/02/2023, 4:08 PM
Ok, thanks!
Works just as expected, many thanks!