1 回答
![?](http://img1.sycdn.imooc.com/54584d080001566902200220-100-100.jpg)
TA贡献1810条经验 获得超5个赞
您正在为 Scala 编译使用一个非常旧的插件(最新版本2.15.2已于 2011年 2 月 6 日发布)。
我建议您先升级到更新的插件,例如( 2019 年 5 月 11 日的scala-maven-plugin最新版本)。4.0.2
然后,您可以在文档中找到混合 Scala/Java 源代码的示例。在这种情况下不需要使用build-helper-maven-plugin,也不需要配置sourceDirectory和testSourceDirectory。用这个插件检查这个简单pom.xml的(当我在本地重现问题时,我刚刚从你提供的示例中删除了未使用的依赖项):
<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<name>myproject</name>
<url>http://maven.apache.org</url>
<groupId>com.myorg</groupId>
<artifactId>myproject</artifactId>
<packaging>jar</packaging>
<version>0.1.0-RELEASE</version>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<encoding>UTF-8</encoding>
<scala.tools.version>2.11</scala.tools.version>
<scala.version>2.11.8</scala.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>4.0.2</version>
<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>
<!-- This builds the fat JAR -->
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>com.myorg.myproject.spark.Main</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>${scala.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
- 1 回答
- 0 关注
- 101 浏览
添加回答
举报