I am mavenifying (is that a word?) a project whose build process has been so far based entirely on ant/shell scripts.
Consider the following enum
public enum ResourceType {
A, B;
}
The following bean:
public ResourceTypeOwner {
//set get resourceType property
}
And the following code snippet:
void foo(ResourceTypeOwner rto) {
ResourceType resourceType = rto.getResourceType();
switch (resourceType) {
case A:
handleA(resourceType); break;
case B:
handleB(resourceType); break;
default:
throw new RuntimeException("Unsupported resource type");
}
}
I am getting a compilation error when building with maven:
Cannot switch on a value of type ResourceType. Only convertible int
values or enum variables are permitted
The pom.xml has the following plugin configuration for compiling
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
<compilerId>eclipse</compilerId>
<compilerVersion>1.6</compilerVersion>
<source>1.6</source>
<target>1.6</target>
</configuration>
<dependencies>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-compiler-eclipse</artifactId>
<version>2.2</version>
</dependency>
</dependencies>
</plugin>
...
</plugins>
Both ant (with org.eclipse.jdt.core.JDTCompilerAdapter) and eclipse build/compile fine. I am obviously doing something wrong (unless it's an unreported maven-compiler-plugin or plexus-compiler-eclipse plugin bug, which is somewhat unlikely, switching on enums is neither bad nor rocket science). Does anybody have an idea?
Additional environment details
$mvn -version Apache Maven 3.0.4 (r1232337; 2012-01-17 10:44:56+0200)
Maven home: /home/d/dev/tools/apache-maven-3.0.4 Java version:
1.6.0_35, vendor: Sun Microsystems Inc. Java home: /opt/jdk1.6.0_35/jre Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.2.0-40-generic", arch: "amd64", family:
"unix"
UPDATE:
Standard JDK compiler compiles the specific class successfully. Looks like an plexus-compiler-eclipse 2.2 issue.