I'm trying to generate a JAR file from Groovy code with Maven. It works well, the classes are in the jar file, but it gives me the error Error: Could not find or load main class me.strafe.hello.Main
.
pom.xml
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>compile</id>
<phase>compile</phase>
<configuration>
<tasks>
<mkdir dir="${basedir}/src/main/groovy"/>
<taskdef name="groovyc"
classname="org.codehaus.groovy.ant.Groovyc">
<classpath refid="maven.compile.classpath"/>
</taskdef>
<mkdir dir="${project.build.outputDirectory}"/>
<groovyc destdir="${project.build.outputDirectory}"
srcdir="${basedir}/src/main/groovy/"
listfiles="true">
<classpath refid="maven.compile.classpath"/>
</groovyc>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>me.strafe.hello.Main</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
I took this from Groovy docs.
Tree:
├── pom.xml
├── src
│ └── main
│ └── groovy
│ └── Main.groovy
Main.groovy:
package me.strafe.hello
class Main {
static void main(String[] args) {
println "Hello, World!"
}
}
I've tried with gradle too, but i wasn't so familiar with it since i've used maven before.