我是一个mavenifying(是一个单词?)一个项目,其构建过程到目前为止完全基于ant /
shell脚本.
请考虑以下枚举
public enum ResourceType {
A, B;
}
以下bean:
public ResourceTypeOwner {
//set get resourceType property
}
以下代码片段:
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");
}
}
使用maven构建时出现编译错误:
Cannot switch on a value of type ResourceType. Only convertible int
values or enum variables are permitted
pom.xml具有以下用于编译的插件配置
org.apache.maven.plugins
maven-compiler-plugin
3.0
eclipse
1.6
1.6
1.6
org.codehaus.plexus
plexus-compiler-eclipse
2.2
...
ant(与org.eclipse.jdt.core.JDTCompilerAdapter)和eclipse构建/编译都很好.我显然做错了(除非它是一个未报告的maven-compiler-plugin或plexus-compiler-eclipse插件bug,这有点不太可能,切换枚举既不坏也不是火箭科学).有人有想法吗?
其他环境细节
$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”
更新:
标准JDK编译器成功编译特定类.看起来像一个plexus-compiler-eclipse 2.2问题.