繁体   English   中英

Maven 无法解析 Kotlin Maven 插件 Z68995FCBF432492D1548D2DAC04

[英]Maven can't resolve the Kotlin Maven Plugin 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>

我收到此错误:

Failure to find org.jetbrains.kotlin:kotlin-maven-plugin:jar:1.2-M2 in https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval中央已过或强制更新

但我没有看到任何可能有问题的地方。

顺便说一句,请注意运行时 jar 已找到,因此存储库部分必须正确,因为此存储库是 maven 找到它的位置。 maven 插件 jar 由于某种原因是另一回事......

为了确保它可以从Maven Central重新下载,您需要删除本地副本,因此请删除目录

〜/ .m2 / repo / org / jetbrains / kotlin / kotlin-maven-plugin

您还需要在〜/ .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>

我刚修好。 这真的很愚蠢。 我发现,对于插件,需要定义一个插件存储库部分。

<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 :)

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

对于kotlin-allopen ,在<plugin>标记内添加followingin <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>

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM