https://kotlinlang.org logo
j

jdemeulenaere

08/06/2019, 9:50 AM
Is it possible to configure script dependencies using package (with wildcard) instead of jar name ? (I don't have the jar name because of the build system I am using [bazel])
i

ilya.chernikov

08/06/2019, 10:27 AM
You can write your custom dependencies resolving code that uses any any info you have. Have a look, for example, on
kotlin-man-kts
implementation - https://github.com/JetBrains/kotlin/tree/master/libraries/tools/kotlin-main-kts You probably don’t want to parse import statements yourself (and we do not provide any interfaces to our parser), but you can e.g. use some annotations, similar to
DependsOn
one from
main-kts
, put a package into it, and in your resolving code generate both dependencies and implicit imports out of it.
j

jdemeulenaere

08/06/2019, 10:38 AM
Thanks! I will have a look 🙂
I think I might have badly expressed myself: I want to specify those dependencies in the compilation configuration, not inside a script 🙂 (i.e. the classes that I allow the scripts to use). So instead of specifying a jar (https://bit.ly/2GPTsQC), I would like to specify a package
I only know a substring of the dependency jar name, so if I could use regex or a * placeholder it might be a solution as well (but specifying package would be better IMO)
i

ilya.chernikov

08/06/2019, 11:34 AM
I do not understand what are you trying to achieve. Kotlin compiler now need a classpath with jars or classes for script compilation, it is similar in a sense to using kotlinc (or javac for that matter) from the command line. So you need to extract jar paths. If you have a classloader with required classes loaded, then there are ways to get jar paths via resources.
g

Gary Tierney

08/06/2019, 12:14 PM
What you're asking for wouldn't make sense. How would
kotlinc
figure out which artifact contains a package?