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 FAILEDFAILURE: Build failed with an exception.
Where:
Build file '/path/to/gradle/project/build.gradle' line: 62What 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.)
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With