Reputation: 763
I have been searching for few hours how to build .jar with maven. Finnaly i got it.
But now i have to have sources in src/main/java.
How to 'include' src/main/groovy to my project? I read solution here but I really don't want to change my pom.xml. I had so many troubles with this.
Here is my pom.xml
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>net.thornydev</groupId>
<artifactId>script</artifactId>
<packaging>jar</packaging>
<version>1.0</version>
<name>script</name>
<url>http://maven.apache.org</url>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<compilerId>groovy-eclipse-compiler</compilerId>
</configuration>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-eclipse-compiler</artifactId>
<version>2.7.0-01</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>pl.jedro.Main</mainClass>
</transformer>
</transformers>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>2.4.0-beta-3</version>
</dependency>
</dependencies>
I tried with:
<sources>
<source>${basedir}/src/main/groovy</source>
</sources>
and
<build>
<resources>
<resource>
<directory>src/main/groovy</directory>
</resource>
</resources>
but still nothing.
I got :
Error: Could not find or load main class pl.jedro.Main
Upvotes: 3
Views: 3457
Reputation: 763
Finally got solution.
I added:
<sourceDirectory>src/main</sourceDirectory>
<resources>
<resource>
<directory>groovy</directory>
</resource>
</resources>
in <build> </build>
section.
Upvotes: 3