installJRE installs the Java Runtime Environment. Returns the installed JRE instance and its name so the caller can persist them to config.yml.
()
| 89 | // installJRE installs the Java Runtime Environment. |
| 90 | // Returns the installed JRE instance and its name so the caller can persist them to config.yml. |
| 91 | func (s *Supplier) installJRE() (jres.JRE, string, error) { |
| 92 | // Create JRE context |
| 93 | ctx := &common.Context{ |
| 94 | Stager: s.Stager, |
| 95 | Manifest: s.Manifest, |
| 96 | Installer: s.Installer, |
| 97 | Log: s.Log, |
| 98 | Command: s.Command, |
| 99 | } |
| 100 | |
| 101 | // Create and populate JRE registry |
| 102 | registry := jres.NewRegistry(ctx) |
| 103 | registry.RegisterStandardJREs() |
| 104 | |
| 105 | // Detect which JRE to use. |
| 106 | // With SetDefault(openJDK) configured, this will always return a JRE unless |
| 107 | // an explicitly configured JRE fails detection. |
| 108 | jre, jreName, err := registry.Detect() |
| 109 | if err != nil { |
| 110 | s.Log.Error("Failed to detect JRE: %s", err.Error()) |
| 111 | return nil, "", err |
| 112 | } |
| 113 | |
| 114 | s.Log.Info("Selected JRE: %s", jreName) |
| 115 | |
| 116 | // Install the JRE |
| 117 | if err := jre.Supply(); err != nil { |
| 118 | s.Log.Error("Failed to install JRE: %s", err.Error()) |
| 119 | return nil, "", err |
| 120 | } |
| 121 | |
| 122 | s.Log.Debug("JRE installation complete: %s %s", jreName, jre.Version()) |
| 123 | return jre, jreName, nil |
| 124 | } |
| 125 | |
| 126 | // installFrameworks installs framework components (APM agents, etc.) |
| 127 | func (s *Supplier) installFrameworks() error { |
no test coverage detected