JAR built by Tycho contains Groovy source files

283 Views Asked by At

I am converting projects to OSGi compatible components and using Maven/Tycho to do this. I am using below plugin to compile the Groovy source files, but afterwards the compiled JAR contains source file along with class files. I don't want source files to be shipped with the JAR. Do I have to do any configuration for this?

<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>
                    <exclusions>
                        <exclusion>
                            <groupId>org.codehaus.groovy</groupId>
                            <artifactId>groovy-eclipse-batch</artifactId>
                        </exclusion>
                    </exclusions>
                </dependency>
                <dependency>
                    <groupId>org.codehaus.groovy</groupId>
                    <artifactId>groovy-eclipse-batch</artifactId>
                    <version>2.1.3-01</version>
                </dependency>
            </dependencies>
        </plugin>
        <plugin>                
            <groupId>org.codehaus.groovy</groupId>
            <artifactId>groovy-eclipse-compiler</artifactId>
            <version>2.7.0-01</version>
            <extensions>true</extensions>                       
        </plugin>
    </plugins>
</build>
1

There are 1 best solutions below

1
On

not sure if you shouldn't be using tycho-compiler-plugin instead of maven-compiler-plugin (it is used anyway for maven packaging types eclipse-plugin and eclipse-test-plugin).

tycho-compiler-plugin has an "excludeResources" configuration

https://www.eclipse.org/tycho/sitedocs/tycho-compiler-plugin/compile-mojo.html#excludeResources

which you can use to exclude for example **/*.groovy files

Here is a scala example

https://github.com/muuki88/tycho/blob/master/pom.xml#L38