Hi guys, i'm trying to make my script be recognize...
# scripting
s
Hi guys, i'm trying to make my script be recognized by the intellij, I create the file on templates but still not working, someone can help me ?
did you make sure to publish to mavenlocal and depend on that ? it does not quite work just between idea modules
s
Hi, yes, I have
I don't add the script to maven local because I'm not using than to add the script to the host module (where it is the script teste)
n
in short idea only recognizes scripts if they are added through some jar.. so i found mavenLocal to be the easiest way since i already publish my stuff to maven
or you can write a idea plugin.. apparently thats what we are expected to do.. i do not like it though
s
I don't like this way either. It would be cool if the Kotlin Gradle plugin as something to force a specfic sourceSet recognize the template. Other thing that whould be cool is if the scratches has support for maven dependency for script definitions.
About the jar thing, I will try it
Hi, a made the changes but still not working, I put the file with the FQN of Script definition in two places, like your project and how the KEEP is telling to put
b
@Nikky it does work for me between modules but I think you need the plugin for it to work https://plugins.gradle.org/plugin/org.jetbrains.kotlin.plugin.scripting
n
oh that is cool, on which module is that applied , the script provider or the consumer ? i have not seen that plugin before..
b
*see the example I posted above
n
i tried it out.. and it also seems to create the META-INF entries nice
sadly i cannot use it between modules because my samples also need to load a custom gradle plugin.. which is another module.. and has to be pushed to mavenLocal unless i want to have duplicate code around i guess
nice to know that it works though
b
It automatically creates META-INF entries? Didn't know that
n
it seems to.. i removed those files and called jar.. opened it and they were there as expected
i assume it works similar to google's AutoService annotation processor
nvm i guess there were files still in the classes.. i just cleaned and ran it again.. there the META-INF entries go
i
The plugin
org.jetbrains.kotlin.plugin.scripting
is applied automatically by kotlin gradle plugin, and it only responsible for script definitions discovery logic, nothing fancy. You normally do not need to apply or otherwise use it manually.
✔️ 1
s
Hi @bart, I clone your project but the IntelliJ is no recognizing your script
b
Did you build the host module?
I don't see any build folder in your project @SrSouza. To make the host visible to the scripts you need to have it in your classpath.
s
I build with
/gradle build
and still nothing
@bart
b
That's odd, what happens when you run it? Does it work?
s
When I try to run
Execute.kt
with IntelliJ doesn't work because the error from the
HelloWorld.kts