创建自己的groovy库 [英] Creating own groovy library
问题描述
我有几种方法,我只是不想复制和粘贴到我的所有内容中groovy脚本。
完美的解决方案是通过
import myownmethods
如何创建myownmethods.jar库?
感谢您的任何回答和解决方案
干杯
最简单的方法是用 groovyc
编译你的groovy文件,然后用 jar
打包成一个jar文件>。例如:
groovyc -d类myclasses.groovy
jar cvf myclasses.jar -C类。
我也会考虑看gradle。要开始,您可以使用 build.gradle
包含:
apply plugin:'groovy'
然后将您的源文件放在名为 src / main / groovy
并运行 gradle jar
。它会将源文件构建到 build / libs
中的jar文件中。
Do anyone have an idea whats the best way of creating an own library for groovy.
I have several methods which i just dont want copy and paste into all my groovy scripts.
The perfect solution would be to do it by an
import myownmethods
How to create the library myownmethods.jar?
Thanks for any answer and solution
Cheers
The simplest method is to compile your groovy files with groovyc
and then package them into a jar file with jar
. For example:
groovyc -d classes myclasses.groovy
jar cvf myclasses.jar -C classes .
I'd also consider looking at gradle. To get started, you can use a build.gradle
containing just:
apply plugin: 'groovy'
Then put your source files in a subdirectory called src/main/groovy
and run gradle jar
. It will build your source files into a jar file in build/libs
.
这篇关于创建自己的groovy库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!