@@ -19,7 +19,10 @@ use crate::version_resolver::{
19
19
resolve_version, OpenJdkArtifactRequirementSource , VersionResolveError ,
20
20
} ;
21
21
use buildpacks_jvm_shared:: output;
22
- use buildpacks_jvm_shared:: output:: { BuildpackOutputText , BuildpackOutputTextSection } ;
22
+ use buildpacks_jvm_shared:: output:: {
23
+ track_buildpack_timing, BuildpackOutputText ,
24
+ BuildpackOutputTextSection ,
25
+ } ;
23
26
use buildpacks_jvm_shared:: system_properties:: { read_system_properties, ReadSystemPropertiesError } ;
24
27
#[ cfg( test) ]
25
28
use buildpacks_jvm_shared_test as _;
@@ -92,18 +95,19 @@ impl Buildpack for OpenJdkBuildpack {
92
95
}
93
96
94
97
fn build ( & self , context : BuildContext < Self > ) -> libcnb:: Result < BuildResult , Self :: Error > {
95
- output:: print_buildpack_name ( "Heroku OpenJDK Buildpack" ) ;
96
-
97
- let resolved_version = resolve_version ( & context. app_dir )
98
- . map_err ( OpenJdkBuildpackError :: ResolveVersionError ) ?;
99
-
100
- if matches ! (
101
- resolved_version. source,
102
- OpenJdkArtifactRequirementSource :: DefaultVersionLatestLts
103
- ) {
104
- output:: print_warning (
105
- "No OpenJDK version specified" ,
106
- formatdoc ! { "
98
+ track_buildpack_timing ( || {
99
+ output:: print_buildpack_name ( "Heroku OpenJDK Buildpack" ) ;
100
+
101
+ let resolved_version = resolve_version ( & context. app_dir )
102
+ . map_err ( OpenJdkBuildpackError :: ResolveVersionError ) ?;
103
+
104
+ if matches ! (
105
+ resolved_version. source,
106
+ OpenJdkArtifactRequirementSource :: DefaultVersionLatestLts
107
+ ) {
108
+ output:: print_warning (
109
+ "No OpenJDK version specified" ,
110
+ formatdoc ! { "
107
111
Your application does not explicitly specify an OpenJDK version. The latest
108
112
long-term support (LTS) version will be installed. This currently is OpenJDK {OPENJDK_LATEST_LTS_VERSION}.
109
113
@@ -115,74 +119,79 @@ impl Buildpack for OpenJdkBuildpack {
115
119
directory of your application to contain:
116
120
117
121
java.runtime.version = {OPENJDK_LATEST_LTS_VERSION}" } ,
118
- ) ;
119
- }
120
-
121
- output:: print_section ( "OpenJDK version resolution" ) ;
122
-
123
- match resolved_version. source {
124
- OpenJdkArtifactRequirementSource :: SystemProperties => {
125
- output:: print_subsection ( BuildpackOutputText :: new ( vec ! [
126
- BuildpackOutputTextSection :: regular( "Using version string provided in " ) ,
127
- BuildpackOutputTextSection :: value( "system.properties" ) ,
128
- ] ) ) ;
122
+ ) ;
129
123
}
130
- OpenJdkArtifactRequirementSource :: DefaultVersionLatestLts => {
131
- output:: print_subsection ( "No explicit configuration found, using latest LTS" ) ;
132
- }
133
- OpenJdkArtifactRequirementSource :: DefaultVersionFunctions => {
134
- output:: print_subsection ( BuildpackOutputText :: new ( vec ! [
135
- BuildpackOutputTextSection :: regular( "No explicit configuration found, using " ) ,
136
- BuildpackOutputTextSection :: value( "8" ) ,
137
- ] ) ) ;
138
- }
139
- } ;
140
-
141
- let openjdk_inventory = include_str ! ( "../openjdk_inventory.toml" )
142
- . parse :: < Inventory < OpenJdkVersion , Sha256 , OpenJdkArtifactMetadata > > ( )
143
- . map_err ( OpenJdkBuildpackError :: ParseInventoryError ) ?;
144
-
145
- let openjdk_artifact = openjdk_inventory
146
- . partial_resolve (
147
- context
148
- . target
149
- . os
150
- . parse :: < Os > ( )
151
- . expect ( "OS should be always parseable, buildpack will not run on unsupported operating systems." ) ,
152
- // On platform API <= `0.9` together with lifecycle <= `0.17`, the `CNB_TARGET_ARCH` environment variable will not be set.
153
- // This will be the case for the `salesforce-functions` builder. To ensure this buildpack can run there, we will
154
- // fall back to Rust's architecture constant when the architecture cannot be determined. This workaround can be removed when
155
- // the `salesforce-functions` builder is EOL.
156
- Some ( context. target . arch . as_str ( ) )
157
- . filter ( |value| !value. is_empty ( ) )
158
- . unwrap_or ( consts:: ARCH )
159
- . parse :: < Arch > ( )
160
- . expect ( "arch should be always parseable, buildpack will not run on unsupported architectures." ) ,
161
- & resolved_version. requirement ,
162
- )
163
- . ok_or ( OpenJdkBuildpackError :: UnsupportedOpenJdkVersion (
164
- resolved_version. requirement . clone ( ) ,
165
- ) ) ?;
166
-
167
- output:: print_subsection ( match resolved_version. requirement . version {
168
- HerokuOpenJdkVersionRequirement :: Major ( major_version) => {
169
- BuildpackOutputText :: new ( vec ! [
170
- BuildpackOutputTextSection :: regular( "Selected major version " ) ,
171
- BuildpackOutputTextSection :: value( format!( "{major_version}" ) ) ,
172
- BuildpackOutputTextSection :: regular( " resolves to " ) ,
173
- BuildpackOutputTextSection :: value( format!( "{}" , openjdk_artifact. version) ) ,
174
- ] )
175
- }
176
- HerokuOpenJdkVersionRequirement :: Specific ( version) => BuildpackOutputText :: new ( vec ! [
177
- BuildpackOutputTextSection :: regular( "Selected version " ) ,
178
- BuildpackOutputTextSection :: value( format!( "{version}" ) ) ,
179
- ] ) ,
180
- } ) ;
181
-
182
- handle_openjdk_layer ( & context, openjdk_artifact) ?;
183
- handle_runtime_layer ( & context) ?;
184
124
185
- BuildResultBuilder :: new ( ) . build ( )
125
+ output:: print_section ( "OpenJDK version resolution" ) ;
126
+
127
+ match resolved_version. source {
128
+ OpenJdkArtifactRequirementSource :: SystemProperties => {
129
+ output:: print_subsection ( BuildpackOutputText :: new ( vec ! [
130
+ BuildpackOutputTextSection :: regular( "Using version string provided in " ) ,
131
+ BuildpackOutputTextSection :: value( "system.properties" ) ,
132
+ ] ) ) ;
133
+ }
134
+ OpenJdkArtifactRequirementSource :: DefaultVersionLatestLts => {
135
+ output:: print_subsection ( "No explicit configuration found, using latest LTS" ) ;
136
+ }
137
+ OpenJdkArtifactRequirementSource :: DefaultVersionFunctions => {
138
+ output:: print_subsection ( BuildpackOutputText :: new ( vec ! [
139
+ BuildpackOutputTextSection :: regular(
140
+ "No explicit configuration found, using " ,
141
+ ) ,
142
+ BuildpackOutputTextSection :: value( "8" ) ,
143
+ ] ) ) ;
144
+ }
145
+ } ;
146
+
147
+ let openjdk_inventory = include_str ! ( "../openjdk_inventory.toml" )
148
+ . parse :: < Inventory < OpenJdkVersion , Sha256 , OpenJdkArtifactMetadata > > ( )
149
+ . map_err ( OpenJdkBuildpackError :: ParseInventoryError ) ?;
150
+
151
+ let openjdk_artifact = openjdk_inventory
152
+ . partial_resolve (
153
+ context
154
+ . target
155
+ . os
156
+ . parse :: < Os > ( )
157
+ . expect ( "OS should be always parseable, buildpack will not run on unsupported operating systems." ) ,
158
+ // On platform API <= `0.9` together with lifecycle <= `0.17`, the `CNB_TARGET_ARCH` environment variable will not be set.
159
+ // This will be the case for the `salesforce-functions` builder. To ensure this buildpack can run there, we will
160
+ // fall back to Rust's architecture constant when the architecture cannot be determined. This workaround can be removed when
161
+ // the `salesforce-functions` builder is EOL.
162
+ Some ( context. target . arch . as_str ( ) )
163
+ . filter ( |value| !value. is_empty ( ) )
164
+ . unwrap_or ( consts:: ARCH )
165
+ . parse :: < Arch > ( )
166
+ . expect ( "arch should be always parseable, buildpack will not run on unsupported architectures." ) ,
167
+ & resolved_version. requirement ,
168
+ )
169
+ . ok_or ( OpenJdkBuildpackError :: UnsupportedOpenJdkVersion (
170
+ resolved_version. requirement . clone ( ) ,
171
+ ) ) ?;
172
+
173
+ output:: print_subsection ( match resolved_version. requirement . version {
174
+ HerokuOpenJdkVersionRequirement :: Major ( major_version) => {
175
+ BuildpackOutputText :: new ( vec ! [
176
+ BuildpackOutputTextSection :: regular( "Selected major version " ) ,
177
+ BuildpackOutputTextSection :: value( format!( "{major_version}" ) ) ,
178
+ BuildpackOutputTextSection :: regular( " resolves to " ) ,
179
+ BuildpackOutputTextSection :: value( format!( "{}" , openjdk_artifact. version) ) ,
180
+ ] )
181
+ }
182
+ HerokuOpenJdkVersionRequirement :: Specific ( version) => {
183
+ BuildpackOutputText :: new ( vec ! [
184
+ BuildpackOutputTextSection :: regular( "Selected version " ) ,
185
+ BuildpackOutputTextSection :: value( format!( "{version}" ) ) ,
186
+ ] )
187
+ }
188
+ } ) ;
189
+
190
+ handle_openjdk_layer ( & context, openjdk_artifact) ?;
191
+ handle_runtime_layer ( & context) ?;
192
+
193
+ BuildResultBuilder :: new ( ) . build ( )
194
+ } )
186
195
}
187
196
188
197
fn on_error ( & self , error : libcnb:: Error < Self :: Error > ) {
0 commit comments