Groovy 编译失败:无法加载 class 'org.grails.io.support.Resource'
Groovy compilation fails: Unable to load class 'org.grails.io.support.Resource'
我正在开发一个用 Groovy 编写并使用 Gradle 的 JavaFX 应用程序。当我最近在 IntelliJ 中启动我的应用程序时,它似乎突然开始无法编译并出现错误:
Unable to load class 'org.grails.io.support.Resource'.
This is an unexpected error. Please file a bug containing the idea.log file.
这来自 运行宁“运行”gradle 任务。
这是我的构建文件:
plugins {
id 'groovy'
id 'application'
id 'org.openjfx.javafxplugin' version '0.0.7'
}
group 'redacted'
version '1.0-SNAPSHOT'
repositories {
mavenCentral()
maven { url "https://m2proxy.atlassian.com/repository/public" } // Atlassian repository
maven { url "https://maven.atlassian.com/content/repositories/atlassian-public/"} // Atlassian public
maven { url "https://download.java.net/maven/2/"}
}
dependencies {
implementation 'org.codehaus.groovy:groovy-all:3.0.5'
// Logback log-annotation
implementation group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.6'
// https://mvnrepository.com/artifact/org.controlsfx/controlsfx
implementation group: 'org.controlsfx', name: 'controlsfx', version: '11.1.0'
testImplementation 'org.spockframework:spock-core:2.0-groovy-3.0'
// ---- GPars concurrency lib ----
// https://mvnrepository.com/artifact/org.codehaus.gpars/gpars
implementation group: 'org.codehaus.gpars', name: 'gpars', version: '1.2.1'
// ---- Jira Client ----
// https://mvnrepository.com/artifact/com.atlassian.jira/jira-rest-java-client-app
implementation group: 'com.atlassian.jira', name: 'jira-rest-java-client-app', version: '5.2.0'
// https://mvnrepository.com/artifact/com.atlassian.jira/jira-rest-java-client-api
implementation group: 'com.atlassian.jira', name: 'jira-rest-java-client-api', version: '5.2.0'
// ---- Misc ----
// https://mvnrepository.com/artifact/io.github.cdimascio/java-dotenv
implementation group: 'io.github.cdimascio', name: 'java-dotenv', version: '5.2.2'
// https://mvnrepository.com/artifact/org.jsoup/jsoup
implementation group: 'org.jsoup', name: 'jsoup', version: '1.14.3'
// ---- REST ----
// https://mvnrepository.com/artifact/org.springframework/spring-web
implementation group: 'org.springframework', name: 'spring-web', version: '3.0.2.RELEASE'
// https://mvnrepository.com/artifact/org.grails/grails-datastore-rest-client
implementation group: 'org.grails', name: 'grails-datastore-rest-client', version: '6.1.9.RELEASE'
// https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api
implementation group: 'javax.servlet', name: 'javax.servlet-api', version: '4.0.1'
// https://mvnrepository.com/artifact/net.dongliu/requests
implementation group: 'net.dongliu', name: 'requests', version: '5.0.8'
// https://mvnrepository.com/artifact/io.jsondb/jsondb-core
implementation group: 'io.jsondb', name: 'jsondb-core', version: '1.0.115-j11'
}
test {
useJUnitPlatform()
}
javafx {
modules = ['javafx.controls', 'javafx.fxml']
version = '11.0.2'
}
mainClassName = 'redacted'
有人以前看过这个吗?我尝试过的事情:
- 使 IntelliJ 中的缓存失效
- 清理 + 重建
- 将代码回滚到我知道已编译的点。
- 更新 gradlew 以使用 gradle 7.4
更新
我好像找到罪魁祸首了。我的公司最近更改了与我们如何构建项目相关的内容,这需要使用 .gradle/ 文件夹中的 init.gradle
文件,其中包含一些标准存储库定义。这是内容(已编辑公司存储库):
allprojects {
apply plugin: 'java'
apply plugin: 'maven-publish'
buildscript {
repositories {
maven {
url "https://<redacted>"
credentials {
username mavenUser
password mavenPassword
}
}
}
}
repositories {
mavenLocal()
maven {
url "https://<redacted>"
credentials {
username mavenUser
password mavenPassword
}
}
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
}
repositories {
maven {
credentials {
username mavenUser
password mavenPassword
}
url "https://<redacted>"
}
}
}
}
删除它解决了相关项目的问题,但显然不适用于所有其他与工作相关的项目。所以问题依然存在……这怎么会导致这样的错误?
更新 2
我还没有完全找到错误的根源,但似乎与以错误的方式声明的存储库有关。 要解决此问题,可以在存储库定义 顶部的项目 build.gradle
文件中调用 clear()
,有效地忽略 init.gradle
中声明的内容。因此,只需将 repositories {}
子句更新为:
repositories {
clear() // This is needed in order for init.gradle to not cause errors
mavenCentral()
maven { url "https://m2proxy.atlassian.com/repository/public" } // Atlassian repository
maven { url "https://maven.atlassian.com/content/repositories/atlassian-public/"} // Atlassian public
maven { url "https://download.java.net/maven/2/"}
}
我还没有完全找到错误的根源,但似乎与以错误的方式声明的存储库有关。要解决此问题,可以在存储库定义顶部的项目 build.gradle
文件中调用 clear()
,有效地忽略 init.gradle 中声明的内容。因此,只需将存储库闭包更新为:
repositories {
clear() // This is needed in order for init.gradle to not cause errors
mavenCentral()
maven { url "https://m2proxy.atlassian.com/repository/public" } // Atlassian repository
maven { url "https://maven.atlassian.com/content/repositories/atlassian-public/"} // Atlassian public
maven { url "https://download.java.net/maven/2/"}
}
我正在开发一个用 Groovy 编写并使用 Gradle 的 JavaFX 应用程序。当我最近在 IntelliJ 中启动我的应用程序时,它似乎突然开始无法编译并出现错误:
Unable to load class 'org.grails.io.support.Resource'.
This is an unexpected error. Please file a bug containing the idea.log file.
这来自 运行宁“运行”gradle 任务。
这是我的构建文件:
plugins {
id 'groovy'
id 'application'
id 'org.openjfx.javafxplugin' version '0.0.7'
}
group 'redacted'
version '1.0-SNAPSHOT'
repositories {
mavenCentral()
maven { url "https://m2proxy.atlassian.com/repository/public" } // Atlassian repository
maven { url "https://maven.atlassian.com/content/repositories/atlassian-public/"} // Atlassian public
maven { url "https://download.java.net/maven/2/"}
}
dependencies {
implementation 'org.codehaus.groovy:groovy-all:3.0.5'
// Logback log-annotation
implementation group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.6'
// https://mvnrepository.com/artifact/org.controlsfx/controlsfx
implementation group: 'org.controlsfx', name: 'controlsfx', version: '11.1.0'
testImplementation 'org.spockframework:spock-core:2.0-groovy-3.0'
// ---- GPars concurrency lib ----
// https://mvnrepository.com/artifact/org.codehaus.gpars/gpars
implementation group: 'org.codehaus.gpars', name: 'gpars', version: '1.2.1'
// ---- Jira Client ----
// https://mvnrepository.com/artifact/com.atlassian.jira/jira-rest-java-client-app
implementation group: 'com.atlassian.jira', name: 'jira-rest-java-client-app', version: '5.2.0'
// https://mvnrepository.com/artifact/com.atlassian.jira/jira-rest-java-client-api
implementation group: 'com.atlassian.jira', name: 'jira-rest-java-client-api', version: '5.2.0'
// ---- Misc ----
// https://mvnrepository.com/artifact/io.github.cdimascio/java-dotenv
implementation group: 'io.github.cdimascio', name: 'java-dotenv', version: '5.2.2'
// https://mvnrepository.com/artifact/org.jsoup/jsoup
implementation group: 'org.jsoup', name: 'jsoup', version: '1.14.3'
// ---- REST ----
// https://mvnrepository.com/artifact/org.springframework/spring-web
implementation group: 'org.springframework', name: 'spring-web', version: '3.0.2.RELEASE'
// https://mvnrepository.com/artifact/org.grails/grails-datastore-rest-client
implementation group: 'org.grails', name: 'grails-datastore-rest-client', version: '6.1.9.RELEASE'
// https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api
implementation group: 'javax.servlet', name: 'javax.servlet-api', version: '4.0.1'
// https://mvnrepository.com/artifact/net.dongliu/requests
implementation group: 'net.dongliu', name: 'requests', version: '5.0.8'
// https://mvnrepository.com/artifact/io.jsondb/jsondb-core
implementation group: 'io.jsondb', name: 'jsondb-core', version: '1.0.115-j11'
}
test {
useJUnitPlatform()
}
javafx {
modules = ['javafx.controls', 'javafx.fxml']
version = '11.0.2'
}
mainClassName = 'redacted'
有人以前看过这个吗?我尝试过的事情:
- 使 IntelliJ 中的缓存失效
- 清理 + 重建
- 将代码回滚到我知道已编译的点。
- 更新 gradlew 以使用 gradle 7.4
更新
我好像找到罪魁祸首了。我的公司最近更改了与我们如何构建项目相关的内容,这需要使用 .gradle/ 文件夹中的 init.gradle
文件,其中包含一些标准存储库定义。这是内容(已编辑公司存储库):
allprojects {
apply plugin: 'java'
apply plugin: 'maven-publish'
buildscript {
repositories {
maven {
url "https://<redacted>"
credentials {
username mavenUser
password mavenPassword
}
}
}
}
repositories {
mavenLocal()
maven {
url "https://<redacted>"
credentials {
username mavenUser
password mavenPassword
}
}
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
}
repositories {
maven {
credentials {
username mavenUser
password mavenPassword
}
url "https://<redacted>"
}
}
}
}
删除它解决了相关项目的问题,但显然不适用于所有其他与工作相关的项目。所以问题依然存在……这怎么会导致这样的错误?
更新 2
我还没有完全找到错误的根源,但似乎与以错误的方式声明的存储库有关。 要解决此问题,可以在存储库定义 顶部的项目 build.gradle
文件中调用 clear()
,有效地忽略 init.gradle
中声明的内容。因此,只需将 repositories {}
子句更新为:
repositories {
clear() // This is needed in order for init.gradle to not cause errors
mavenCentral()
maven { url "https://m2proxy.atlassian.com/repository/public" } // Atlassian repository
maven { url "https://maven.atlassian.com/content/repositories/atlassian-public/"} // Atlassian public
maven { url "https://download.java.net/maven/2/"}
}
我还没有完全找到错误的根源,但似乎与以错误的方式声明的存储库有关。要解决此问题,可以在存储库定义顶部的项目 build.gradle
文件中调用 clear()
,有效地忽略 init.gradle 中声明的内容。因此,只需将存储库闭包更新为:
repositories {
clear() // This is needed in order for init.gradle to not cause errors
mavenCentral()
maven { url "https://m2proxy.atlassian.com/repository/public" } // Atlassian repository
maven { url "https://maven.atlassian.com/content/repositories/atlassian-public/"} // Atlassian public
maven { url "https://download.java.net/maven/2/"}
}