微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

任务':shadowJar'的执行失败

如何解决任务':shadowJar'的执行失败

我正在遵循此tutorial,以便可以在AWS中使用Java运行Selenium测试。但是,当我执行运行gradle clean unzipLibs shadowJar deploy的步骤时,会出现错误Execution Failed for task ':shadowJar'.

我进行了一些研究,发现一些人可以通过在Gradle包装器属性中降级其Gradle版本来解决此问题,但我没有该文件。我猜是因为我在笔记本电脑上使用了Gradle。

我还运行了命令行参数--warning-mode=all,它向我显示错误

10:57:13 AM: Executing tasks 'clean unzipLibs shadowJar deploy --warning-mode all'...


> Configure project :
The compile configuration has been deprecated for dependency declaration. This will fail with an error in Gradle 7.0. Please use the implementation configuration instead. Consult the upgrading guide for further information: https://docs.gradle.org/6.5/userguide/upgrading_version_5.html#dependencies_should_no_longer_be_declared_using_the_compile_and_runtime_configurations
    at build_edh3c05nyxvkq30murs3vluef$_run_closure3.doCall(C:\Users\NROLL97\IdeaProjects\SeleniumTest\lambda-selenium-master\lambda-selenium-java\build.gradle:25)
    (Run with --stacktrace to get the full stack trace of this deprecation warning.)
The AbstractArchiveTask.archiveName property has been deprecated. This is scheduled to be removed in Gradle 7.0. Please use the archiveFileName property instead. See https://docs.gradle.org/6.5/dsl/org.gradle.api.tasks.bundling.AbstractArchiveTask.html#org.gradle.api.tasks.bundling.AbstractArchiveTask:archiveName for more details.
    at build_edh3c05nyxvkq30murs3vluef$_run_closure5.doCall(C:\Users\NROLL97\IdeaProjects\SeleniumTest\lambda-selenium-master\lambda-selenium-java\build.gradle:44)
    (Run with --stacktrace to get the full stack trace of this deprecation warning.)
The AbstractArchiveTask.destinationDir property has been deprecated. This is scheduled to be removed in Gradle 7.0. Please use the destinationDirectory property instead. See https://docs.gradle.org/6.5/dsl/org.gradle.api.tasks.bundling.AbstractArchiveTask.html#org.gradle.api.tasks.bundling.AbstractArchiveTask:destinationDir for more details.
    at build_edh3c05nyxvkq30murs3vluef$_run_closure5.doCall(C:\Users\NROLL97\IdeaProjects\SeleniumTest\lambda-selenium-master\lambda-selenium-java\build.gradle:45)
    (Run with --stacktrace to get the full stack trace of this deprecation warning.)

> Task :clean
> Task :unzipLibs UP-TO-DATE
> Task :compileJava
> Task :processResources
> Task :classes
> Task :compileTestJava
> Task :processtestResources NO-SOURCE
> Task :testClasses

> Task :shadowJar
Property 'dependencyFilter' is not annotated with an input or output annotation. This behavIoUr has been deprecated and is scheduled to be removed in Gradle 7.0. See https://docs.gradle.org/6.5/userguide/more_about_tasks.html#sec:up_to_date_checks for more details.
Property 'internalCompressor' is not annotated with an input or output annotation. This behavIoUr has been deprecated and is scheduled to be removed in Gradle 7.0. See https://docs.gradle.org/6.5/userguide/more_about_tasks.html#sec:up_to_date_checks for more details.
Property 'relocators' is not annotated with an input or output annotation. This behavIoUr has been deprecated and is scheduled to be removed in Gradle 7.0. See https://docs.gradle.org/6.5/userguide/more_about_tasks.html#sec:up_to_date_checks for more details.
Property 'rootPatternSet' is not annotated with an input or output annotation. This behavIoUr has been deprecated and is scheduled to be removed in Gradle 7.0. See https://docs.gradle.org/6.5/userguide/more_about_tasks.html#sec:up_to_date_checks for more details.
Property 'stats' is not annotated with an input or output annotation. This behavIoUr has been deprecated and is scheduled to be removed in Gradle 7.0. See https://docs.gradle.org/6.5/userguide/more_about_tasks.html#sec:up_to_date_checks for more details.
Property 'transformers' is not annotated with an input or output annotation. This behavIoUr has been deprecated and is scheduled to be removed in Gradle 7.0. See https://docs.gradle.org/6.5/userguide/more_about_tasks.html#sec:up_to_date_checks for more details.
The testRuntime configuration has been deprecated for resolution. This will fail with an error in Gradle 7.0. Please resolve the testRuntimeClasspath configuration instead. Consult the upgrading guide for further information: https://docs.gradle.org/6.5/userguide/upgrading_version_5.html#dependencies_should_no_longer_be_declared_using_the_compile_and_runtime_configurations

> Task :shadowJar Failed
6 actionable tasks: 5 executed,1 up-to-date

FAILURE: Build Failed with an exception.

* What went wrong:
Execution Failed for task ':shadowJar'.
> org/gradle/api/internal/tasks/SimpleWorkResult

* 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 15s
10:57:28 AM: Tasks execution finished 'clean unzipLibs shadowJar deploy --warning-mode all'.

所以我考虑一个一个解决这些问题,因为它们具有解决方案的链接,但我什至无法修复第一个解决方案。它说Dependencies should no longer be declared using the compile and runtime configurations。但这并未说明将其更改为什么。

我最好的做法是什么?降级Gradle是否可以解决此问题,如果可以,我该怎么做?我没有Gradle包装器。

编辑

这是我的build.gradle文件

apply plugin: 'java'

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.1'
    }
}

apply plugin: 'com.github.johnrengelman.shadow'

group = 'com.blackboard.testing'

repositories {
    mavenCentral()
}

test {
    include '**/ExampleTestSuite.class'
}

dependencies {
    compile group: 'com.codeborne',name: 'selenide',version: '4.8'
    compile group: 'com.amazonaws',name: 'aws-lambda-java-events',version: '1.1.0'
    compile group: 'com.amazonaws',name: 'aws-lambda-java-core',name: 'aws-java-sdk-lambda',version: '1.11.208'
    compile group: 'com.amazonaws.serverless',name: 'aws-serverless-java-container-jersey',version: '0.7'
    compile group: 'org.reflections',name: 'reflections',version: '0.9.10'
    compile group: 'junit',name: 'junit',version:'4.12'
}

task unzipLibs(type: copy) {
    def libs = file('../bin/lib.zip')
    def resources = file("${projectDir}/src/main/resources/")

    from zipTree(libs)
    into resources
}

task zipLibs(type: Zip) {
    from processResources
    archiveName 'lib.zip'
    destinationDir(file('../bin/'))
}

shadowJar {
    from sourceSets.test.output
    configurations = [ project.configurations.testRuntime ]
}

task deploy(type: Exec) {
    commandLine 'sls','deploy'
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。