Gradle 8.1 -发生了什么问题:'java.io.File org.gradle.API.reporting.ConfigurableReport.getDestination()'

apeeds0o  于 2023-04-21  发布在  Java
关注(0)|答案(3)|浏览(264)

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

gradle build clean

FAILURE: Build failed with an exception.

* What went wrong:
'java.io.File org.gradle.api.reporting.ConfigurableReport.getDestination()'

* 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.

gradle build clean --scan:

Started today at 08:04:46 GMT, finished today at 08:04:51 GMT
Gradle 8.0,Gradle Enterprise plugin 3.12.3
Explore console log
1 failure
'java.io.File org.gradle.api.reporting.ConfigurableReport.getDestination()'
'java.io.File org.gradle.api.reporting.ConfigurableReport.getDestination()'

探索失败:

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

返回Gradle 7.6:

/gradlew build clean --warning-mode=all

> Configure project :
The 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.
The 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.
>>>>> 1 deleteFiles
>>>>> 2 NOTiFYmotoWAR
The 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.
        at build_6fdw9omce69ijjc1fgog2e4q0$_run_closure13.doCall(/Users/NOTiFY/IdeaProjects/NOTiFYmoto/build.gradle:265)
        (Run with --stacktrace to get the full stack trace of this deprecation warning.)
>>>>> 3 NOTiFYmotoJAR
>>>>> 4 copyNOTiFYmotoWAR
>>>>> 5 copyNOTiFYmotoJAR
>>>>> 6 NOTiFYmotoEAR

我的Gradle:

plugins {
    id("war")
    id("ear")
    id("idea")
    id("java-library")

    id("org.jetbrains.kotlin.jvm") version "1.8.10"

    id("checkstyle")
    id("pmd")

    id("com.github.spotbugs") version "5.0.13"

    id("org.sonarqube") version "3.5.0.2730"
    id("name.remal.sonarlint") version "1.5.0"
    id("org.wildfly.build.provision") version "0.0.11"
}

configurations.all {
    resolutionStrategy {
        //force 'xml-apis:xml-apis:1.0.b2'
        force 'xml-apis:xml-apis:2.0.2'
    }
}

compileJava {
    sourceCompatibility = '1.8'
    targetCompatibility = '1.8'
}

repositories {
    mavenLocal()
    mavenCentral()
    google()
    maven {
        name "jboss-nexus"
        url "http://repository.jboss.org/nexus/content/groups/public/"
        url "https://repository.jboss.org/nexus/content/groups/public-jboss"
        url "https://repository.jboss.org/nexus/content/repositories"
        url "https://repository.jboss.org/nexus/content/repositories/thirdparty-releases"
        url "https://repository.primefaces.org"
    }

    //jcenter()
    gradlePluginPortal()
    mavenCentral()

    flatDir {
        dirs "lib"
    }
}

dependencies {
    compileOnly("jakarta.platform:jakarta.jakartaee-api:10.0.0")

    implementation("jakarta.platform:jakarta.jakartaee-web-api:10.0.0")

    // JUnit (Jupiter) 5.9.0)
    testImplementation('org.junit.jupiter:junit-jupiter-api:5.9.2')
    testImplementation('org.junit.jupiter:junit-jupiter-engine:5.9.2')
    testImplementation('org.junit.vintage:junit-vintage-engine:5.9.2')
    testImplementation("org.testng:testng:7.7.0")

    implementation("org.apache.maven.surefire:surefire-testng:2.22.2")
    implementation("org.slf4j:slf4j-api:2.0.5")
    implementation("org.slf4j:slf4j-simple:2.0.5")

    implementation('com.puppycrawl.tools:checkstyle:10.7.0')
    implementation("dev.morphia.morphia:morphia-core:2.3.0")

    // Omnifaces 4.0.1 - November 2022
    implementation("org.omnifaces:omnifaces:4.0.1")

    implementation("org.primefaces:primefaces-12.0.3-jakarta")
    implementation("org.primefaces.themes:bootstrap:1.0.10")

    // BootsFaces
    implementation("net.bootsfaces:bootsfaces:1.5.0")

    implementation("org.mongodb:mongodb-driver-core:4.8.2")
    implementation("org.mongodb:mongodb-driver-sync:4.8.2")
    implementation("org.mongodb:bson:4.8.2")

    implementation('io.github.classgraph:classgraph:4.8.154')
    implementation('net.bytebuddy:byte-buddy:1.12.21')

    implementation('com.google.code.gson:gson:2.10.1')

    // Kotlin - 2022-12-28
    implementation('org.jetbrains.kotlin:kotlin-stdlib:1.8.10')

    implementation("org.jsoup:jsoup:1.15.3")

    providedCompile("org.eclipse.persistence:javax.persistence:2.2.1")
    providedCompile("javax.inject:javax.inject:1")
    providedCompile("javax.faces:javax.faces-api:2.3")
    providedCompile("jakarta.enterprise:jakarta.enterprise.cdi-api:4.0.1")
    providedCompile("org.jboss.resteasy:resteasy-jaxrs:3.15.3.Final")
    providedCompile('com.google.code.gson:gson:2.10.1')
    providedCompile("javax.ws.rs:javax.ws.rs-api:2.1.1")
    providedCompile("org.slf4j:slf4j-api:2.0.5")
    providedCompile("org.slf4j:slf4j-simple:2.0.5")
    spotbugsPlugins("com.h3xstream.findsecbugs:findsecbugs-plugin:1.12.0")
}

checkstyleMain {
    source = ["src/main/java"]
}

checkstyle {
    toolVersion "10.7.0"
    configFile = file("config/checkstyle/checkstyle.xml")
}

spotbugs {
    ignoreFailures = true
    toolVersion = '4.7.3'

    reportsDir = file("reports/spotbugs")
    effort = "max"
    reportLevel = "high"

//     ignoreFailures = false
    showProgress = true
//     showStackTraces = false
//     effort = "default"
//     reportLevel = "default"
//     visitors = [ "FindSqlInjection", "SwitchFallthrough" tVisitors = [ "FindNonShortCircuit" ]
//     reportsDir = filef("$buildDir/ƒprime")
//     includeFilter = file("include.xml")
//     excludeFilter = file("exclude.xml")
//     onlyAnalyze = [ "com.foobar.MyClass", "com.foobar.mypkg.*" ]
//     maxHeapSize = "1g"
//     extraArgs = [ "-nested:false" ]
//     jvmArgs = [ "-Duser.language=ja" ]
}

pmd {
    ignoreFailures = true
    reportsDir = file("reports/pmd")
    ruleSets = [
            "java-basic",
            "java-braces",
            "java-clone",
            "java-codesize",
            "java-comments",
            "java-controversial",
            "java-coupling",
            "java-design",
            "java-empty",
            "java-finalizers",
            "java-imports",
            "java-optimizations",
            "java-strictexception",
            "java-strings",
            "java-typeresolution",
            "java-unnecessary",
            "java-unusedcode"
    ]
}

// SonarLint & SonarQube
sonarlint {
    ignoreFailures = true
//    excludes {
//        message 'java:S1214'
//        message 'kotlin:S100'
//        message 'xml:S125'
//    }
//    includes {
//        message 'java:S4266' // Enable java:S4266 which is disabled by default
//    }
//    ruleParameter('java:S119', 'format', '^[A-Z][a-zA-Z0-9]*$') // Allow upper camel-case for type parameter names
}

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

tasks.withType(Checkstyle) {
    reports {
        html.destination rootProject.file("reports/checkstyle/checkstyle.html")
    }
}

task deleteFiles(type: Delete) {
    project.logger.lifecycle(">>>>> 1 deleteFiles")

    delete fileTree("./build/libs") {
        include "**/NOTiFYmoto*.?ar"
    }

    delete fileTree("./src/main/application") {
        include "**/NOTiFYmoto*.war"
        include "**/NOTiFYmoto*.jar"
        include "**/NOTiFYmoto*.ear"
    }
}

task NOTiFYmotoWAR(type: War) {
    project.logger.lifecycle(">>>>> 2 NOTiFYmotoWAR")

    dependsOn deleteFiles

    archiveName "NOTiFYmotoWAR.war"
    //archiveFileName "NOTiFYmotoWAR.war"

    //webInf {
    //    from "WEB-INF"
    //}

    rootSpec.exclude("**/dto/*")
    rootSpec.exclude("**/ean/*")
    rootSpec.exclude("**/ejb/*")
    rootSpec.exclude("**/entity/*")
    rootSpec.exclude("**/filter/*")
    rootSpec.exclude("**/gson/*")

    rootSpec.exclude("**/morphia-*.jar")
    rootSpec.exclude("**/mongo*.jar")
    rootSpec.exclude("**/bson*.jar")
    rootSpec.exclude("**/surefire*.jar")

    rootSpec.exclude("**/controller*/*")

    // Exclude push PushEvent.class
    rootSpec.exclude("**/push/PushEvent.class")

    //rootSpec.exclude("**/layout/img/OmniFaces-icon-*")
    rootSpec.exclude("**/webservices/*")

    rootSpec.exclude("**/checkstyle*.jar")
    rootSpec.exclude("**/classgraph*.jar")
    rootSpec.exclude("**/kotlin*.jar")

    rootSpec.exclude("**/NOTiFYmoto*.jar")
    rootSpec.exclude("**/NOTiFYmoto*.war")

}

task NOTiFYmotoJAR(type: Jar) {
    project.logger.lifecycle(">>>>> 3 NOTiFYmotoJAR")

    dependsOn NOTiFYmotoWAR

    archiveName "NOTiFYmotoJAR.jar"
//    archiveFileName "NOTiFYmotoJAR.jar"

    from("./src/main/java") {
        include "META-INF/**"
    }

    // Exclude
    rootSpec.exclude("**/jsf/SliderViewBean.class")
    rootSpec.exclude("**/push/PushBean.class")

    from("./build/classes/java/main") {
        include "*/**"
    }

    // Kotlin
    from("./build/classes/kotlin/main") {
        include "*/**"
    }
}

task copyNOTiFYmotoWAR(type: Copy) {
    project.logger.lifecycle(">>>>> 4 copyNOTiFYmotoWAR")

    dependsOn NOTiFYmotoJAR

    from file("./build/libs/NOTiFYmotoWAR.war")
    into file("./src/main/application")
}

task copyNOTiFYmotoJAR(type: Copy) {
    project.logger.lifecycle(">>>>> 5 copyNOTiFYmotoJAR")

    dependsOn copyNOTiFYmotoWAR

    from file("./build/libs/NOTiFYmotoJAR.jar")
    into file("./src/main/application")
}

task NOTiFYmotoEAR(type: Ear) {
    project.logger.lifecycle(">>>>> 6 NOTiFYmotoEAR")

    apply plugin: "ear"

    //compileOnly("org.omnifaces:omnifaces:4.0.1")

    dependsOn copyNOTiFYmotoJAR

    archiveName "NOTiFYmoto.ear"
//    archiveFileName "NOTiFYmoto.ear"

    manifest {
        from("./src/main/resources/META-INF/MANIFEST.MF")
    }

    exclude "**/*.class"
    exclude "**/asm-Java.jar"
    exclude "**/jboss-deployment-structure.xml"

//    exclude("**/beans.xml")

    dependencies {
        earlib group: "com.google.code.gson", name: "gson", version: "2.10", ext: "jar"
        earlib group: "org.apache.httpcomponents", name: "httpclient", version: "4.5.13", ext: "jar"
        earlib group: "org.apache.httpcomponents", name: "httpcore", version: "4.4.14", ext: "jar"
        earlib group: "org.jetbrains.kotlin", name: "kotlin-stdlib", version: "1.8.10", ext: "jar"

        earlib group: "dev.morphia.morphia", name: "morphia-core", version: "2.3.0", ext: "jar"

        earlib group: "org.mongodb", name: "mongodb-driver-core", version: "4.8.2", ext: "jar"
        earlib group: "org.mongodb", name: "mongodb-driver-sync", version: "4.8.2", ext: "jar"
        earlib group: "org.mongodb", name: "bson", version: "4.8.2", ext: "jar"

        earlib group: "net.bytebuddy", name: "byte-buddy", version: "1.12.17", ext: "jar"

        earlib group: "io.github.classgraph", name: "classgraph", version: "4.8.153"

        spotbugsPlugins("com.h3xstream.findsecbugs:findsecbugs-plugin:1.12.0")
    }
}

有什么建议吗?短暂性脑缺血发作

cigdeys3

cigdeys31#

以下是将build.gradle文件中不推荐使用的报表属性从Gradle 7.x.x.迁移到8.0.0的示例:

Gradle 7.x.x

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

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

Gradle 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')
    }
}

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

当前

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

tasks.withType(Checkstyle) {
    reports {
        html.destination rootProject.file("reports/checkstyle/checkstyle.html")
    }
}

新增

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

tasks.withType(Checkstyle) {
    reports {
        html.outputLocation = rootProject.file('reports/checkstyle/checkstyle.html')
    }
}
hmae6n7t

hmae6n7t2#

对于那些谁来这里与类似的问题在sonarqube任务期间收到:

Unable to find method ''java.io.File org.gradle.api.tasks.testing.JUnitXmlReport.getDestination()''
'java.io.Fileorg.gradle.api.tasks.testing.JUnitXmlReport.getDestination()'

在我的例子中,根本原因是版本不兼容(gradle和sonarqube之间)。
我将gradle版本升级到8.0.2,错误已经被抛出。在阅读文档后,我发现gradle 8.0.x版本有一个新的兼容sonarqube版本。将sonarqube版本升级到4.0.0.2929后,它又开始正常工作了。
您可以在这里找到更多信息:

piah890a

piah890a3#

升级到Gradle 8.1:

删除:

rm -rf .m2
rm -rf $HOME/.gradle/caches/

还能得到:

java.lang.NoSuchMethodError: 'java.io.File org.gradle.api.reporting.ConfigurableReport.getDestination()'

./gradlew build clean --scan:

FAILURE: Build failed with an exception.

* What went wrong:
'java.io.File org.gradle.api.reporting.ConfigurableReport.getDestination()'

* 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 630ms

Publishing a build scan to scans.gradle.com requires accepting the Gradle Terms of Service defined at https://gradle.com/terms-of-service. Do you accept these terms? [yes, no] yes

Gradle Terms of Service accepted.

Publishing build scan...
Publishing build scan failed due to network error 'java.net.SocketException: Unexpected end of file from server' (2 retries remaining)...
Publishing build scan failed due to network error 'java.net.SocketException: Unexpected end of file from server' (1 retry remaining)...

A network error occurred.

If you require assistance with this problem, please report it via https://gradle.com/help/plugin and include the following information via copy/paste.

----------
Gradle version: 8.1
Plugin version: 3.12.6
Request URL: https://status.gradle.com
Request ID: 41b92b84-4e11-4c13-94da-bda5af7ac0de
Exception: java.net.SocketException: Unexpected end of file from server
----------

./gradlew build clean --debug

2023-04-18T10:52:45.403+0100 [DEBUG] [org.jetbrains.kotlin.gradle.plugin.statistics.KotlinBuildStatHandler] Build completed with 1 failures.
org.gradle.execution.MultipleBuildFailures: Build completed with 1 failures.

为什么这样:

gradle --version

------------------------------------------------------------
Gradle 8.1
------------------------------------------------------------

Build time:   2023-04-12 12:07:45 UTC
Revision:     40ba32cde9d6daf2b92c39376d2758909dd6b813

Kotlin:       1.8.10
Groovy:       3.0.15
Ant:          Apache Ant(TM) version 1.10.11 compiled on July 10 2021
JVM:          20 (Oracle Corporation 20+36-2344)
OS:           Mac OS X 13.3.1 x86_64

将Kotlin显示为1.8.10
当它是所有1.8.20

brew list kotlin
/usr/local/Cellar/kotlin/1.8.20/bin/kapt
/usr/local/Cellar/kotlin/1.8.20/bin/kotlin
/usr/local/Cellar/kotlin/1.8.20/bin/kotlin-dce-js
/usr/local/Cellar/kotlin/1.8.20/bin/kotlinc
/usr/local/Cellar/kotlin/1.8.20/bin/kotlinc-js
/usr/local/Cellar/kotlin/1.8.20/bin/kotlinc-jvm
/usr/local/Cellar/kotlin/1.8.20/libexec/bin/ (6 files)
/usr/local/Cellar/kotlin/1.8.20/libexec/lib/ (55 files)
/usr/local/Cellar/kotlin/1.8.20/libexec/build.txt
/usr/local/Cellar/kotlin/1.8.20/license/third_party/ (40 files)
/usr/local/Cellar/kotlin/1.8.20/license/ (5 files)

相关问题