Reputation:
The strangest thing ever occurred today when I was running a simple test class via Maven. From within the Eclipse IDE there is no problem what so ever.
My package has one JUnit Test Case Class and a package-info.java
documentation class.
I found that the package-info.java
somehow interferes with the Maven compiler plugin. When removed the test runs fine.
When the package-info.java
exists in the package Maven writes this in the log:
[ERROR] Failure executing javac, but could not parse the error:
javac: invalid source release: **/*.java
Usage: javac <options> <source files>
use -help for a list of possible options
How can I make Maven skip the package-info.java
so that I can keep it in the package folder?
Upvotes: 4
Views: 1015
Reputation: 7159
I had the exact same problem a few days back and solved it by entering this in my pom.xml file:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
<executions>
<execution>
<phase>test-compile</phase>
<goals>
<goal>testCompile</goal>
</goals>
<configuration>
<source>1.6</source>
<target>1.6</target>
<testSource> **/*.java</testSource>
<testExcludes>
<exclude>**/package-info.java</exclude>
</testExcludes>
</configuration>
</execution>
</executions>
</plugin>
It is the testExcludes element that makes Maven forget the package-info.java class.
Upvotes: 4