https://kotlinlang.org logo
s

SrSouza

01/22/2019, 6:49 PM
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

SrSouza

01/22/2019, 9:10 PM
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

Nikky

01/22/2019, 10:01 PM
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

SrSouza

01/22/2019, 10:36 PM
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

bart

01/23/2019, 9:38 AM
@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

Nikky

01/23/2019, 9:48 AM
oh that is cool, on which module is that applied , the script provider or the consumer ? i have not seen that plugin before..
b

bart

01/23/2019, 9:51 AM
*see the example I posted above
n

Nikky

01/23/2019, 10:09 AM
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

bart

01/23/2019, 10:17 AM
It automatically creates META-INF entries? Didn't know that
n

Nikky

01/23/2019, 10:23 AM
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

ilya.chernikov

01/23/2019, 2:30 PM
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

SrSouza

01/23/2019, 4:14 PM
Hi @bart, I clone your project but the IntelliJ is no recognizing your script
b

bart

01/23/2019, 4:16 PM
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

SrSouza

01/23/2019, 4:29 PM
I build with
/gradle build
and still nothing
@bart
b

bart

01/23/2019, 4:40 PM
That's odd, what happens when you run it? Does it work?
s

SrSouza

01/23/2019, 4:49 PM
When I try to run
Execute.kt
with IntelliJ doesn't work because the error from the
HelloWorld.kts
3 Views