Slackbot
05/03/2022, 1:32 PMephemient
05/03/2022, 1:43 PMbuildscript, initscript, plugins, and pluginManagement are all special blocks that extracted and run separately, before any other part of the script. this is necessary because Gradle needs to use them to set up the build environment for the rest of the script. you cannot use anything defined outside of the block, in these blocks.Alon Eitan
05/03/2022, 1:56 PMAlon Eitan
05/03/2022, 1:56 PMAlon Eitan
05/03/2022, 1:56 PMephemient
05/03/2022, 2:02 PMAlon Eitan
05/03/2022, 2:19 PMAlon Eitan
05/03/2022, 2:20 PMinitscript{
def hi() {
println "hi"
}
hi()
hi()
}
does not workAlon Eitan
05/03/2022, 2:20 PMFAILURE: Build failed with an exception.
* Where:
Initialization script '/Users/aloneitan/.gradle/init.gradle' line: 1
* What went wrong:
Could not compile initialization script '/Users/aloneitan/.gradle/init.gradle'.
> startup failed:
initialization script '/Users/aloneitan/.gradle/init.gradle': 1: Unexpected input: '{' @ line 1, column 11.
initscript{
^
1 errorAlon Eitan
05/03/2022, 2:23 PMinitscript and plugins .
just keep it within initiscriptephemient
05/03/2022, 2:36 PMAlon Eitan
05/03/2022, 3:14 PMAlon Eitan
05/03/2022, 3:15 PMephemient
05/03/2022, 3:15 PMinitscript{ versus initscript {Alon Eitan
05/03/2022, 3:16 PMFAILURE: Build failed with an exception.
* Where:
Initialization script '/Users/aloneitan/.gradle/init.gradle' line: 2
* What went wrong:
Could not compile initialization script '/Users/aloneitan/.gradle/init.gradle'.
> startup failed:
initialization script '/Users/aloneitan/.gradle/init.gradle': 2: Method definition not expected here. Please define the method at an appropriate place or perhaps try using a block/Closure instead. at line: 2 column: 5. File: _BuildScript_ @ line 2, column 5.
def hi() {
^
1 errorephemient
05/03/2022, 3:16 PMephemient
05/03/2022, 3:16 PMAlon Eitan
05/03/2022, 3:16 PMAlon Eitan
05/03/2022, 3:17 PM