I have zip downloaded groovy (groovy-3.0.0-rc-3 URL) and unziped into a directory. I can run groovy scripts by saying the following after adding $GROOVY_HOME/bin to my path.
groovy ex1.groovy
where ex1.groovy
has the following one line:
["Rod", "Carlos", "Chris"].findAll{it.size() < 4}.each{println it}
So I know it is working, but when I try to run the same script in IntelliJ Ultimate, I get an error saying
Information:Groovyc: While compiling groovy1:org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
C:\p\groovy-3.0.0-rc-3\conf\groovy-starter.conf: 1: Unexpected input: '#' @ line 1, column 1.
## Licensed to the Apache Software Foundation (ASF) under one or more
So the file I specified for File > Settings > Build, Execution, Deployment, Compiler > Groovy Compiler dialog, the field name was Path to configscript
was not correct. I used the file $GROOVY_HOME/conf/groovy-starter.conf
.
But when I remove it I get another error which basically indicates the IntelliJ doesn't (yet) know where to look for the install files.
Information:Groovyc: While compiling groovy1:java.lang.NoClassDefFoundError: Unable to load class org.apache.groovy.jaxb.extensions.JaxbExtensions due to missing dependency javax/xml/bind/JAXBContext
I searched for a solution and found IntelliJ's documentation was basically useless (restating the obvious).
My thought is that by passing the correctly formatted file to the groovy compiler, the other files needed to run a Groovy script will be found.
Thanks, in advance, for any help.
In order to get IntelliJ to run groovy
files, I needed to properly configure groovy inside IntelliJ.
Through some experimentation found that a file is included in the groovy zipfile distribution that can be used. The file is groovy/config/groovy-starter.conf
So if the groovy zip file was unzipped to the directory $HOME/.apps/groovy
then the config is located at $HOME/.apps/groovy/config/groovy-starter.conf
After using this file as the config file, I was able to run *.groovy files inside IntelliJ Ultimate and they ran correctly.
Also see the Intellij documentation at https://www.jetbrains.com/help/idea/getting-started-with-groovy.html
Below is the full java command that was used when I selected File | Run
C:\p\jdk1.8.0_271\bin\java.exe -Dtools.jar=C:\p\jdk1.8.0_271\lib\tools.jar -Dgroovy.home=C:\p\groovy-3.0.6 -Dgroovy.starter.conf=C:\p\groovy-3.0.6\conf\groovy-starter.conf "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA 2020.1\lib\idea_rt.jar=57171:C:\Program Files\JetBrains\IntelliJ IDEA 2020.1\bin" -Dfile.encoding=UTF-8 -classpath C:\p\groovy-3.0.6\lib\groovy-3.0.6.jar org.codehaus.groovy.tools.GroovyStarter --conf C:\p\groovy-3.0.6\conf\groovy-starter.conf --main groovy.ui.GroovyMain --classpath .;C:\Play\groovy-try2\out\production\groovy-try2;C:\p\groovy-3.0.6\lib\ant-1.10.8.jar;C:\p\groovy-3.0.6\lib\ant-antlr-1.10.8.jar;C:\p\groovy-3.0.6\lib\ant-junit-1.10.8.jar;C:\p\groovy-3.0.6\lib\ant-launcher-1.10.8.jar;C:\p\groovy-3.0.6\lib\bsf-2.4.0.jar;C:\p\groovy-3.0.6\lib\commons-cli-1.4.jar;C:\p\groovy-3.0.6\lib\commons-logging-1.2.jar;C:\p\groovy-3.0.6\lib\gpars-1.2.1.jar;C:\p\groovy-3.0.6\lib\groovy-3.0.6.jar;C:\p\groovy-3.0.6\lib\groovy-ant-3.0.6.jar;C:\p\groovy-3.0.6\lib\groovy-astbuilder-3.0.6.jar;C:\p\groovy-3.0.6\lib\groovy-bsf-3.0.6.jar;C:\p\groovy-3.0.6\lib\groovy-cli-commons-3.0.6.jar;C:\p\groovy-3.0.6\lib\groovy-cli-picocli-3.0.6.jar;C:\p\groovy-3.0.6\lib\groovy-console-3.0.6.jar;C:\p\groovy-3.0.6\lib\groovy-datetime-3.0.6.jar;C:\p\groovy-3.0.6\lib\groovy-dateutil-3.0.6.jar;C:\p\groovy-3.0.6\lib\groovy-docgenerator-3.0.6.jar;C:\p\groovy-3.0.6\lib\groovy-groovydoc-3.0.6.jar;C:\p\groovy-3.0.6\lib\groovy-groovysh-3.0.6.jar;C:\p\groovy-3.0.6\lib\groovy-jaxb-3.0.6.jar;C:\p\groovy-3.0.6\lib\groovy-jmx-3.0.6.jar;C:\p\groovy-3.0.6\lib\groovy-json-3.0.6.jar;C:\p\groovy-3.0.6\lib\groovy-jsr223-3.0.6.jar;C:\p\groovy-3.0.6\lib\groovy-macro-3.0.6.jar;C:\p\groovy-3.0.6\lib\groovy-nio-3.0.6.jar;C:\p\groovy-3.0.6\lib\groovy-servlet-3.0.6.jar;C:\p\groovy-3.0.6\lib\groovy-sql-3.0.6.jar;C:\p\groovy-3.0.6\lib\groovy-swing-3.0.6.jar;C:\p\groovy-3.0.6\lib\groovy-templates-3.0.6.jar;C:\p\groovy-3.0.6\lib\groovy-test-3.0.6.jar;C:\p\groovy-3.0.6\lib\groovy-test-junit5-3.0.6.jar;C:\p\groovy-3.0.6\lib\groovy-testng-3.0.6.jar;C:\p\groovy-3.0.6\lib\groovy-xml-3.0.6.jar;C:\p\groovy-3.0.6\lib\groovy-yaml-3.0.6.jar;C:\p\groovy-3.0.6\lib\hamcrest-core-1.3.jar;C:\p\groovy-3.0.6\lib\ivy-2.5.0.jar;C:\p\groovy-3.0.6\lib\jackson-annotations-2.11.2.jar;C:\p\groovy-3.0.6\lib\jackson-core-2.11.2.jar;C:\p\groovy-3.0.6\lib\jackson-databind-2.11.2.jar;C:\p\groovy-3.0.6\lib\jackson-dataformat-yaml-2.11.2.jar;C:\p\groovy-3.0.6\lib\jansi-1.18.jar;C:\p\groovy-3.0.6\lib\javaparser-core-3.16.1.jar;C:\p\groovy-3.0.6\lib\javax.servlet-api-3.0.1.jar;C:\p\groovy-3.0.6\lib\jcommander-1.78.jar;C:\p\groovy-3.0.6\lib\jline-2.14.6.jar;C:\p\groovy-3.0.6\lib\jsp-api-2.0.jar;C:\p\groovy-3.0.6\lib\jsr166y-1.7.0.jar;C:\p\groovy-3.0.6\lib\junit-4.13.jar;C:\p\groovy-3.0.6\lib\junit-jupiter-api-5.7.0.jar;C:\p\groovy-3.0.6\lib\junit-jupiter-engine-5.7.0.jar;C:\p\groovy-3.0.6\lib\junit-platform-commons-1.7.0.jar;C:\p\groovy-3.0.6\lib\junit-platform-engine-1.7.0.jar;C:\p\groovy-3.0.6\lib\junit-platform-launcher-1.7.0.jar;C:\p\groovy-3.0.6\lib\multiverse-core-0.7.0.jar;C:\p\groovy-3.0.6\lib\opentest4j-1.2.0.jar;C:\p\groovy-3.0.6\lib\org.abego.treelayout.core-1.0.1.jar;C:\p\groovy-3.0.6\lib\qdox-1.12.1.jar;C:\p\groovy-3.0.6\lib\snakeyaml-1.26.jar;C:\p\groovy-3.0.6\lib\ST4-4.1.jar;C:\p\groovy-3.0.6\lib\testng-7.3.0.jar;C:\p\groovy-3.0.6\lib\xstream-1.4.13.jar --encoding=UTF-8 C:\Play\groovy-try2\src\hello2.groovy