0
votes

I have a maven project which consist of 1 groovy script (src/main/groovy/Main.groovy)

I am able to run it from IntelliJ by simply clicking run. What I want to do is to create an executable jar containing all dependencies so I could run in with

java -jar myjar.jar

Here's my pom:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>groupId</groupId>
<artifactId>artifactId</artifactId>
<version>1.0-SNAPSHOT</version>

<dependencies>
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>6.0.6</version>
    </dependency>
</dependencies>
</project>

I've searched on google and on so but couldn't find any working solution.

1

1 Answers

0
votes

Using Maven you can set up build plugins, and one of these can be a Groovy compiler.

I wrote a blog article on setting up a Groovy compiler in Maven. But there's two parts: the groovy compiler and a plugin to package the .class files into the .jar. Traditionally for the former you'd use the groovy-eclipse-compiler and the maven-shade-plugin for the latter.

It's like 100 lines of XML in your pom file.