Gradle Could not find method “() for arguments on root project

社会主义新天地 提交于 2019-12-10 02:48:24

问题


I have a Gradle project that I'm attempting to fix and am slowly learning Gradle's syntax as I go.

Currently I have a library that if IS_RELEASE (an environmental variable) is set, then it uploads it to our production servers. If not, it copies it to our testing location.

The code is as follows:

task(detect) << {
    if(System.getenv().containsKey("IS_RELEASE"))
        apply from: “{$rootDir}/upload-pack.gradle”
    else
        apply from: “{$rootDir}/copy-testing.gradle”
}

detect.mustRunAfter build
build.finalizedBy detect

The code looks just fine and doesn't cause any syntax errors in NetBeans. However, when I run gradle build I get the following:

:compileJava UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:jar UP-TO-DATE
:assemble UP-TO-DATE
:compileTestJava UP-TO-DATE
:processTestResources UP-TO-DATE
:testClasses UP-TO-DATE
:test UP-TO-DATE
:check UP-TO-DATE
:build UP-TO-DATE
:detect FAILED

FAILURE: Build failed with an exception.

  • Where:
    Build file '/path/to/gradle/project/build.gradle' line: 62

  • What went wrong:
    Execution failed for task ':detect'. Could not find method “() for arguments [build_934uxjujs447ej84orspcupbq$_run_closure4$_closure15@3a230b5f] on root project 'myproject'.

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

    BUILD FAILED

Line 62 is apply from: “{$rootDir}/copy-testing.gradle”.

Am I missing something here? I have taken some similar ideas from here and fixed the solutions up. (See the "Apply From a File" header.)


回答1:


Your quotation marks are wrong. In your code you are using (copied from the linked website) and (Double curved quotes) instead of regular (ambidextrous) "s.



来源:https://stackoverflow.com/questions/37100254/gradle-could-not-find-method-for-arguments-on-root-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!