kotlin编译器似乎只是试图编译src / main / java中的.kt文件,而忽略了src / main / kotlin。但是,所有内容似乎都在IntelliJ IDE中正确链接。没有错误。
以下是我对kotlin的插件配置:
<plugins>
<plugin>
<artifactId>kotlin-maven-plugin</artifactId>
<groupId>org.jetbrains.kotlin</groupId>
<version>${kotlin.version}</version>
<executions>
<execution>
<id>compile</id>
<goals> <goal>compile</goal> </goals>
<configuration>
<sourceDirs>
<sourceDir>${project.basedir}/src/main/kotlin</sourceDir>
<sourceDir>${project.basedir}/src/main/java</sourceDir>
</sourceDirs>
</configuration>
</execution>
<execution>
<id>test-compile</id>
<goals> <goal>test-compile</goal> </goals>
<configuration>
<sourceDirs>
<sourceDir>${project.basedir}/src/test/kotlin</sourceDir>
<sourceDir>${project.basedir}/src/test/java</sourceDir>
</sourceDirs>
</configuration>
</execution>
</executions>
</plugin>
但是,当我运行mvn clean install时,kotlin编译器似乎没有运行。所以我尝试直接从插件运行kotlin编译器。
[INFO] --- kotlin-maven-plugin:1.1.2:compile (default-cli) @ eagle-client-core ---
[INFO] Kotlin Compiler version 1.1.2
[INFO] Compiling Kotlin sources from [C:\Users\me\workspace\Project\Clients\project-client\project-client-core\src\main\java]
如您所见,src / main / java正在扫描,但不是src / main / kotlin。
我的配置没有看到任何明显错误。任何帮助都是适当的。
答案 0 :(得分:1)
您可能需要关闭https://kotlinlang.org/docs/reference/using-maven.html#compiling-kotlin-and-java-sources
中所述的默认编译<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<executions>
<!-- Replacing default-compile as it is treated specially by maven -->
<execution>
<id>default-compile</id>
<phase>none</phase>
</execution>
<!-- Replacing default-testCompile as it is treated specially by maven -->
<execution>
<id>default-testCompile</id>
<phase>none</phase>
</execution>
<execution>
<id>java-compile</id>
<phase>compile</phase>
<goals> <goal>compile</goal> </goals>
</execution>
<execution>
<id>java-test-compile</id>
<phase>test-compile</phase>
<goals> <goal>testCompile</goal> </goals>
</execution>
</executions>
</plugin>