I'm building Kotlin
simple Hello-Worl using Gradle
my build.gradle
is:
/*
* This build file was generated by the Gradle 'init' task.
*
* This generated file contains a commented-out sample Java project to get you started.
* For more details take a look at the Java Quickstart chapter in the Gradle
* user guide available at https://docs.gradle.org/4.3.1/userguide/tutorial_java_projects.html
*/
// Apply the java plugin to add support for Kotlin
apply plugin: 'kotlin'
/*
plugins {
id "org.jetbrains.kotlin.jvm" version "1.1.60"
}
*/
buildscript {
ext.kotlin_version = '1.1.60'
// In this section you declare where to find the dependencies of your project
repositories {
mavenCentral()
// jcenter()
}
// In this section you declare the dependencies for your production and test code
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
sourceSets {
main.kotlin.srcDirs += 'src/kotlin'
main.resources.srcDirs += 'src/resources'
}
dependencies {
compile 'org.slf4j:slf4j-api:1.7.7'
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
testCompile 'junit:junit:4.12'
}
kotlin {
experimental {
coroutines 'enable'
}
}
compileKotlin {
kotlinOptions.suppressWarnings = true
}
compileKotlin {
kotlinOptions {
suppressWarnings = true
}
}
and Main.kt
is:
fun main(args: Array<String>) {
println("kotlin!")
}
upon running Gradle buil
, I got the below error:
Notes:
- I'm new to gradle
so built it as below 2 steps:
UPDATE
As per the first answer, I tried getting the files locally, I created another folder named lib
and downloaded the *.jar files into it, so I got the gradle.build
as below:
buildscript {
ext.kotlin_version = '1.1.60'
repositories {
flatDir {
dirs 'libs'
}
}
dependencies {
classpath fileTree(include: ['*.jar'], dir: 'libs')
classpath files('kotlin-gradle-plugin-1.1.60.jar')
}
}
apply plugin: 'kotlin'
sourceSets {
main.kotlin.srcDirs += 'src/kotlin'
main.resources.srcDirs += 'src/resources'
}
dependencies {
compile 'org.slf4j:slf4j-api:1.7.7'
compile name: 'kotlin-stdlib-1.1.60'
testCompile 'junit:junit:4.12'
}
kotlin {
experimental {
coroutines 'enable'
}
}
compileKotlin {
kotlinOptions.suppressWarnings = true
}
compileKotlin {
kotlinOptions {
suppressWarnings = true
}
}
Below the revised structure and new error I got:
UPDATE
U copied all the required repositories .jar and .pom to folder:
C:\Users\.m2\repository\org\jetbrains\
I copied for example: ...\kotlin\kotlin-std\1.1.60\kotlin-stdlib-1.1.60.jar And ...\annotations\13.0\annotations-13.0.jar
And used
mavenLocal()
But still getting the same error :(