Groovy app packaging

I want to package the Groovy CLI application in a form that is easy to distribute, similar to what Java does with the JAR. I could not find anything that could do this. I found a couple of things like this that are for one-time scripts, but nothing that could compile a whole Groovy application, a lot of different Groovy files and resource data.

I don’t need the Groovy standalone executable to be part of it (although that would be nice), and it is not a library intended for use by other JVM languages. All I want is just a packaged version of my application.

EDIT : Based on a few answers that I received, I do not think that I was sufficiently clear in my purpose. I am mainly looking for an archive format that Groovy can support. The goal here is to make it easier to distribute. Right now, the best way is to create a ZIP file, you can unzip it, and then modify the package / shell file to run it. I was hoping to find a way to make it more like an executable JAR file, where the user just needs to run one file.

I know that Groovy will compile with JVM-compatible bytecode, but I'm not trying to get it to work like Java code. I am dynamically adding Groovy classes at runtime based on user configuration and Java will not be able to handle this. As I said in the original post, the presence of the Groovy executable included in the archive is pretty nice. However, I really need Groovy for the executable, not Java.

+4
source share
2 answers

The Gradle cookbook shows how to make a "fat jar" from a groovy project: http://wiki.gradle.org/display/GRADLE/Cookbook#Cookbook-Creatingafatjar

This links all dependencies, including groovy. The resulting jar file can be run on the command line, for example:

java -jar myapp.jar 
+3
source

I had great success using a combination of the eclipse Fat Jar plugin and Another Java Wrapper service .

Essentially, this becomes a Java problem, not a groovy problem. A greasy can is painless to use. This may lead to several attempts to get your only drum on the right, but as soon as all the dependencies are flattened into one jar, you no longer execute it on the command line with

 java -jar application.jar 

Then I wrap these jars as a service. I often develop stand-alone groovy-based services that perform a specific task. I installed it as a service on a Windows server using another Java service, and I plan on using various methods to interact with Windows services.

+1
source

Source: https://habr.com/ru/post/1498616/


All Articles