Gradle 8.1.1 - 出了什么问题:“java.io.File org.gradle.api.reporting.ConfigurableReport.getDestination()”

NOT*_*iFY 12 macos homebrew gradle build.gradle

我已在 macOS Ventura 13.2.1 上使用 openjdk 版本“19.0.2”2023-01-17 使用(Home)brew 从 Gradle 7.6 升级到 8.0。

\n
gradle build clean\n\nFAILURE: Build failed with an exception.\n\n* What went wrong:\n'java.io.File org.gradle.api.reporting.ConfigurableReport.getDestination()'\n\n* Try:\n> Run with --stacktrace option to get the stack trace.\n> Run with --info or --debug option to get more log output.\n> Run with --scan to get full insights.\n
Run Code Online (Sandbox Code Playgroud)\n

gradle 构建干净--扫描:

\n
Started today at 08:04:46 GMT, finished today at 08:04:51 GMT\nGradle 8.0,Gradle Enterprise plugin 3.12.3\nExplore console log\n1 failure\n'java.io.File org.gradle.api.reporting.ConfigurableReport.getDestination()'\n'java.io.File org.gradle.api.reporting.ConfigurableReport.getDestination()'\n
Run Code Online (Sandbox Code Playgroud)\n

探索失败:

\n
Failure 1 of 1'java.io.File org.gradle.api.reporting.ConfigurableReport.getDestination()'\n'java.io.File org.gradle.api.reporting.ConfigurableReport.getDestination()'\nException\njava.lang.NoSuchMethodError: 'java.io.File org.gradle.api.reporting.ConfigurableReport.getDestination()'    \nat name.remal.gradle_plugins.dsl.extensions.Org_gradle_api_reporting_ConfigurableReportKt.setDefaultDestinationForTask(org.gradle.api.reporting.ConfigurableReport.kt:63)   \nat name.remal.gradle_plugins.plugins.common.ReportsSettingsPlugin$Setup all tasks with reports$1$1.execute(ReportsSettingsPlugin.kt:24) \nat name.remal.gradle_plugins.plugins.common.ReportsSettingsPlugin$Setup all tasks with reports$1$1.execute(ReportsSettingsPlugin.kt:16) \n\xe2\x80\xa2\xe2\x80\xa2\xe2\x80\xa2\nat name.remal.gradle_plugins.plugins.common.ReportsSettingsPlugin$Setup all tasks with reports$1.execute(ReportsSettingsPlugin.kt:22)   \nat name.remal.gradle_plugins.plugins.common.ReportsSettingsPlugin$Setup all tasks with reports$1.execute(ReportsSettingsPlugin.kt:16)   \n\xe2\x80\xa2\xe2\x80\xa2\xe2\x80\xa2\nat name.remal.gradle_plugins.plugins.common.ReportsSettingsPlugin.Setup all tasks with reports(ReportsSettingsPlugin.kt:20) \n\xe2\x80\xa2\xe2\x80\xa2\xe2\x80\xa2\nat name.remal.gradle_plugins.dsl.extensions.Java_lang_reflect_MethodKt.invokeForInstance(java.lang.reflect.Method.kt:21)    \nat name.remal.gradle_plugins.dsl.reflective_project_plugin.action_param_injector.ExtensionsKt.invokeForProject(extensions.kt:15)    \nat name.remal.gradle_plugins.dsl.reflective_project_plugin.action_param_injector.ExtensionsKt.invoke(extensions.kt:23)  \nat name.remal.gradle_plugins.dsl.BaseReflectiveProjectPlugin$doActions$1$7.invoke(BaseReflectiveProjectPlugin.kt:103)   \nat name.remal.gradle_plugins.dsl.BaseReflectiveProjectPlugin$doActions$1$7.invoke(BaseReflectiveProjectPlugin.kt:19)    \nat name.remal.gradle_plugins.dsl.extensions.Org_gradle_api_plugins_PluginManagerKt.withPluginIds(org.gradle.api.plugins.PluginManager.kt:67)    \nat name.remal.gradle_plugins.dsl.extensions.Org_gradle_api_ProjectKt.withPluginIds(org.gradle.api.Project.kt:193)   \nat name.remal.gradle_plugins.dsl.BaseReflectiveProjectPlugin$doActions$1.invoke(BaseReflectiveProjectPlugin.kt:88)  \nat name.remal.gradle_plugins.dsl.BaseReflectiveProjectPlugin$doActions$1.invoke(BaseReflectiveProjectPlugin.kt:19)  \nat name.remal.gradle_plugins.dsl.extensions.Org_gradle_api_plugins_PluginManagerKt.withPluginIds(org.gradle.api.plugins.PluginManager.kt:67)    \nat name.remal.gradle_plugins.dsl.extensions.Org_gradle_api_ProjectKt.withPluginIds(org.gradle.api.Project.kt:193)   \nat name.remal.gradle_plugins.dsl.BaseReflectiveProjectPlugin.doActions(BaseReflectiveProjectPlugin.kt:67)   \nat name.remal.gradle_plugins.dsl.BaseReflectiveProjectPlugin.applyImpl(BaseReflectiveProjectPlugin.kt:43)   \nat name.remal.gradle_plugins.dsl.BaseProjectPlugin.apply(BaseProjectPlugin.kt:57)   \nat name.remal.gradle_plugins.dsl.BaseProjectPlugin.apply(BaseProjectPlugin.kt:23)   \n\xe2\x80\xa2\xe2\x80\xa2\xe2\x80\xa2\nat name.remal.gradle_plugins.dsl.extensions.Org_gradle_api_ProjectKt.applyPlugin(org.gradle.api.Project.kt:195) \nat name.remal.gradle_plugins.dsl.BaseReflectiveProjectPlugin$doActions$1.invoke(BaseReflectiveProjectPlugin.kt:69)  \nat name.remal.gradle_plugins.dsl.BaseReflectiveProjectPlugin$doActions$1.invoke(BaseReflectiveProjectPlugin.kt:19)  \nat name.remal.gradle_plugins.dsl.extensions.Org_gradle_api_plugins_PluginManagerKt.withPluginIds(org.gradle.api.plugins.PluginManager.kt:67)    \nat name.remal.gradle_plugins.dsl.extensions.Org_gradle_api_ProjectKt.withPluginIds(org.gradle.api.Project.kt:193)   \nat name.remal.gradle_plugins.dsl.BaseReflectiveProjectPlugin.doActions(BaseReflectiveProjectPlugin.kt:67)   \nat name.remal.gradle_plugins.dsl.BaseReflectiveProjectPlugin.applyImpl(BaseReflectiveProjectPlugin.kt:43)   \nat name.remal.gradle_plugins.dsl.BaseProjectPlugin.apply(BaseProjectPlugin.kt:57)   \nat name.remal.gradle_plugins.dsl.BaseProjectPlugin.apply(BaseProjectPlugin.kt:23)   \n\xe2\x80\xa2\xe2\x80\xa2\xe2\x80\xa2\n
Run Code Online (Sandbox Code Playgroud)\n

移回 Gradle 7.6:

\n
/gradlew build clean --warning-mode=all\n\n> Configure project :\nThe Report.destination property has been deprecated. This is scheduled to be removed in Gradle 8.0. Please use the outputLocation property instead. See https://docs.gradle.org/7.6/dsl/org.gradle.api.reporting.Report.html#org.gradle.api.reporting.Report:destination for more details.\nThe Report.enabled property has been deprecated. This is scheduled to be removed in Gradle 8.0. Please use the required property instead. See https://docs.gradle.org/7.6/dsl/org.gradle.api.reporting.Report.html#org.gradle.api.reporting.Report:enabled for more details.\n>>>>> 1 deleteFiles\n>>>>> 2 NOTiFYmotoWAR\nThe AbstractArchiveTask.archiveName property has been deprecated. This is scheduled to be removed in Gradle 8.0. Please use the archiveFileName property instead. See https://docs.gradle.org/7.6/dsl/org.gradle.api.tasks.bundling.AbstractArchiveTask.html#org.gradle.api.tasks.bundling.AbstractArchiveTask:archiveName for more details.\n        at build_6fdw9omce69ijjc1fgog2e4q0$_run_closure13.doCall(/Users/NOTiFY/IdeaProjects/NOTiFYmoto/build.gradle:265)\n        (Run with --stacktrace to get the full stack trace of this deprecation warning.)\n>>>>> 3 NOTiFYmotoJAR\n>>>>> 4 copyNOTiFYmotoWAR\n>>>>> 5 copyNOTiFYmotoJAR\n>>>>> 6 NOTiFYmotoEAR\n
Run Code Online (Sandbox Code Playgroud)\n

我的摇篮:

\n
plugins {\n    id("war")\n    id("ear")\n    id("idea")\n    id("java-library")\n\n    id("org.jetbrains.kotlin.jvm") version "1.8.10"\n\n    id("checkstyle")\n    id("pmd")\n\n    id("com.github.spotbugs") version "5.0.13"\n\n    id("org.sonarqube") version "3.5.0.2730"\n    id("name.remal.sonarlint") version "1.5.0"\n    id("org.wildfly.build.provision") version "0.0.11"\n}\n\nconfigurations.all {\n    resolutionStrategy {\n        //force 'xml-apis:xml-apis:1.0.b2'\n        force 'xml-apis:xml-apis:2.0.2'\n    }\n}\n\ncompileJava {\n    sourceCompatibility = '1.8'\n    targetCompatibility = '1.8'\n}\n\nrepositories {\n    mavenLocal()\n    mavenCentral()\n    google()\n    maven {\n        name "jboss-nexus"\n        url "http://repository.jboss.org/nexus/content/groups/public/"\n        url "https://repository.jboss.org/nexus/content/groups/public-jboss"\n        url "https://repository.jboss.org/nexus/content/repositories"\n        url "https://repository.jboss.org/nexus/content/repositories/thirdparty-releases"\n        url "https://repository.primefaces.org"\n    }\n\n    //jcenter()\n    gradlePluginPortal()\n    mavenCentral()\n\n    flatDir {\n        dirs "lib"\n    }\n}\n\ndependencies {\n    compileOnly("jakarta.platform:jakarta.jakartaee-api:10.0.0")\n\n    implementation("jakarta.platform:jakarta.jakartaee-web-api:10.0.0")\n\n    // JUnit (Jupiter) 5.9.0)\n    testImplementation('org.junit.jupiter:junit-jupiter-api:5.9.2')\n    testImplementation('org.junit.jupiter:junit-jupiter-engine:5.9.2')\n    testImplementation('org.junit.vintage:junit-vintage-engine:5.9.2')\n    testImplementation("org.testng:testng:7.7.0")\n\n    implementation("org.apache.maven.surefire:surefire-testng:2.22.2")\n    implementation("org.slf4j:slf4j-api:2.0.5")\n    implementation("org.slf4j:slf4j-simple:2.0.5")\n\n    implementation('com.puppycrawl.tools:checkstyle:10.7.0')\n    implementation("dev.morphia.morphia:morphia-core:2.3.0")\n\n    // Omnifaces 4.0.1 - November 2022\n    implementation("org.omnifaces:omnifaces:4.0.1")\n\n    implementation("org.primefaces:primefaces-12.0.3-jakarta")\n    implementation("org.primefaces.themes:bootstrap:1.0.10")\n\n    // BootsFaces\n    implementation("net.bootsfaces:bootsfaces:1.5.0")\n\n    implementation("org.mongodb:mongodb-driver-core:4.8.2")\n    implementation("org.mongodb:mongodb-driver-sync:4.8.2")\n    implementation("org.mongodb:bson:4.8.2")\n\n    implementation('io.github.classgraph:classgraph:4.8.154')\n    implementation('net.bytebuddy:byte-buddy:1.12.21')\n\n    implementation('com.google.code.gson:gson:2.10.1')\n\n    // Kotlin - 2022-12-28\n    implementation('org.jetbrains.kotlin:kotlin-stdlib:1.8.10')\n\n    implementation("org.jsoup:jsoup:1.15.3")\n\n    providedCompile("org.eclipse.persistence:javax.persistence:2.2.1")\n    providedCompile("javax.inject:javax.inject:1")\n    providedCompile("javax.faces:javax.faces-api:2.3")\n    providedCompile("jakarta.enterprise:jakarta.enterprise.cdi-api:4.0.1")\n    providedCompile("org.jboss.resteasy:resteasy-jaxrs:3.15.3.Final")\n    providedCompile('com.google.code.gson:gson:2.10.1')\n    providedCompile("javax.ws.rs:javax.ws.rs-api:2.1.1")\n    providedCompile("org.slf4j:slf4j-api:2.0.5")\n    providedCompile("org.slf4j:slf4j-simple:2.0.5")\n    spotbugsPlugins("com.h3xstream.findsecbugs:findsecbugs-plugin:1.12.0")\n}\n\ncheckstyleMain {\n    source = ["src/main/java"]\n}\n\ncheckstyle {\n    toolVersion "10.7.0"\n    configFile = file("config/checkstyle/checkstyle.xml")\n}\n\nspotbugs {\n    ignoreFailures = true\n    toolVersion = '4.7.3'\n\n    reportsDir = file("reports/spotbugs")\n    effort = "max"\n    reportLevel = "high"\n\n//     ignoreFailures = false\n    showProgress = true\n//     showStackTraces = false\n//     effort = "default"\n//     reportLevel = "default"\n//     visitors = [ "FindSqlInjection", "SwitchFallthrough" tVisitors = [ "FindNonShortCircuit" ]\n//     reportsDir = filef("$buildDir/\xc6\x92prime")\n//     includeFilter = file("include.xml")\n//     excludeFilter = file("exclude.xml")\n//     onlyAnalyze = [ "com.foobar.MyClass", "com.foobar.mypkg.*" ]\n//     maxHeapSize = "1g"\n//     extraArgs = [ "-nested:false" ]\n//     jvmArgs = [ "-Duser.language=ja" ]\n}\n\npmd {\n    ignoreFailures = true\n    reportsDir = file("reports/pmd")\n    ruleSets = [\n            "java-basic",\n            "java-braces",\n            "java-clone",\n            "java-codesize",\n            "java-comments",\n            "java-controversial",\n            "java-coupling",\n            "java-design",\n            "java-empty",\n            "java-finalizers",\n            "java-imports",\n            "java-optimizations",\n            "java-strictexception",\n            "java-strings",\n            "java-typeresolution",\n            "java-unnecessary",\n            "java-unusedcode"\n    ]\n}\n\n// SonarLint & SonarQube\nsonarlint {\n    ignoreFailures = true\n//    excludes {\n//        message 'java:S1214'\n//        message 'kotlin:S100'\n//        message 'xml:S125'\n//    }\n//    includes {\n//        message 'java:S4266' // Enable java:S4266 which is disabled by default\n//    }\n//    ruleParameter('java:S119', 'format', '^[A-Z][a-zA-Z0-9]*$') // Allow upper camel-case for type parameter names\n}\n\ntasks.withType(Pmd) {\n    reports {\n        xml.enabled = true\n        html.enabled = true\n    }\n}\n\ntasks.withType(Checkstyle) {\n    reports {\n        html.destination rootProject.file("reports/checkstyle/checkstyle.html")\n    }\n}\n\ntask deleteFiles(type: Delete) {\n    project.logger.lifecycle(">>>>> 1 deleteFiles")\n\n    delete fileTree("./build/libs") {\n        include "**/NOTiFYmoto*.?ar"\n    }\n\n    delete fileTree("./src/main/application") {\n        include "**/NOTiFYmoto*.war"\n        include "**/NOTiFYmoto*.jar"\n        include "**/NOTiFYmoto*.ear"\n    }\n}\n\ntask NOTiFYmotoWAR(type: War) {\n    project.logger.lifecycle(">>>>> 2 NOTiFYmotoWAR")\n\n    dependsOn deleteFiles\n\n    archiveName "NOTiFYmotoWAR.war"\n    //archiveFileName "NOTiFYmotoWAR.war"\n\n    //webInf {\n    //    from "WEB-INF"\n    //}\n\n    rootSpec.exclude("**/dto/*")\n    rootSpec.exclude("**/ean/*")\n    rootSpec.exclude("**/ejb/*")\n    rootSpec.exclude("**/entity/*")\n    rootSpec.exclude("**/filter/*")\n    rootSpec.exclude("**/gson/*")\n\n    rootSpec.exclude("**/morphia-*.jar")\n    rootSpec.exclude("**/mongo*.jar")\n    rootSpec.exclude("**/bson*.jar")\n    rootSpec.exclude("**/surefire*.jar")\n\n    rootSpec.exclude("**/controller*/*")\n\n    // Exclude push PushEvent.class\n    rootSpec.exclude("**/push/PushEvent.class")\n\n    //rootSpec.exclude("**/layout/img/OmniFaces-icon-*")\n    rootSpec.exclude("**/webservices/*")\n\n    rootSpec.exclude("**/checkstyle*.jar")\n    rootSpec.exclude("**/classgraph*.jar")\n    rootSpec.exclude("**/kotlin*.jar")\n\n    rootSpec.exclude("**/NOTiFYmoto*.jar")\n    rootSpec.exclude("**/NOTiFYmoto*.war")\n\n}\n\ntask NOTiFYmotoJAR(type: Jar) {\n    project.logger.lifecycle(">>>>> 3 NOTiFYmotoJAR")\n\n    dependsOn NOTiFYmotoWAR\n\n    archiveName "NOTiFYmotoJAR.jar"\n//    archiveFileName "NOTiFYmotoJAR.jar"\n\n    from("./src/main/java") {\n        include "META-INF/**"\n    }\n\n    // Exclude\n    rootSpec.exclude("**/jsf/SliderViewBean.class")\n    rootSpec.exclude("**/push/PushBean.class")\n\n    from("./build/classes/java/main") {\n        include "*/**"\n    }\n\n    // Kotlin\n    from("./build/classes/kotlin/main") {\n        include "*/**"\n    }\n}\n\ntask copyNOTiFYmotoWAR(type: Copy) {\n    project.logger.lifecycle(">>>>> 4 copyNOTiFYmotoWAR")\n\n    dependsOn NOTiFYmotoJAR\n\n    from file("./build/libs/NOTiFYmotoWAR.war")\n    into file("./src/main/application")\n}\n\ntask copyNOTiFYmotoJAR(type: Copy) {\n    project.logger.lifecycle(">>>>> 5 copyNOTiFYmotoJAR")\n\n    dependsOn copyNOTiFYmotoWAR\n\n    from file("./build/libs/NOTiFYmotoJAR.jar")\n    into file("./src/main/application")\n}\n\ntask NOTiFYmotoEAR(type: Ear) {\n    project.logger.lifecycle(">>>>> 6 NOTiFYmotoEAR")\n\n    apply plugin: "ear"\n\n    //compileOnly("org.omnifaces:omnifaces:4.0.1")\n\n    dependsOn copyNOTiFYmotoJAR\n\n    archiveName "NOTiFYmoto.ear"\n//    archiveFileName "NOTiFYmoto.ear"\n\n    manifest {\n        from("./src/main/resources/META-INF/MANIFEST.MF")\n    }\n\n    exclude "**/*.class"\n    exclude "**/asm-Java.jar"\n    exclude "**/jboss-deployment-structure.xml"\n\n//    exclude("**/beans.xml")\n\n    dependencies {\n        earlib group: "com.google.code.gson", name: "gson", version: "2.10", ext: "jar"\n        earlib group: "org.apache.httpcomponents", name: "httpclient", version: "4.5.13", ext: "jar"\n        earlib group: "org.apache.httpcomponents", name: "httpcore", version: "4.4.14", ext: "jar"\n        earlib group: "org.jetbrains.kotlin", name: "kotlin-stdlib", version: "1.8.10", ext: "jar"\n\n        earlib group: "dev.morphia.morphia", name: "morphia-core", version: "2.3.0", ext: "jar"\n\n        earlib group: "org.mongodb", name: "mongodb-driver-core", version: "4.8.2", ext: "jar"\n        earlib group: "org.mongodb", name: "mongodb-driver-sync", version: "4.8.2", ext: "jar"\n        earlib group: "org.mongodb", name: "bson", version: "4.8.2", ext: "jar"\n\n        earlib group: "net.bytebuddy", name: "byte-buddy", version: "1.12.17", ext: "jar"\n\n        earlib group: "io.github.classgraph", name: "classgraph", version: "4.8.153"\n\n        spotbugsPlugins("com.h3xstream.findsecbugs:findsecbugs-plugin:1.12.0")\n    }\n}\n
Run Code Online (Sandbox Code Playgroud)\n

有什么建议么?TIA

\n

Her*_*ond 29

对于那些在 SonarQube 任务期间遇到类似问题的人:

Unable to find method ''java.io.File org.gradle.api.tasks.testing.JUnitXmlReport.getDestination()''
'java.io.Fileorg.gradle.api.tasks.testing.JUnitXmlReport.getDestination()'
Run Code Online (Sandbox Code Playgroud)

就我而言,根本原因是版本不兼容(Gradle 和 SonarQube 之间)。

我将Gradle版本升级到8.0.2,并抛出错误。阅读文档后,我发现 Gradle 8.0.x 版本有一个新的兼容 SonarQube 版本。升级 SonarQube 版本后,4.0.0.2929它再次开始正常工作。

您可以在这里找到更多信息:

  • 非常适合我。唯一的变化是我升级到了“4.2.0.3129”。 (3认同)

djm*_*nki 7

以下是将 build.gradle 文件上已弃用的报告属性从 Gradle 7.xx 迁移到 8.0.0 的示例:

摇篮 7.xx


jacoco {
    toolVersion = "0.8.6"
    reportsDirectory = file("$buildDir/customJacocoReportDir")
}

jacocoTestReport {
    reports {
        xml.enabled false
        csv.enabled true
        html.destination file("${buildDir}/reports/html/jacoco")
    }
}
Run Code Online (Sandbox Code Playgroud)

摇篮8.0.0

jacoco {
    toolVersion = "0.8.8"
    reportsDirectory = layout.buildDirectory.dir('customJacocoReportDir')
}

jacocoTestReport {
    reports {
        xml.required = false
        csv.required = true
        html.outputLocation = layout.buildDirectory.dir('jacocoHtml')
    }
}
Run Code Online (Sandbox Code Playgroud)

因此,关于问题中的 build.gradle,它将从以下位置迁移:

当前的

tasks.withType(Pmd) {
    reports {
        xml.enabled = true
        html.enabled = true
    }
}

tasks.withType(Checkstyle) {
    reports {
        html.destination rootProject.file("reports/checkstyle/checkstyle.html")
    }
}
Run Code Online (Sandbox Code Playgroud)

新的

tasks.withType(Pmd) {
    reports {
        xml.required = true
        html.required = true
    }
}

tasks.withType(Checkstyle) {
    reports {
        html.outputLocation = rootProject.file('reports/checkstyle/checkstyle.html')
    }
}
Run Code Online (Sandbox Code Playgroud)

  • 完全无关的答案。刚刚被熟人添加为“有用”。 (3认同)

NOT*_*iFY 2

实际阅读:https ://docs.gradle.org/current/userguide/upgrading_version_8.html

将我所有的“战争,罐子,耳朵”从:

archiveName "MyWAR.war" 
Run Code Online (Sandbox Code Playgroud)

到:

archiveFileName = "MyWAR.war"
Run Code Online (Sandbox Code Playgroud)

还需要在“构建”之前运行“停止”:

./gradlew --stop
./gradlew build clean 
Run Code Online (Sandbox Code Playgroud)