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

Method buildClasspath

src/java/containers/groovy.go:140–165  ·  view source on GitHub ↗

buildClasspath globs all JARs under the build dir and returns a "-cp <...>" flag string with runtime-relative paths (using $HOME), mirroring the Ruby buildpack's add_libs behaviour.

()

Source from the content-addressed store, hash-verified

138// buildClasspath globs all JARs under the build dir and returns a "-cp <...>" flag string
139// with runtime-relative paths (using $HOME), mirroring the Ruby buildpack's add_libs behaviour.
140func (g *GroovyContainer) buildClasspath() string {
141 buildDir := g.context.Stager.BuildDir()
142
143 var jarPaths []string
144 err := filepath.Walk(buildDir, func(path string, info os.FileInfo, err error) error {
145 if err != nil || info.IsDir() {
146 return err
147 }
148 if strings.HasSuffix(info.Name(), ".jar") {
149 rel, relErr := filepath.Rel(buildDir, path)
150 if relErr == nil {
151 jarPaths = append(jarPaths, "$HOME/"+filepath.ToSlash(rel))
152 }
153 }
154 return nil
155 })
156 if err != nil {
157 g.context.Log.Debug("Error walking build dir for JARs: %s", err.Error())
158 }
159
160 if len(jarPaths) == 0 {
161 return "-cp ${CLASSPATH:+:$CLASSPATH}${CONTAINER_SECURITY_PROVIDER:+:$CONTAINER_SECURITY_PROVIDER}"
162 }
163 // Adding also container security provider and the additional CLASSPATH env built when profile.d scripts are sourced
164 return "-cp " + strings.Join(jarPaths, ":") + "${CLASSPATH:+:$CLASSPATH}${CONTAINER_SECURITY_PROVIDER:+:$CONTAINER_SECURITY_PROVIDER}"
165}

Callers 1

ReleaseMethod · 0.95

Calls 2

BuildDirMethod · 0.65
NameMethod · 0.65

Tested by

no test coverage detected