Maven无法解析Kotlin Maven Plugin jar

时间:2017-08-30 15:51:07

标签: java maven

不确定如何解决此问题。

我想要Kotlin运行时的this versionmaven plugin

这些是我的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-plugin:jar:1.2-M2 in   https://repo.maven.apache.org/maven2被缓存在当地   存储库,在更新之前不会重新尝试解析   中心间隔已经过去或更新了   强制

但我没有看到任何可能出错的事。

顺便提一下,请注意找到了运行时jar,因此存储库部分必须正确,因为这个存储库是maven找到它的地方。由于某些原因,maven插件jar是另一回事......

3 个答案:

答案 0 :(得分:2)

要确保从maven中心下载新内容,您需要清除本地副本,因此请删除目录

〜/ .m2目录/回购/组织/ JetBrains的/科特林/科特林-行家-插件

您还需要将第三方回购添加到〜/ .m2 see here

的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>

答案 1 :(得分:2)

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

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

答案 2 :(得分:0)

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

对于kotlin-allopen,在<configuration>标记内添加跟随符<pluginOptions><plugin>

<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>
相关问题