长时间的听众第一次来电。:-)
我正在尝试将我们工作中的 java webapp 慢慢转移到 scala 上,第一步是让一些 scala 代码在我们的项目中编译。我已将 scala-maven-plugin 添加到我们的 webapp 特定 pom 中,如下所示:
...
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<!--version>2.10.3</version-->
<version>2.7.2</version>
</dependency>
....
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>src/main/scala</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<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>
和其他变体,但这是我最新的。
现在这是 webapp 的 pom,我们还有一个 jar 的 pom,其中包含一些我们与其他应用程序共享的公共代码。并且这两个项目都依赖于其他内部 jar。
我的 scala 类是一个位于 src/main/scala 中的小控制器。
当我运行 maven 包或任何 maven 命令时,我遇到的错误实际上是:
[INFO] --- scala-maven-plugin:3.1.6:compile (scala-compile-first) @ producttool-webapp ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.663s
[INFO] Finished at: Thu Jan 16 15:34:09 PST 2014
[INFO] Final Memory: 16M/213M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal net.alchim31.maven:scala-maven-plugin:3.1.6:compile (scala-compile-fi
rst) on project producttool-webapp: Execution scala-compile-first of goal net.alchim31.maven:scala-m
aven-plugin:3.1.6:compile failed: For artifact {company.com:vine-xml:null:jar}: The version cannot be em
pty. -> [Help 1]
我在调试此构建时看到警告/错误,但这对我来说没有意义:
[WARNING] The POM for company.com:vine-xml:jar:1.11.1 is invalid, transitive dependencies (if any) will
not be available: 2 problems were encountered while building the effective model for company.com:vine-xm
l:
[ERROR] 'modelVersion' is missing. @ company.com:vine-xml:[unknown-version]
[ERROR] 'version' is missing. @ company.com:vine-xml:[unknown-version]
我们所依赖的子 jar 项目依赖于该 jar,它在他们的 pom.xml 中指定,它在调试中也是如此:
[DEBUG] company.com:vine-xml:jar:1.12.2:compile
...
[DEBUG] testArtifact: artifact=company.com:vine-xml:jar:1.12.2:compile
[DEBUG] includeArtifact: artifact=company.com:vine-xml:jar:1.12.2:compile
[DEBUG] startProcessChildren: artifact=company.com:vine-xml:jar:1.12.2:compile
[DEBUG] testArtifact: artifact=javax.xml.bind:jaxb-api:jar:2.1:compile
[DEBUG] omitForNearer: omitted=javax.xml.bind:jaxb-api:jar:2.1:compile kept=javax.xml.bind:jax
我想知道我的 scala-maven-plugin 是否没有看到任何依赖项并询问我将如何解决这个问题。或者是否有一种方法可以忽略我可以在 scala-maven-plugin 中打开的此类错误。
谢谢你的帮助。