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

Method Finalize

src/java/containers/play.go:365–433  ·  view source on GitHub ↗

Finalize performs final configuration for the Play Framework application

()

Source from the content-addressed store, hash-verified

363
364// Finalize performs final configuration for the Play Framework application
365func (p *PlayContainer) Finalize() error {
366 p.context.Log.BeginStep("Finalizing Play Framework %s", p.playVersion)
367
368 // Collect additional libraries (JVMKill agent, frameworks, etc.)
369 additionalLibs := p.collectAdditionalLibraries()
370 p.context.Log.Info("Found %d additional libraries for CLASSPATH", len(additionalLibs))
371
372 // Build CLASSPATH from additional libraries
373 // Convert staging paths to runtime paths
374 classpathParts := p.buildRuntimeClasspath(additionalLibs)
375
376 // Determine the script directory based on Play type
377 var scriptDir string
378 switch p.playType {
379 case "post22_dist":
380 scriptDir = "application-root/bin"
381 case "post22_staged":
382 scriptDir = "bin"
383 case "pre22_dist":
384 scriptDir = "application-root"
385 case "pre22_staged":
386 scriptDir = "."
387 default:
388 scriptDir = "bin"
389 }
390
391 // Write profile.d script that sets up environment variables
392 // This follows the immutable BuildDir pattern: configure via environment, don't modify files
393 envContent := fmt.Sprintf(`export DEPS_DIR=${DEPS_DIR:-/home/vcap/deps}
394export PLAY_HOME=$HOME
395export PLAY_BIN=$HOME/%s
396export PATH=$PLAY_BIN:$PATH
397
398# Prepend additional libraries to CLASSPATH
399# Play start scripts respect CLASSPATH environment variable
400# This includes JVMKill agent, framework JARs, JDBC drivers, etc.
401`, scriptDir)
402
403 // Add CLASSPATH if we have additional libraries
404 if len(classpathParts) > 0 {
405 classpathValue := strings.Join(classpathParts, ":")
406 envContent += fmt.Sprintf("export CLASSPATH=\"%s:${CLASSPATH:-}\"\n", classpathValue)
407 p.context.Log.Info("Configured CLASSPATH with %d additional libraries", len(classpathParts))
408 }
409
410 if err := p.context.Stager.WriteProfileD("play.sh", envContent); err != nil {
411 p.context.Log.Warning("Could not write play.sh profile.d script: %s", err.Error())
412 } else {
413 p.context.Log.Debug("Created profile.d script: play.sh")
414 }
415
416 // Configure JAVA_OPTS to be picked up by Play startup scripts
417 // Play uses -Dhttp.port system property to configure the HTTP port
418 // Note: JVMKill agent is configured by the JRE component via .profile.d/java_opts.sh
419 javaOpts := []string{
420 "-Dhttp.port=$PORT",
421 "-Djava.io.tmpdir=$TMPDIR",
422 "-XX:+ExitOnOutOfMemoryError",

Callers

nothing calls this directly

Calls 3

buildRuntimeClasspathMethod · 0.95
WriteProfileDMethod · 0.65

Tested by

no test coverage detected