简体   繁体   中英

Maven can't resolve the Kotlin Maven Plugin jar

Not sure how to fix this.

I want this version of the Kotlin runtime and maven plugin .

These are the bits in my 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>

And I added this as a repo:

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

I get this error:

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 of central has elapsed or updates are forced

But I don't see anything that might be wrong.

By the way, notice that the runtime jar is found, so the repository section must be correct since this repository is where maven finds it. The maven plugin jar is a different matter for some reason though...

To make sure it downloads fresh from maven central you will need to blow away your local copy, so delete the directory

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

You will also need to add the 3rd party repo to your settings.xml at ~/.m2 see here

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

I just fixed. It was something really silly. I found out that for plugins one needs to define a plugin repository section.

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

And now it works. I guess I should spend more time learning maven in depth :)

At the documentation , we can see how to implement Compiler Plugins

For kotlin-allopen add the followin <configuration> and <pluginOptions> inside the <plugin> tag

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

i just added this line and it worked for me <version>${kotlin.version}</version>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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