gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 04:05:02 53 4
gpt4 key购买 nike

当我尝试在 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 的前几行如下(我们可以看到导入失败):

import org.gradle.api.internal.project.ProjectInternal
import org.gradle.tooling.provider.model.ToolingModelBuilderRegistry
import org.gradle.util.GradleVersion
import org.jetbrains.plugins.gradle.tooling.internal.ExtraModelBuilder

import java.util.concurrent.CopyOnWriteArrayList

initscript {
dependencies {
classpath files(["F:/Programmes/Jetbrains/apps/IDEA-U/ch-0/202.5958.24.plugins/Kotlin/lib/kotlin-gradle-tooling.jar","F:/Programmes/Jetbrains/apps/IDEA-U/ch-0/202.5958.24/lib/util.jar","F:/Programmes/Jetbrains/apps/IDEA-U/ch-0/202.5958.24/plugins/Grails/lib/grails-gradle-tooling.jar","F:/Programmes/Jetbrains/apps/IDEA-U/ch-0/202.5958.24.plugins/Minecraft Development/lib/MinecraftDev-2020.2-1.4.1-gradle-tooling-extension.jar","F:/Programmes/Jetbrains/apps/IDEA-U/ch-0/202.5958.24/plugins/Grails/lib/grails-rt.jar","F:/Programmes/Jetbrains/apps/IDEA-U/ch-0/202.5958.24/plugins/gradle/lib/gradle-tooling-extension-impl.jar","F:/Programmes/Jetbrains/apps/IDEA-U/ch-0/202.5958.24/lib/gson-2.8.6.jar","F:/Programmes/Jetbrains/apps/IDEA-U/ch-0/202.5958.24.plugins/Kotlin/lib/kapt3-idea.jar","F:/Programmes/Jetbrains/apps/IDEA-U/ch-0/202.5958.24.plugins/Kotlin/lib/kotlin-plugin.jar","F:/Programmes/Jetbrains/apps/IDEA-U/ch-0/202.5958.24.plugins/Kotlin/lib/noarg-ide-plugin.jar","F:/Programmes/Jetbrains/apps/IDEA-U/ch-0/202.5958.24/lib/ion-java-1.5.2-2.jar","F:/Programmes/Jetbrains/apps/IDEA-U/ch-0/202.5958.24.plugins/Kotlin/lib/allopen-ide-plugin.jar","F:/Programmes/Jetbrains/apps/IDEA-U/ch-0/202.5958.24/lib/external-system-rt.jar","F:/Programmes/Jetbrains/apps/IDEA-U/ch-0/202.5958.24.plugins/Kotlin/lib/sam-with-receiver-ide-plugin.jar","F:/Programmes/Jetbrains/apps/IDEA-U/ch-0/202.5958.24/plugins/gradle-ext/lib/gradle-ext-profiler-tooling.jar","F:/Programmes/Jetbrains/apps/IDEA-U/ch-0/202.5958.24/lib/kotlin-stdlib-1.3.70.jar","F:/Programmes/Jetbrains/apps/IDEA-U/ch-0/202.5958.24/lib/trove4j.jar","F:/Programmes/Jetbrains/apps/IDEA-U/ch-0/202.5958.24/plugins/gradle/lib/gradle-tooling-extension-api.jar","F:/Programmes/Jetbrains/apps/IDEA-U/ch-0/202.5958.24/plugins/gradle/lib/gradle-api-impldep-6.5.jar"])
}
}

apply plugin: JetGradlePlugin
[...]

是我当前的 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
}

尽管尝试使用下面的代码也会出现相同的错误:

plugins {
id 'java'
}

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

编辑2:在 JB 端打开了一个问题 https://youtrack.jetbrains.com/issue/IDEA-245303

最佳答案

我在最新版本的所有东西中遇到了这个确切的问题——gradle 插件 4.1.2 和 Gradle 版本 6.5。我在 C 上安装了 Windows 操作系统,并在可移植硬盘驱动器上全新安装了 Android Studio(内置 intellij)。该项目也在移动硬盘上。

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

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

关于gradle - 使用 IJ 和 Gradle 6.5 重新加载项目时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62660782/

53 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com