MCPcopy Index your code
hub / github.com/cloudfoundry/java-buildpack / Detect

Method Detect

src/java/containers/container.go:47–74  ·  view source on GitHub ↗

Detect finds the first container that can handle the application. If JBP_CONFIG_JAVA_MAIN specifies an explicit java_main_class, the Java Main container is selected unconditionally — before the normal priority order — so it can override higher-priority containers such as Spring Boot. Java Main is al

()

Source from the content-addressed store, hash-verified

45// so it can override higher-priority containers such as Spring Boot.
46// Java Main is always registered last (lowest priority), so it is the last element.
47func (r *Registry) Detect() (Container, string, error) {
48 cfg := loadJavaMainConfig(r.context.Log)
49 if cfg.JavaMainClass != "" && len(r.containers) > 0 {
50 if jm, ok := r.containers[len(r.containers)-1].(*JavaMainContainer); ok {
51 name, err := jm.Detect()
52 if err != nil {
53 return nil, "", err
54 }
55 if name != "" {
56 return jm, name, nil
57 }
58 } else {
59 r.context.Log.Warning("JBP_CONFIG_JAVA_MAIN java_main_class is set but JavaMain container is not available; ignoring override")
60 }
61 }
62
63 for _, container := range r.containers {
64 name, err := container.Detect()
65 if err != nil {
66 // Propagate errors (e.g., validation failures)
67 return nil, "", err
68 }
69 if name != "" {
70 return container, name, nil
71 }
72 }
73 return nil, "", nil
74}
75
76// DetectAll returns all containers that can handle the application
77func (r *Registry) DetectAll() ([]Container, []string, error) {

Callers

nothing calls this directly

Calls 2

loadJavaMainConfigFunction · 0.85
DetectMethod · 0.65

Tested by

no test coverage detected