Gradle无法下载Kotlin存储库

时间:2017-11-16 06:03:14

标签: java maven gradle kotlin jcenter

我使用Kotlin构建Gradle简单的Hello-Worl

我的build.gradle是:

/*
 * 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
        }
    }

Main.kt是:

fun main(args: Array<String>) {
    println("kotlin!")
}

运行Gradle buil后,我收到以下错误:

enter image description here

注意: - 我是gradle的新用户,因此将其构建为以下两个步骤:

第1步: enter image description here

第2步: enter image description here

更新

根据第一个答案,我尝试在本地获取文件,我创建了另一个名为lib的文件夹并将* .jar文件下载到其中,因此我得到了gradle.build,如下所示:

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

在我修改的结构和新错误之下:

enter image description here

更新

U将所有必需的存储库.jar和.pom复制到文件夹:

C:\ Users \用户的.m2 \库\有机\ JetBrains的\

我复制了例如: ... \科特林\科特林-STD \ 1.1.60 \科特林-STDLIB-1.1.60.jar 和 ... \注解\ 13.0 \注解-13.0.jar

并使用

mavenLocal()

但仍然得到同样的错误:(

0 个答案:

没有答案