长时间听众第一次来电。 : - )
我正在尝试慢慢地将我们的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,其中包含我们与其他应用共享的一些常用代码。这两个项目都依赖于其他内部罐子。
我的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中打开的错误。
感谢您的帮助。
答案 0 :(得分:0)
嗯,我不确定是否还有另一个修复,但是从完全不同的子项目中排除了违规的jar,就像下面的那样。
<exclusion>
<artifactId>vine-xml</artifactId>
<groupId>company.com</groupId>
</exclusion>