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
.
You should follow the same process that you would for a Java library, i.e.
lib
directory (if not) †† I know this sucks, but I can't remember how I used to manage dependencies without using a dependency management tool
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With