【发布时间】:2016-02-11 12:46:02
【问题描述】:
我正在使用 Maven 和 kotlin-maven-plugin 来编译代码。
<plugin>
<artifactId>kotlin-maven-plugin</artifactId>
<groupId>org.jetbrains.kotlin</groupId>
<version>${kotlin.version}</version>
<executions>
<execution>
<id>compile</id>
<phase>process-sources</phase>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<sourceDirs>
<source>src/main/kotlin</source>
<source>src/main/resources</source>
<source>target/generated-sources/jooq-h2</source>
</sourceDirs>
</configuration>
</execution>
<execution>
<id>test-compile</id>
<phase>process-test-sources</phase>
<goals>
<goal>test-compile</goal>
</goals>
<configuration>
<sourceDirs>
<source>src/test/kotlin</source>
</sourceDirs>
</configuration>
</execution>
</executions>
</plugin>
target/generated-sources/jooq-h2 目录包含 Java 源文件。我正在关注Kotlin manual 和其他people's recommendation,将Kotlin 编译放在<phase>process-sources</phase> 而不是<phase>compile</phase>。我(可能是错误的?)假设 Kotlin 编译器也负责为我编译这些 Java 文件。
但是,在某些服务器(例如 Jenkins CI)上,我收到了奇怪的编译错误消息,例如:
[ERROR] /var/lib/jenkins/jobs/jooq-build/workspace/jOOQ-examples/jOOQ-kotlin-example/target/generated-sources/jooq-h2/org/jooq/example/db/h2/tables/Author.java:[35,37]
error: generics are not supported in -source 1.3
为什么会这样?
【问题讨论】:
-
@Tunaki:没有 Kotlin。具体来说,我(错误地)假设 Kotlin 编译器也会为我编译 Java 类。
-
@LukasEder Kotlin 仅使用 Java 类生成存根供 Kotlin 进行编译,然后 Kotlin 在 Java 之前编译,然后 SOMETHING ELSE 编译 Java。