首页 > 解决方案 > 此构建中使用了弃用的 Gradle 功能,使其与 Gradle 6.0 不兼容,并且找不到 Groovy Jar

问题描述

我不确定这个错误。我遇到了构建问题,并且注意到我的 grails 版本是 4.0,所以我根据更新 Grails进行了一些更新。当前的构建错误是:

Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.

我正在查看已弃用的 gradle,即使我知道我的 Gradle 是 5.0 因为我跑了

gradlew wrapper --gradle-version 5.0

按照链接中的建议,我运行了 gradlew bootRun --warning-mode all --stacktrace,并看到了以下输出:

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':compileGroovy'.
        at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:37)
        at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.run(EventFiringTaskExecuter.java:49)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:301)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:293)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:175)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:91)
        at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31)
        at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.execute(EventFiringTaskExecuter.java:44)
        at org.gradle.execution.plan.LocalTaskNodeExecutor.execute(LocalTaskNodeExecutor.java:43)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:337)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:325)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:318)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:304)
        at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker$1.execute(DefaultPlanExecutor.java:134)
        at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker$1.execute(DefaultPlanExecutor.java:129)
        at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.execute(DefaultPlanExecutor.java:202)
        at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.executeNextNode(DefaultPlanExecutor.java:193)
        at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.run(DefaultPlanExecutor.java:129)
        at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
        at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
        at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
Caused by: org.gradle.api.GradleException: Cannot infer Groovy class path because no Groovy Jar was found on class path: [C:\Users\me\.gradle\caches\modules-2\files-2.1\org.grails.plugins\external-config\1.3.0\

有任何想法吗?

更新:当我再次尝试设置 gradle 版本时,我也看到了这一点:

gradlew wrapper --gradle-version 5.0

Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.0/userguide/command_line_interface.html#sec:command_line_warnings

BUILD SUCCESSFUL in 1s
1 actionable task: 1 executed
'E_ARGS' is not recognized as an internal or external command,
operable program or batch file.

C:\Users\me\grailsapp>gradlew wrapper --gradle-version 5.0

Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.0/userguide/command_line_interface.html#sec:command_line_warnings

BUILD SUCCESSFUL in 1s
1 actionable task: 1 up-to-date

Update2:尝试过gradlew clean build,但因为想要 Gradle 6.0 而失败,所以尝试gradlew wrapper --gradle-version 5.0再次执行并 gradlew bootRun --warning-mode all --stacktrace 并查看:

at java.lang.Thread.run(Thread.java:748)

> Task :compileGroovy FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileGroovy'.
> org/grails/io/support/Resource

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

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':compileGroovy'.

这是 build.gradle:

buildscript {
    repositories {
        mavenLocal()
        maven { url "https://repo.grails.org/grails/core" }
    }
    dependencies {
        classpath "org.grails:grails-gradle-plugin:$grailsVersion"
        classpath "org.grails.plugins:hibernate5:${gormVersion-".RELEASE"}"
        classpath "com.bertramlabs.plugins:asset-pipeline-gradle:2.14.8"
        classpath "org.grails.plugins:views-gradle:1.3.0"
        classpath "gradle.plugin.com.gorylenko.gradle-git-properties:gradle-git-properties:2.2.0"
    }
}

version "0.1"
group "com.mcwa.internal"

apply plugin:"eclipse"
apply plugin:"idea"
apply plugin:"war"
apply plugin:"org.grails.grails-web"
apply plugin:"asset-pipeline"
apply plugin:"org.grails.grails-gsp"
apply plugin:"org.grails.plugins.views-json"
apply plugin: "com.gorylenko.gradle-git-properties"



repositories {
    //mavenLocal()
    maven { url "http://subversion:8080/repository/internal" }
    maven { url "https://repo.grails.org/grails/core" }
}



dependencies {
    compile 'org.grails.plugins:external-config:1.3.0'
    compile 'com.oracle:ojdbc8:12.2.0.1'
    compile "org.grails.plugins:dropwizard-metrics:1.0.0.M3"
    compile ("org.grails.plugins:sentry:11.7.24")


    //https://github.com/grails-plugins/grails-spring-security-ldap/issues/17
    compile "org.grails.plugins:spring-security-core:3.2.0"

    compile ('org.grails.plugins:spring-security-kerberos:3.0.1' ){
         exclude group: 'org.grails.plugins', module:'spring-security-core'
    }

    dependencies {
        implementation 'com.github.rjolly:flying-saucer:9.1.20'
    }

    dependencies {
        compile 'com.lowagie:itext:2.1.7'
    }

    compile 'org.grails.plugins:mail:2.0.0'

    compile "org.apache.poi:poi:4.1.0"
    compile "org.apache.poi:poi-ooxml:4.1.0"
    compile "org.apache.poi:poi-scratchpad:4.1.0"
    compile "org.apache.poi:ooxml-schemas:1.4"
    compile "org.apache.commons:commons-csv:1.7"
    compile "org.apache.httpcomponents:httpclient:4.5.5"

    compile "org.springframework.boot:spring-boot-starter-logging"
    compile("org.springframework.boot:spring-boot-autoconfigure")
    compile "org.grails:grails-core"
    compile "org.springframework.boot:spring-boot-starter-actuator"
    compile "org.springframework.boot:spring-boot-starter-tomcat"
    compile "org.grails:grails-web-boot"
    compile "org.grails:grails-logging"
    compile "org.grails:grails-plugin-rest"
    compile "org.grails:grails-plugin-databinding"
    compile "org.grails:grails-plugin-i18n"
    compile "org.grails:grails-plugin-services"
    compile "org.grails:grails-plugin-url-mappings"
    compile "org.grails:grails-plugin-interceptors"
    compile "org.grails.plugins:cache"
    compile "org.grails.plugins:async"
    compile "org.grails.plugins:scaffolding"
    compile "org.grails.plugins:events"
    compile "org.grails.plugins:hibernate5"
    compile "org.grails.plugins:views-json:1.3.0"
    compile "org.hibernate:hibernate-core:5.1.5.Final"
    compile "org.grails.plugins:gsp"
    compile 'org.codehaus.groovy:groovy-all:2.5.6'
    console "org.grails:grails-console"
    profile "org.grails.profiles:web"
    runtime "org.glassfish.web:el-impl:2.1.2-b03"
    runtime "org.apache.tomcat:tomcat-jdbc"
    runtime "com.bertramlabs.plugins:asset-pipeline-grails:2.14.8"
    runtime 'org.grails.plugins:grails-melody-plugin:1.80.0'
    testCompile "org.grails:grails-gorm-testing-support"
    testCompile "org.grails:grails-web-testing-support"
    testCompile "org.grails.plugins:geb:1.1.2"
    testRuntime "org.seleniumhq.selenium:selenium-chrome-driver:2.47.1"
    testRuntime "org.seleniumhq.selenium:selenium-htmlunit-driver:2.47.1"
    testRuntime "net.sourceforge.htmlunit:htmlunit:2.18"
}

bootRun {
    jvmArgs('-Dspring.output.ansi.enabled=always')
    addResources = true
    String springProfilesActive = 'spring.profiles.active'
    systemProperty springProfilesActive, System.getProperty(springProfilesActive)
}

tasks.withType(Test) {
    systemProperty "geb.env", System.getProperty('geb.env')
    systemProperty "geb.build.reportsDir", reporting.file("geb/integrationTest")
    systemProperty "webdriver.chrome.driver", System.getProperty('webdriver.chrome.driver')
    systemProperty "webdriver.gecko.driver", System.getProperty('webdriver.gecko.driver')
}

assets {
    minifyJs = true
    minifyCss = true
    enableSourceMaps = true
}

Update3:尝试删除添加到 build.gradle 的内容:

grails { pathingJar = true } 

因为错误信息。做了干净的构建,但看到

> Task :compileGroovy FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileGroovy'.
> org/grails/io/support/Resource

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

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':compileGroovy'.

标签: grailsgroovy

解决方案


推荐阅读