efemoney
03/30/2019, 3:40 AM*
).
The issue I’m facing is that in AS, with gradle, I have a service-def (script definitoin) module and a services (actual script files in src folder) module.
The services module gets its dependencies via gradle project dependencies (currently project(":service-def")
, project(":service-api")
and project(":service-dsl")
plus kotlin-stdlib and scripting-jvm dependencies). I also have a service-host module which I use to run the scripting host to debug issues and test out the scripts.
I really want to be able to specify only required jars while building the compilation configuration (only the api and dsl jars/classes should be visible within the scripts) but I cannot do this because, when resolved from intelliJ/AS, the classpath contains the actual jars like service-api-dev.jar
, but when I run the host module java app, the classpath contains folders with .class
files like .../api/build/classes/main/
. I think its a Gradle performance feature to avoid building the actual jars in the case of project dependencies. Would be great if I could specify *api*
and *dsl*
to filter the classpath as that would cover all the cases.
Current workaround is to use dependenciesFromCurrentContext(wholeClasspath = true)
which works but I dunno if I like. Also, the requirement for the jar version is too strict. As you can see from above my current version is dev because project is still in development. The current classpath filtering tries to strictly match semver like x.y.z and filters out my correct jars.
Final question: does scripting add the kotlin stdlib dep automatically? aka if I wanted a really small classpath, can I specify only api and dsl jars w/o explicitly specifying the stdlib and it will work? (My guess is no and we would have to add a kotlin compile config to compile with the stdlib or else specify it)
Final question 2: what classpath does the kotlin IJ/AS plugin use to determine dependencies for scripts? Like, if I open a custom script how is IJ/AS able to know the correct types. I know I have to have a jar in the classpath that contains script definition (in my case, I have to make sure to assemble/build the service-def module) but what classpath is IJ/AS checking exactlyilya.chernikov
04/01/2019, 9:50 AMdependenciesFromXXX
functions are just helpers that simplify classpath extraction from the current environment. It probably makes sense to implement more flexible selectors in them, this is an interesting feature to consider.
But in fact if you have a need for a fine-grained control of the classpath, it is better to specify jars explicitly via e.g.:
dependencies(JvmDependency(<files>))
ilya.chernikov
04/01/2019, 9:52 AMdoes scripting add the kotlin stdlib dep automaticallyyes, unless you’ll specify
-no-stdlib
compiler option, as per CLI compiler.ilya.chernikov
04/01/2019, 9:54 AMwhat classpath does the kotlin IJ/AS pluginBy default - the module classpath, the script is located - if it is located in a source root. The results of refining are taken into account on top of that.
efemoney
04/01/2019, 10:11 AM