I have a gradle task as follows. Setting the GOPATH before I start the build. When I run the second task, that is runUnitTest and GOPATH is not set inside that block and I see this error "$GOPATH not set".
task goBuild(type:Exec) {
environment 'GOPATH', projectDir.toString().split("/src")[0]
commandLine "go", "build", "main.go"
}
task runUnitTest(type:Exec) {
dependsOn goBuild
commandLine "go", "get", "github.com/AlekSi/gocov-xml"
commandLine "go", "test", "-v"
}
I can of course, set the GOPATH again inside the second task. But, I am curious on how to have globally set in gradle.