https://kotlinlang.org logo
Title
n

Nik

07/19/2021, 1:17 PM
Does anyone know of a method for adding files to the
Resources
folder for the macOS .DMG from our
build.gradle.kts
? I have an application which performs file I/O (ultimately to run
.sh
scripts for a variety of tasks) and I’m having trouble locating those files once the application is installed, as
File(".")
gives me the macOS root directory
/
, not the same file structure as when running the application in IntelliJ
Though it is odd to me that accessing
.svg
files from my Composables would succeed with a path like
"raw/image.svg"
where the original file is at
"src/main/resources/raw/image.svg"
, meaning there must be some difference in how the
svgResource(…)
method is accessing project files and how
File(…)
is doing it
If anyone would like to do this, this is my current workaround (sorry, :not-kotlin: ); this adds the
src/main/resources
file to
/Applications/{your app}.app/Contents/Resources/resources
j

jim

07/19/2021, 4:59 PM
Compose is not doing anything special to resolve resources, it is just using the standard JVM classloader resolution rules. The path is "raw/image.svg" because gradle adds"src/main/resources/" to the classpath and "raw/image.svg" is the resource path relative to the classpath. See https://docs.oracle.com/javase/7/docs/api/java/lang/ClassLoader.html#getResource(java.lang.String) for details.
:thank-you: 1
s

saket

07/20/2021, 3:11 PM
n

Nik

07/20/2021, 3:12 PM
Ah possibly — the script above accomplishes what you’d like to see added to the library in that issue!