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

Method Finalize

src/java/frameworks/java_cf_env.go:86–108  ·  view source on GitHub ↗

Finalize performs final java-cfenv configuration

()

Source from the content-addressed store, hash-verified

84
85// Finalize performs final java-cfenv configuration
86func (j *JavaCfEnvFramework) Finalize() error {
87 // Add the JAR to additional libraries (classpath)
88 javaCfEnvDir := filepath.Join(j.context.Stager.DepDir(), "java_cf_env")
89 jarPattern := filepath.Join(javaCfEnvDir, "java-cfenv-*.jar")
90
91 matches, err := filepath.Glob(jarPattern)
92 if err != nil || len(matches) == 0 {
93 // JAR not found, might not have been installed
94 return nil
95 }
96
97 depsIdx := j.context.Stager.DepsIdx()
98 runtimePath := fmt.Sprintf("$DEPS_DIR/%s/java_cf_env/%s", depsIdx, filepath.Base(matches[0]))
99
100 profileScript := fmt.Sprintf("export CLASSPATH=\"%s${CLASSPATH:+:$CLASSPATH}\"\n", runtimePath)
101 if err := j.context.Stager.WriteProfileD("java_cf_env.sh", profileScript); err != nil {
102 return fmt.Errorf("failed to write java_cf_env.sh profile.d script: %w", err)
103 }
104
105 j.context.Log.Debug("Java CF Env JAR will be added to classpath at runtime: %s", runtimePath)
106
107 return nil
108}
109
110// isEnabled checks if java-cfenv is enabled in configuration
111func (j *JavaCfEnvFramework) isEnabled() bool {

Callers

nothing calls this directly

Calls 3

DepDirMethod · 0.65
DepsIdxMethod · 0.65
WriteProfileDMethod · 0.65

Tested by

no test coverage detected