我想使用 maven 来构建存在未解决编译问题的项目。
主要目的是使用包含编译错误的类的某种存根来打包和部署或运行应用程序,就像我理解 Eclipse 所做的那样(感谢JDT Core)。
我按照使用非 Javac 编译器中的Apache Maven 文档配置 maven java 编译器插件以使用 Eclipse 编译器。认为可能应该设置一些参数来修改编译器/构建器行为我正在阅读帮助 Eclipse - 编译 Java 代码,但我不知道哪个编译器/构建器选项或这些选项的组合可以解决问题。
到目前为止,maven java编译器插件的下一个配置使用eclipse编译器编译,并打包应用程序,包括为java类生成的.class(jvm字节码),没有编译错误。要获得这种行为,它只需要使用 eclipse 编译器(请参阅 compilerId 和依赖项)并设置failOnError=false
.
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<compilerId>eclipse</compilerId>
<source>1.7</source>
<target>1.7</target>
<optimize>true</optimize>
<showWarnings>true</showWarnings>
<showDeprecation>true</showDeprecation>
<failOnError>false</failOnError>
<compilerArguments>
<org.eclipse.jdt.core.compiler.problem.fatalOptionalError>disabled</org.eclipse.jdt.core.compiler.problem.fatalOptionalError>
<org.eclipse.jdt.core.compiler.problem.forbiddenReference>ignore</org.eclipse.jdt.core.compiler.problem.forbiddenReference>
</compilerArguments>
</configuration>
<dependencies>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-compiler-eclipse</artifactId>
<version>2.3</version>
</dependency>
</dependencies>
</plugin>
使用此配置,只要执行不使用未包含编译错误的类(因为未生成存根),我就可以运行 java 应用程序,但在 Java EE 容器上,类加载将失败,因此永远无法部署应用程序.
我很感激这方面的任何帮助。