簡體   English   中英

我怎樣才能使scala-maven-plugin看到由maven-compiler-plugin編譯的類?

[英]How can I make scala-maven-plugin make see classes compiled by maven-compiler-plugin?

由於Scalac( https://issues.scala-lang.org/browse/SI-9853 )中的錯誤,我無法使用scala-maven-plugin構建我的Java源代碼。

使用src / main / javasrc / 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。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM