我有一个混合 java 和 scala 代码的项目,它使用 maven 进行依赖和构建管理。我使用maven-source-plugin来构建一个上传到我的 maven 镜像的源文件,它适用于java源(in src/main/java),但不适用于scala源(in src/main/scala)。
我在scala-maven-plugin 网页上没有找到任何帮助,但我可能错过了一些东西。是否无法在 jar 中附加 Scala 源?
我应该注意到类文件都在那里,所以取决于库工作正常,只是缺少 Scala 源。
小智 6
I had a similar problem; I'd added the maven-source-plugin fine, but was seeing
[INFO] --- maven-source-plugin:3.0.0:jar (attach-sources) @ foo-bar ---
[INFO] No sources in project. Archive not created.
Run Code Online (Sandbox Code Playgroud)
when I compiled my Scala project.
To fix this, I added the add-source goal to my scala-maven-plugin config, eg:
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<id>scala-compile-first</id>
<phase>process-resources</phase>
<goals>
<goal>compile</goal>
<goal>add-source</goal>
</goals>
</execution>
...
</executions>
...
</plugin>
Run Code Online (Sandbox Code Playgroud)
这会将您的 Scala 源添加到 pom,从而允许maven-source-plugin找到源文件并将它们放入源 jar 中。
另见http://davidb.github.io/scala-maven-plugin/add-source-mojo.html
| 归档时间: |
|
| 查看次数: |
6478 次 |
| 最近记录: |