DPM
DPM

Reputation: 2030

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

Upvotes: 3

Views: 14363

Answers (4)

YounextAdams
YounextAdams

Reputation: 96

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

Upvotes: 5

Essex Boy
Essex Boy

Reputation: 7940

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>

Upvotes: 4

Gast&#243;n Saill&#233;n
Gast&#243;n Saill&#233;n

Reputation: 13129

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>

Upvotes: 2

DPM
DPM

Reputation: 2030

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

Upvotes: 10

Related Questions