I'm trying to create a new Kotlin project that builds with Gradle using IntelliJ IDEA (2016.2.5 on Ubuntu 16.04). When I do this I immediately get an error message.
Here's what I'm trying:
Select "Create New Project" from Welcome Screen.
Select "Gradle" from left hand pane, "Kotlin (Java)" from right. Click "Next".
Enter "hello-world" as ArtifactId. Click Next.
Ensure "Create separate module from source set" and "Use default Gradle wrapper" are selected, nothing else is. Click "Next".
Use defaults for project name and location. Click "Finish".
I then immediately get this error:
Gradle 'hello-world' project refresh failed
Error: Could not find org.jetbrains.kotlin:kotlin-gradle-plugin:1.1-M02-12.
Searched in the following locations:
https://repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-gradle-plugin/1.1-M02-12/kotlin-gradle-plugin-1.1-M02-12.pom
https://repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-gradle-plugin/1.1-M02-12/kotlin-gradle-plugin-1.1-M02-12.jar
Required by:
:hello-world:unspecified
The generated build.gradle
looks like this:
version '1.0-SNAPSHOT'
buildscript {
ext.kotlin_version = '1.1-M02-12'
repositories {
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
apply plugin: 'kotlin'
repositories {
mavenCentral()
}
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
}
How can I create a Kotlin project that builds with Gradle correctly?
In your build.gradle
, change ext.kotlin_version
to be:
ext.kotlin_version = '1.1-M02'
It's a minor bug that the IDE plugin puts its own version into build scripts, not the Kotlin version.
And also add the 1.1 EAP repository to the repositories
in both buildscript
and the root scope:
repositories {
// ...
maven { url "http://dl.bintray.com/kotlin/kotlin-eap-1.1" }
}
Kotlin artifacts related to EAP versions are not put into Maven Central like those of public releases, and this repository is not added automatically into the generated build script.
Then refresh the Gradle project, and the build should pass.
Feel free to check with this build.gradle
file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With