我是一个mavenifying(是一个单词?)一个项目,其构建过程到目前为止完全基于ant/shell脚本.
请考虑以下枚举
public enum ResourceType {
A, B;
}
Run Code Online (Sandbox Code Playgroud)
以下bean:
public ResourceTypeOwner {
//set get resourceType property
}
Run Code Online (Sandbox Code Playgroud)
以下代码片段:
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");
}
}
Run Code Online (Sandbox Code Playgroud)
使用maven构建时出现编译错误:
无法打开ResourceType类型的值.只允许使用可转换的int值或枚举变量
pom.xml具有以下用于编译的插件配置
<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>
Run Code Online (Sandbox Code Playgroud)
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 …