使用IJ和Gradle 6.5重新加载项目时出错

使用IJ和Gradle 6.5重新加载项目时出错,gradle,intellij-idea,Gradle,Intellij Idea,当我试图用IntelliJ中的Gradle重新加载我的项目时,我失败了 FAILURE: Build failed with an exception. * Where: Initialization script 'C:\Users\yateu\AppData\Local\Temp\ijinit.gradle' line: 4 * What went wrong: Could not compile initialization script 'C:\Users\yateu\AppData

当我试图用IntelliJ中的Gradle重新加载我的项目时,我失败了

FAILURE: Build failed with an exception.

* Where:
Initialization script 'C:\Users\yateu\AppData\Local\Temp\ijinit.gradle' line: 4

* What went wrong:
Could not compile initialization script 'C:\Users\yateu\AppData\Local\Temp\ijinit.gradle'.
> startup failed:
  initialization script 'C:\Users\yateu\AppData\Local\Temp\ijinit.gradle': 4: unable to resolve class org.jetbrains.plugins.gradle.tooling.internal.ExtraModelBuilder
   @ line 4, column 1.
     import org.jetbrains.plugins.gradle.tooling.internal.ExtraModelBuilder
     ^
  
  1 error


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

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

BUILD FAILED in 57ms
IJ 2020.2EAP(202.5958.24)、Gradle 6.5(.1)、OpenJDK 14都会出现这种情况

  • 切换到IJ 2020.1.2会导致相同的问题
  • 切换到Gradle 6.4.1可以正常工作
  • 我还试图通过应用java插件来使用一个非常基本的build.gradle,但得到了相同的错误
ijinit.gradle的前几行如下(我们可以看到导入失败):

我当前的IJ安装有问题吗?还是Gradle 6.5根本不受支持

谢谢你的帮助

编辑 我正在使用的实际build.gradle:

plugins {
    id 'com.github.johnrengelman.shadow' version '6.0.0'
    id "com.github.ben-manes.versions" version '0.28.0'
    id 'com.novoda.build-properties' version '0.4.1'
    id 'idea'
    id 'java'
    id 'application'
    id "io.freefair.lombok" version '5.1.0'
}

def secretsFile = new File(".", "secrets.properties")

if (!secretsFile.getParentFile().exists()) {
    secretsFile.mkdirs()
}

if (!secretsFile.exists()) {
    secretsFile.withWriterAppend { w ->
        w << "\n"
    }
}

buildProperties {
    secrets {
        using(file('secrets.properties')).or(System.getenv()).or([
                "GITHUB_USER" : "RakSrinaNa",
                "GITHUB_TOKEN": "N/A"
        ])
    }
}

group = 'fr.raksrinana'
description = 'RSNDiscord'
sourceCompatibility = targetCompatibility = JavaVersion.VERSION_14

mainClassName = project.mainClass

dependencies {
    implementation("net.dv8tion:JDA:${project.JDA_version}") {
        exclude module: 'opus-java'
    }
    implementation("com.sedmelluq:lavaplayer:${project.lavaplayer_version}")
    implementation("com.github.natanbc:lavaplayer-arm-natives:${project.lavaplayer_arm_version}")

    implementation("org.slf4j:slf4j-api:${project.slf4j_version}")
    implementation("ch.qos.logback:logback-classic:${project.logback_version}") {
        exclude group: 'edu.washington.cs.types.checker', module: 'checker-framework'
    }
    implementation("fr.raksrinana:utils.http:${project.raksrinana_utils_version}")

    implementation("com.beust:jcommander:${project.jcommander_version}")
    implementation("com.fasterxml.jackson.core:jackson-core:${project.jackson_version}")
    implementation("com.fasterxml.jackson.core:jackson-annotations:${project.jackson_version}")
    implementation("com.fasterxml.jackson.core:jackson-databind:${project.jackson_version}")
    implementation("org.apache.httpcomponents:httpclient:${project.httpclient_version}")
    implementation("org.apache.commons:commons-lang3:${project.lang3_version}")
    implementation("org.reflections:reflections:${project.reflections_version}")
    implementation("com.vdurmont:emoji-java:${project.emoji_java_version}")
    implementation("org.imgscalr:imgscalr-lib:${project.imgscalr_version}")
}

repositories {
    maven {
        url = 'https://repo.maven.apache.org/maven2'
    }
    maven {
        url = 'https://jcenter.bintray.com'
    }
    maven {
        url = 'https://maven.pkg.github.com/RakSrinaNa/JavaUtils/'
        credentials {
            username buildProperties.secrets['GITHUB_USER'].string
            password buildProperties.secrets['GITHUB_TOKEN'].string
        }
    }
}

import org.apache.tools.ant.filters.ReplaceTokens

processResources {
    doFirst {
        from 'src/main/resources'
        filter(ReplaceTokens, tokens: [project_version: project.version, project_name: project.name])
    }
}

compileJava {
    inputs.property("moduleName", moduleName)
    doFirst {
        options.compilerArgs = [
                '--module-path', classpath.asPath,
        ]
        classpath = files()
    }
}

test {
    useJUnitPlatform()
}

application {
    mainModule = project.moduleName
    mainClass = project.mainClass
}

java {
    modularity.inferModulePath.set(true)
}

shadowJar {
    archivesBaseName = project.name
    classifier = 'shaded'
    archiveVersion = ''
}

tasks.withType(JavaCompile) {
    options.encoding = 'UTF-8'
    options.deprecation = true
}

tasks.withType(Wrapper) {
    gradleVersion = project.wrapper_version
}
编辑2:
在JB端打开了一个问题

我在最新版本的everything中得到了这个问题-gradle插件4.1.2和gradle版本6.5。我在C上安装了Windows操作系统,在便携式硬盘上重新安装了Android Studio(内置intellij)。这个项目也在便携式硬盘上

gradle脚本似乎无法在另一个磁盘上找到包org.jetbrains.plugins.gradle.tooling.internal.ExtraModelBuilder。


在你的C盘上安装Android Studio,如果是这样,你所有的问题都会解决。

我对IJ 2020.1.2中的Gradle 6.5.1没有任何问题。你能分享你的build.gradle吗?@TomasZezula我用build.gradle编辑了这篇文章。还有一个最小的失败。如果这对你有用的话,也许我应该在Jetbrains的youtrack上报告。我对极简主义的构建配置没有问题。我在实际build.gradle中得到一个错误,因为它引用了gradle.properties中必须包含的一些自定义变量。尽管如此,我相信我已经找到了你的repo(FileSecure,correct?),并且在使用gradle 6.5.1构建项目时没有任何问题。这是RSNDiscord,但是的,如果极简文件是为你而不是为我工作的,那么这可能是我与IJ之间的问题。我将尝试完全清除/重新安装它,如果不起作用,则在他们的youtrack上打开一个问题。谢谢你的帮助:)@RakSrinaNa你已经解决了这个问题,我也面临同样的问题。
plugins {
    id 'com.github.johnrengelman.shadow' version '6.0.0'
    id "com.github.ben-manes.versions" version '0.28.0'
    id 'com.novoda.build-properties' version '0.4.1'
    id 'idea'
    id 'java'
    id 'application'
    id "io.freefair.lombok" version '5.1.0'
}

def secretsFile = new File(".", "secrets.properties")

if (!secretsFile.getParentFile().exists()) {
    secretsFile.mkdirs()
}

if (!secretsFile.exists()) {
    secretsFile.withWriterAppend { w ->
        w << "\n"
    }
}

buildProperties {
    secrets {
        using(file('secrets.properties')).or(System.getenv()).or([
                "GITHUB_USER" : "RakSrinaNa",
                "GITHUB_TOKEN": "N/A"
        ])
    }
}

group = 'fr.raksrinana'
description = 'RSNDiscord'
sourceCompatibility = targetCompatibility = JavaVersion.VERSION_14

mainClassName = project.mainClass

dependencies {
    implementation("net.dv8tion:JDA:${project.JDA_version}") {
        exclude module: 'opus-java'
    }
    implementation("com.sedmelluq:lavaplayer:${project.lavaplayer_version}")
    implementation("com.github.natanbc:lavaplayer-arm-natives:${project.lavaplayer_arm_version}")

    implementation("org.slf4j:slf4j-api:${project.slf4j_version}")
    implementation("ch.qos.logback:logback-classic:${project.logback_version}") {
        exclude group: 'edu.washington.cs.types.checker', module: 'checker-framework'
    }
    implementation("fr.raksrinana:utils.http:${project.raksrinana_utils_version}")

    implementation("com.beust:jcommander:${project.jcommander_version}")
    implementation("com.fasterxml.jackson.core:jackson-core:${project.jackson_version}")
    implementation("com.fasterxml.jackson.core:jackson-annotations:${project.jackson_version}")
    implementation("com.fasterxml.jackson.core:jackson-databind:${project.jackson_version}")
    implementation("org.apache.httpcomponents:httpclient:${project.httpclient_version}")
    implementation("org.apache.commons:commons-lang3:${project.lang3_version}")
    implementation("org.reflections:reflections:${project.reflections_version}")
    implementation("com.vdurmont:emoji-java:${project.emoji_java_version}")
    implementation("org.imgscalr:imgscalr-lib:${project.imgscalr_version}")
}

repositories {
    maven {
        url = 'https://repo.maven.apache.org/maven2'
    }
    maven {
        url = 'https://jcenter.bintray.com'
    }
    maven {
        url = 'https://maven.pkg.github.com/RakSrinaNa/JavaUtils/'
        credentials {
            username buildProperties.secrets['GITHUB_USER'].string
            password buildProperties.secrets['GITHUB_TOKEN'].string
        }
    }
}

import org.apache.tools.ant.filters.ReplaceTokens

processResources {
    doFirst {
        from 'src/main/resources'
        filter(ReplaceTokens, tokens: [project_version: project.version, project_name: project.name])
    }
}

compileJava {
    inputs.property("moduleName", moduleName)
    doFirst {
        options.compilerArgs = [
                '--module-path', classpath.asPath,
        ]
        classpath = files()
    }
}

test {
    useJUnitPlatform()
}

application {
    mainModule = project.moduleName
    mainClass = project.mainClass
}

java {
    modularity.inferModulePath.set(true)
}

shadowJar {
    archivesBaseName = project.name
    classifier = 'shaded'
    archiveVersion = ''
}

tasks.withType(JavaCompile) {
    options.encoding = 'UTF-8'
    options.deprecation = true
}

tasks.withType(Wrapper) {
    gradleVersion = project.wrapper_version
}
plugins {
    id 'java'
}

tasks.withType(Wrapper) {
    gradleVersion = project.wrapper_version
}