[英]how to run Groovy script in Netbeans?
I'm trying out NetBeans for editing Groovy code.我正在尝试使用 NetBeans 来编辑 Groovy 代码。 (I'm new to Groovy, and it's been a long time since I did any Java development).
(我是Groovy新手,好久没做Java开发了)。
At some point I installed the Groovy plugin via the "plugins" tool.在某些时候,我通过“插件”工具安装了 Groovy 插件。 But it does not have the green checkmark under "active", and choosing the Groovy plugin does not make the Activate/Deactivate/Uninstall buttons available.
但它在“活动”下没有绿色复选标记,并且选择 Groovy 插件不会使激活/停用/卸载按钮可用。 Oh well...
那好吧...
So let's create a project...那么让我们创建一个项目...
Let's create a file...让我们创建一个文件...
But wait a minute...the output is "Hello World,".但是等一下……output 是“Hello World”。 and it should be "Hello chris."
应该是“你好克里斯”。 It looks like "HelloWorld" is coming out of "Mavenproject1.java".
看起来“HelloWorld”来自“Mavenproject1.java”。
How can I (or can I) just run my script from within NetBeans?我如何(或我可以)只从 NetBeans 中运行我的脚本?
UPDATE : per @andrewJames suggestion, I tried working that tutorial.更新:根据@andrewJames 的建议,我尝试使用该教程。 (It looks like the tutorial may be a bit out of date.)
(看起来教程可能有点过时了。)
I get that same error whether I'm running on a machine with a groovyc
executable or not, so I suspect that there's something about the configuration that I need to change in order to point to the groovyc
executable.无论我是否在带有
groovyc
可执行文件的机器上运行,我都会遇到同样的错误,所以我怀疑我需要更改配置以指向groovyc
可执行文件。
Probably something to do with the build.xml
file...but I can't seem to figure out how to edit that to change the search path for the groovyc
step.可能与
build.xml
文件有关......但我似乎无法弄清楚如何编辑它以更改groovyc
步骤的搜索路径。
I had the same problem that NB doesn't run a Groovy script out of the IDE like Eclipse does.我遇到了同样的问题,NB 没有像 Eclipse 那样从 IDE 运行 Groovy 脚本。 I logged an issue and spent more than a year on the.netbeans-dev mailing list advocating for it.
我记录了一个问题,并在 .netbeans-dev 邮件列表上花费了一年多的时间来提倡它。 Often replied to with "we'll be happy to review your pull request" type of stuff.
经常回复“我们很乐意审查您的拉取请求”之类的东西。 Eventually, when I rage quit the mailing list with a scathing message, Geertjan replied to the issue with a solution .
最终,当我用严厉的消息愤怒地退出邮件列表时,Geertjan 用解决方案回复了这个问题。
So, in short, use the old plugin to create a Groovy project and change line 26 in groovy-build.xml
to因此,简而言之,使用旧插件创建一个 Groovy 项目并将
groovy-build.xml
中的第 26 行更改为
<groovyc srcdir="@{srcdir}" sourcepath="@{sourcepath}" destdir="@{destdir}" encoding="${source.encoding}" excludes="@{excludes}" includeAntRuntime="true" fork="false">
You can then run your script with Shift+F6.然后您可以使用 Shift+F6 运行您的脚本。
The project needs the Groovy jars added.该项目需要添加Groovy jars。 It works for me on NB 11, 12 & 13 with Groovy 2.x and Java 8, 11 & 14 so far.
到目前为止,它适用于 Groovy 2.x 和 Java 8、11 和 14 的 NB 11、12 和 13。 I haven't tried it with Groovy 3.x as the groovy-all.jar is deprecated so you'll have to maven or manually manage the Groovy jars.
我还没有尝试使用 Groovy 3.x,因为 groovy-all.jar 已弃用,因此您必须使用 maven 或手动管理 Groovy jars。
Also, I collaborated a bit with someone on a new plugin .此外,我还与某人合作开发了一个新插件。 It works as is but new development has stalled.
它按原样工作,但新的开发已经停滞。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.