Maven 无法解析 Kotlin Maven 插件 jar



不确定如何修复此问题。

我想要这个版本的Kotlin运行时和maven插件。

这些是我的pom.xml中的位:

<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-runtime</artifactId>
<version>1.2-M2</version>
</dependency>
<build>
<plugins>
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<version>1.2-M2</version>
<executions>

我把它添加为回购:

<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>kotlin-bintray</id>
<name>Kotlin Bintray</name>
<url>http://dl.bintray.com/kotlin/kotlin-dev/</url>
</repository>

我得到这个错误:

找不到org.jetbrains.kotlin:kotlin-maven插件:jar:1.2-M2 inhttps://repo.maven.apache.org/maven2已缓存在本地存储库,在更新之前不会重新尝试解决方案中心的间隔已过或更新强制

但我看不出有什么问题。

顺便说一句,请注意,运行时jar是找到的,所以存储库部分必须是正确的,因为这个存储库是maven找到它的地方。不过,由于某些原因,maven插件jar是另一回事。。。

我刚刚修复了。这真是太傻了。我发现对于插件,需要定义一个插件存储库部分。

<pluginRepositories>
<pluginRepository>
<id>kotlin-bintray</id>
<name>Kotlin Bintray</name>
<url>http://dl.bintray.com/kotlin/kotlin-dev</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>

现在它起作用了。我想我应该花更多的时间深入学习maven:(

要确保它从maven central新鲜下载,您需要销毁本地副本,因此删除目录:

~/.m2/repo/org/jetbrains/kotlin/kotlin-maven插件

您还需要将第三方回购添加到位于~/.m2的settings.xml中,请参阅此处

<settings>
...
<profiles>
...
<profile>
<id>myprofile</id>
<repositories>
<repository>
<id>my-repo2</id>
<name>your custom repo</name>
<url>https://dl.bintray.com/kotlin/kotlin-dev/</url>
</repository>
</repositories>
</profile>
...
</profiles>

<activeProfiles>
<activeProfile>myprofile</activeProfile>
</activeProfiles>
...
</settings>

我刚刚添加了这一行,它对我很有用<version>${kotlin.version}</version>

在文档中,我们可以看到如何实现编译器插件

对于kotlin-allopen,在<plugin>标签内添加以下<configuration><pluginOptions>

<plugin>
<artifactId>kotlin-maven-plugin</artifactId>
<groupId>org.jetbrains.kotlin</groupId>
<version>${kotlin.version}</version>
<configuration>
<compilerPlugins>
<!-- Or "spring" for the Spring support -->
<plugin>all-open</plugin>
</compilerPlugins>
<pluginOptions>
<!-- Each annotation is placed on its own line -->
<option>all-open:annotation=com.my.Annotation</option>
<option>all-open:annotation=com.their.AnotherAnnotation</option>
</pluginOptions>
</configuration>
<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-allopen</artifactId>
<version>${kotlin.version}</version>
</dependency>
</dependencies>
</plugin>

最新更新