gianluz
03/01/2021, 9:39 PM.main.kts
script with a compiled jar runtime locally inside IntelliJ and in CI.
More in specific:
• i have a project where i compile a module with this jar that is going into: build/libs/myJar.jar
• then i have a MyScript.main.kts
where i use the library:
@file:DependsOn("./build/libs/test-jar-main-kts-0.1.jar")
import com.test.jar.TestJar
print(TestJar.iAmTestJar())
If i run the script from IntelliJ works but the script gives an error : File build/libs/myJar.jar
not found and i cannot benefit the autocomplete.
By using the /absolute/path/to/myJar.jar
it works well in IntelliJ with autocomplete and locally in general, but the path will be different whiles running on CI or another machine.
Is there a way to have this working well both locally and on CI/other machine just using relative paths?
Alternatively, how i can contribute to fix that? attached a screenshotilya.chernikov
03/03/2021, 7:55 PM@file:Repository
annotation for simplicity
- Use maven(ivy) resolver, and put your jar to the maven/ivy local cache (e.g. for the .main.kts` scripts, which uses ivy, the ~/.ivy2/cache
directory is usually used as a cache.)
- Implement your own customized script definition, e.g. taking https://github.com/Kotlin/kotlin-script-examples/tree/master/jvm/simple-main-kts as a base, and add there a logic for the base directory settings.