由于Scalac(https://issues.scala-lang.org/browse/SI-9853)中的错误,我无法使用scala-maven-plugin构建我的Java源代码。
使用src / main / java和src / main / scala中的源代码,可以很容易地拆分构建,以便由maven-compiler-plugin编译Java和由scala-maven-plugin编译Scala 。现在,我遇到了Scala类看不到Java类的问题。在执行mvn clean编译时,对于Scala类所需的所有Java类,我都“找不到”。检查“目标/类”表明那里有Java类。
我尝试将Scala构建移动到不同的阶段,但结果保持不变。
我怎样才能使Scala-build看到目标/类中已经可用的类?
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>de.codepitbull.maven</groupId>
<artifactId>maven-scalac-bug</artifactId>
<version>3.4.0-SNAPSHOT</version>
<name>Scalac + Javac</name>
<properties>
<scala.version>2.11.8</scala.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>${scala.version}</version>
</dependency>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-compiler</artifactId>
<scope>provided</scope>
<version>${scala.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>3.2.2</version>
<configuration>
<sendJavaToScalac>false</sendJavaToScalac>
<args>
<arg>-target:jvm-1.8</arg>
<arg>-feature</arg>
<arg>-deprecation</arg>
<arg>-explaintypes</arg>
<arg>-unchecked</arg>
<arg>-Xlint</arg>
</args>
</configuration>
<executions>
<execution>
<id>java-compile-first</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
最简单的解决方法是将其分为两个子模块。这样,您就可以将Java类引用为依赖项。之后,生成内联两个模块的Uber jar或有阴影的jar。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句