Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to properly configure Kotlin plugin for Gradle?

I'm trying to build a basic Gradle project. My build.gradle file is below. I keep getting the below error. I don't get it because you can find the plugin here... where I think I'm directing to: https://mvnrepository.com/artifact/org.jetbrains.kotlin/kotlin-gradle-plugin

Update: same thing happens to the spring-boot plugin if I comment out the Kotlin line. It's not just specific to the Kotlin plugin.

The error:

Error:(21, 0) Plugin [id: 'kotlin', version: '1.1.1'] was not found in any of the following sources: 
- Gradle Core Plugins (not a core plugin, please see https://docs.gradle.org/3.3/userguide/standard_plugins.html for available core plugins) 
- Gradle Central Plugin Repository (no 'kotlin' plugin available - see https://plugins.gradle.org for available plugins)

Build.gradle:

buildscript {


    ext.kotlin_version = '1.1.1'

    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:1.2.6.RELEASE")
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }


}

plugins {
    id 'java'
    id 'kotlin' version "1.1.1"
    id 'spring-boot'
}



group 'si.dime.kotlin.tutorials.rest'
version '1.0-SNAPSHOT'

sourceCompatibility = 1.8

repositories {
    mavenCentral()
}

sourceSets {
    main.java.srcDirs += 'src/main/kotlin'
}

dependencies {
    compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
    compile("org.springframework.boot:spring-boot-starter-web:1.3.3.RELEASE")
}
like image 502
Ben Cooper Avatar asked Mar 24 '17 02:03

Ben Cooper


People also ask

How do I set the Gradle plugin version?

You can specify the Gradle version in either the File > Project Structure > Project menu in Android Studio, or update your Gradle version using the command line.

Does Gradle work with Kotlin?

Gradle is a build system that is very commonly used in the Java, Android, and other ecosystems. It is the default choice for Kotlin/Native and Multiplatform when it comes to build systems.


1 Answers

For non-core Gradle plugins (those that are not from the org.gradle namespace), you have to use a fully qualified id as well as a version number.

The official Kotlin documentation contains the id to use:

plugins {
  id "org.jetbrains.kotlin.jvm" version "<version to use>"
}

(You can also find these ids by searching for the plugin on the plugins.gradle.org site.)

like image 72
zsmb13 Avatar answered Oct 18 '22 20:10

zsmb13