MCPcopy Create free account
hub / github.com/cloudfoundry/java-buildpack / FindMainGroovyScript

Function FindMainGroovyScript

src/java/containers/groovy_utils.go:128–148  ·  view source on GitHub ↗

FindMainGroovyScript determines which Groovy script should be executed. Following Ruby buildpack logic, a file is a candidate if it has a static void main() method, is not a POGO, or has a shebang. Returns the single candidate if exactly one matches, empty string otherwise.

(scripts []string)

Source from the content-addressed store, hash-verified

126// void main() method, is not a POGO, or has a shebang.
127// Returns the single candidate if exactly one matches, empty string otherwise.
128func FindMainGroovyScript(scripts []string) (string, error) {
129 g := &GroovyUtils{}
130 candidates := make(map[string]bool)
131
132 for _, script := range scripts {
133 if !isValidGroovyFile(script) {
134 continue
135 }
136 if g.HasMainMethod(script) || !g.IsPOGO(script) || g.HasShebang(script) {
137 candidates[script] = true
138 }
139 }
140
141 if len(candidates) == 1 {
142 for script := range candidates {
143 return script, nil
144 }
145 }
146
147 return "", nil
148}

Callers 2

ReleaseMethod · 0.85

Calls 4

HasMainMethodMethod · 0.95
IsPOGOMethod · 0.95
HasShebangMethod · 0.95
isValidGroovyFileFunction · 0.85

Tested by

no test coverage detected