我刚刚使用maven开始了我的第一个Kotlin项目。
当我开始将项目分成几个Maven模块时,我从Kotlin收到了许多奇怪的编译错误,这些错误对我来说没有任何意义。
此类是一个示例:
class ConfigurationException(msg: String) : Exception(msg)
我在这里看到编译器错误
[INFO] --- kotlin-maven-plugin:1.2.71:compile (compile) @ ticketmaster-cli-configuration ---
[ERROR] /home/matthias/dev/ticketmaster/ticketmaster-cli-configuration/src/main/kotlin/de/mh/ticketmaster/cli/config/ConfigurationException.kt: (3, 45) None of the following functions can be called with the arguments supplied:
public constructor Exception(p0: String!) defined in java.lang.Exception
public constructor Exception(p0: Throwable!) defined in java.lang.Exception
(这类错误有数百种)
它过去可以像没有子模块的简单Maven项目一样很好地编译,但是一旦引入子模块就停止了工作。有没有人看过类似的东西?
这是父pom的构建部分:
<build>
<sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>
<testSourceDirectory>${project.basedir}/src/test/kotlin</testSourceDirectory>
<plugins>
<plugin>
<artifactId>kotlin-maven-plugin</artifactId>
<groupId>org.jetbrains.kotlin</groupId>
<version>1.2.71</version>
<executions>
<execution>
<id>compile</id>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>test-compile</id>
<goals>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<dependencies>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-surefire-provider</artifactId>
<version>1.0.3</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.1.0</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
子模块仅继承该配置(未定义构建部分),并且都依赖于同一版本中的kotlin运行时。