我实际上正在为Jenkins开发一个插件,我想在我的插件中集成Scala,Java和Maven。我用Java开发了我的插件的一部分,我想在Scala中开发其他部分。 问题是当我整合所有这些(maven,Scala和Java)时,我从scala maven插件中得到了这个错误:
[INFO] artifact org.kohsuke.stapler:stapler: checking for updates from scala
[INFO] D:\workspace\remote-deployment-new\src\main\java:-1: info: compiling
[INFO] D:\workspace\remote-deployment-new\target\generated-sources\localizer:-1: info: compiling
[INFO] Compiling 4 source files to D:\workspace\remote-deployment-new\target\classes at 1352200897840
[ERROR] D:\workspace\remote-deployment-new\src\main\java\com\ebiznext\plugins\RemoteDeployment.java:33: error: RemoteDep
loyment is already defined as package RemoteDeployment
[INFO] public class RemoteDeployment extends Plugin implements Action, ExtensionPoint, Describable<RemoteDeployment> {
[INFO] ^
[ERROR] one error found
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 52.801s
[INFO] Finished at: Tue Nov 06 12:21:39 CET 2012
[INFO] Final Memory: 27M/370M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal net.alchim31.maven:scala-maven-plugin:3.1.0:compile (default) on project remote-deploymen
t-new: wrap: org.apache.commons.exec.ExecuteException: Process exited with an error: 1(Exit value: 1) -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
我完全理解错误说类RemoteDeployment
已经被定义为包。这是真的,因为在为Jenkins开发插件时,如果我有一个类,例如com.ebiznext.plugins包中定义的RemoteDeployment
,我必须在{{1}下创建一个包com.ebiznext.plugins.RemoteDeployment
}。那是一个詹金斯大会,我对此无能为力。
如何更正此问题?
这是我的POM:
src/main/resources
答案 0 :(得分:1)
我建议使用net.alchim31.maven:scala-maven-plugin进行编译。然后,您可以将参数设置为编译器-Yresolve-term-conflict:object
。
例如:
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<configuration>
<recompileMode>incremental</recompileMode> <!-- NOTE: incremental compilation although faster requires passing to MAVEN_OPTS="-XX:MaxPermSize=128m" -->
<useZincServer>true</useZincServer> <!-- NOTE: if you have Zinc server installed and running, you can get faster compilation by enabling this -->
<!-- addScalacArgs>-feature</addScalacArgs -->
<args>
<arg>-Yresolve-term-conflict:object</arg> <!-- required for package/object name conflict in Jenkins jar -->
</args>
<javacArgs>
<javacArg>-Xlint:unchecked</javacArg>
<javacArg>-Xlint:deprecation</javacArg>
</javacArgs>
</configuration>
<executions>
<execution>
<id>scala-compile-first</id>
<phase>process-resources</phase>
<goals>
<goal>add-source</goal>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>scala-test-compile</id>
<phase>process-test-resources</phase>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
答案 1 :(得分:0)
如果您的java代码依赖于scala类,则应首先编译scala类。
这有效:
clean scala:compile compile package