After upgrading to Kotlin 1.7.20 I started to get ...
# scripting
s
After upgrading to Kotlin 1.7.20 I started to get
w: Script 'osadl.rules.kts' is not supposed to be used along with regular Kotlin sources, and will be ignored in the future versions by default. (Use -Xallow-any-scripts-in-source-roots command line option to opt-in for the old behavior.)
for a script that's committed as a resource in a Kotlin project (see https://github.com/oss-review-toolkit/ort/blob/osadl-rules/evaluator/src/main/resources/rules/osadl.rules.kts). What's this supposed to tell me? I mean, the script is not in a source root of Kotlin source set after all...
b
Resources are still sources since they are added to the classpath. But in your case I think the warning can be safely ignored.
s
So, since we treat warnings as errors my only chance is to opt-in to
-Xallow-any-scripts-in-source-roots
, right? Or can I place the script elsewhere to avoid this?
b
Are you using it in your program? If not, then just move it out of resources, kotlin and java directories
s
Yes, I'm using it in the same program / module.
b
Then yeah, that compiler flag seems to be the only option. Which is still safe since you don't depend on the script being compiled and available for your kotlin code to call
👍🏻 1
Although ideally kgp should hide files in resources from the compiler somehow
At the moment it cannot differentiate between kotlin sources and resources directories.
s
Thanks!
However, with
-Xallow-any-scripts-in-source-roots
I'm now running (again) into https://youtrack.jetbrains.com/issue/KTIJ-22806. Do you also have a recommendation about a work-around for that? That issue also seems to be somehow classpath-related.
b
This is hacky, but you could move script out of resources and then add it into classpath on JvmRun and Jar tasks
This would effectively hide it from compilations
s
And I wouldn't get auto-completion for the script when editing it in the IDE, right?
b
You would. Scripts are standalone entities. You cn have a kts in a npm project and still have autocompletion
i.e. Autocompletion has nothing to do with gradle
108 Views