我實際上正在爲Jenkins開發一個插件,並且我想將Scala,Java和Maven集成到我的插件中。我開發了Java插件的一部分,我想在Scala中開發其他部分。 的事情是,當我整合所有的人(行家,斯卡拉和Java),我從斯卡拉Maven插件此錯誤:構建Scala,Maven和Java集成的失敗
[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
,我必須創建一個包src/main/resources
。這是詹金斯的慣例,我對此無能爲力。
我該如何解決這個問題?
這裏是我的POM:
<project>
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>1.466</version><!-- which version of Jenkins is this plugin built
against? -->
</parent>
<groupId>com.ebiznext.plugins</groupId>
<artifactId>remote-deployment-new</artifactId>
<version>1.0</version>
<name>Remote Deployment</name>
<packaging>hpi</packaging>
....
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>3.1.0</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<id>compile</id>
<goals>
<goal>compile</goal>
</goals>
<phase>compile</phase>
</execution>
<execution>
<id>test-compile</id>
<goals>
<goal>testCompile</goal>
</goals>
<phase>test-compile</phase>
</execution>
<execution>
<phase>process-resources</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
我有同樣的問題。我有一個混合的Java/Scala項目。對於我的測試課程,我有資源中的測試數據,例如對於com.organization.foo.bar.MyTest,數據位於src/test/java/resources/com/organization/foo/bar/MyTest中。一切都很好,直到我將其中一個測試從Java切換到Scala,然後它不會編譯,報告「已經定義爲包」錯誤。它必須是資源名稱和類名稱之間的衝突。 –