首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >无法找到Kotlin脚本Gradle的kotlin-gradle-plugin

无法找到Kotlin脚本Gradle的kotlin-gradle-plugin
EN

Stack Overflow用户
提问于 2018-02-07 12:06:42
回答 1查看 1.7K关注 0票数 3

生成失败,类路径错误:

代码语言:javascript
运行
复制
thufir@dur:~/NetBeansProjects/kotlinShadowJar$ 
thufir@dur:~/NetBeansProjects/kotlinShadowJar$ gradle clean

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'kotlinShadowJar'.
> Could not resolve all files for configuration ':classpath'.
   > Could not find org.jetbrains.kotlin:kotlin-gradle-plugin:.
     Searched in the following locations:
         file:/home/thufir/.gradle/caches/4.3.1/embedded-kotlin-repo-1.1.51-1/repo/org/jetbrains/kotlin/kotlin-gradle-plugin//kotlin-gradle-plugin-.pom
         file:/home/thufir/.gradle/caches/4.3.1/embedded-kotlin-repo-1.1.51-1/repo/org/jetbrains/kotlin/kotlin-gradle-plugin//kotlin-gradle-plugin-.jar
         https://repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-gradle-plugin//kotlin-gradle-plugin-.pom
         https://repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-gradle-plugin//kotlin-gradle-plugin-.jar
         https://repo.gradle.org/gradle/repo/org/jetbrains/kotlin/kotlin-gradle-plugin//kotlin-gradle-plugin-.pom
         https://repo.gradle.org/gradle/repo/org/jetbrains/kotlin/kotlin-gradle-plugin//kotlin-gradle-plugin-.jar
     Required by:
         project :

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

* Get more help at https://help.gradle.org

BUILD FAILED in 1s

cat build.gradle.kts

代码语言:javascript
运行
复制
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar

buildscript {
    repositories {
        mavenCentral()
        gradleScriptKotlin()
    }
    dependencies {
        classpath(kotlinModule("gradle-plugin"))
        classpath("com.github.jengelman.gradle.plugins:shadow:1.2.3")
    }
}

apply {
    plugin("kotlin")
    plugin("com.github.johnrengelman.shadow")
}

repositories {
    mavenCentral()
}

val shadowJar: ShadowJar by tasks
shadowJar.apply {
    manifest.attributes.apply {
        put("Implementation-Title", "Gradle Jar File Example")
        put("Implementation-Version" version)
        put("Main-Class", "com.mkyong.DateUtils")
    }

    baseName = project.name + "-all"
}

构建文件是工作构建的直接复制。上下文已经开始使用Kotlin脚本级了。到目前为止,我可以告诉脚本应该是好的

请注意,我没有使用智能J,这是严格从CLI与Kotlin脚本Gradle。

也许是一些相当简单的东西,比如“插件”和“插件”.

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-02-26 17:05:14

查看错误日志,您可以看到插件版本请求:

代码语言:javascript
运行
复制
Searched in the following locations:
     file:/home/thufir/.gradle/caches/4.3.1/embedded-kotlin-repo-1.1.51-1/repo/org/jetbrains/kotlin/kotlin-gradle-plugin//kotlin-gradle-plugin-.pom
     file:/home/thufir/.gradle/caches/4.3.1/embedded-kotlin-repo-1.1.51-1/repo/org/jetbrains/kotlin/kotlin-gradle-plugin//kotlin-gradle-plugin-.jar
     https://repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-gradle-plugin//kotlin-gradle-plugin-.pom
     https://repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-gradle-plugin//kotlin-gradle-plugin-.jar
     https://repo.gradle.org/gradle/repo/org/jetbrains/kotlin/kotlin-gradle-plugin//kotlin-gradle-plugin-.pom
     https://repo.gradle.org/gradle/repo/org/jetbrains/kotlin/kotlin-gradle-plugin//kotlin-gradle-plugin-.jar

您可以看到,每个插件请求都不需要版本,因为他们正在寻找kotlin-gradle-plugin-.jar

如果您使用看看源头,您还会看到kotlinModule不受欢迎。

为了改进构建脚本,我建议做一些不同的修改:

  1. 使用Gradle包装器(./gradlew )
  2. 为您的kotlinModule指定一个版本,直到升级您的分级版本- kotlinModule("gradle-plugin", "1.1.51")
  3. 插件使用plugins {}块而不是buildscript
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48663427

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档