Finalize performs final java-cfenv configuration
()
| 84 | |
| 85 | // Finalize performs final java-cfenv configuration |
| 86 | func (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 |
| 111 | func (j *JavaCfEnvFramework) isEnabled() bool { |
nothing calls this directly
no test coverage detected