@@ -230,54 +230,42 @@ maven::settings_xml_opts() {
230
230
local build_dir=" ${1} "
231
231
232
232
local settings_file=" "
233
+
233
234
if [[ -n " ${MAVEN_SETTINGS_PATH:- } " ]]; then
234
235
settings_file=$( cd " ${build_dir} " && realpath -m " ${MAVEN_SETTINGS_PATH} " )
235
236
elif [[ -n " ${MAVEN_SETTINGS_URL:- } " ]]; then
236
- settings_file=$( maven::download_settings_xml " ${MAVEN_SETTINGS_URL} " )
237
- elif [[ -f " ${build_dir} /settings.xml" ]]; then
238
- settings_file=" ${build_dir} /settings.xml"
239
- fi
240
-
241
- if [[ -n " ${settings_file} " ]]; then
242
- echo -n " -s ${settings_file} "
243
- fi
244
- }
245
-
246
- # Downloads Maven settings.xml from a URL and returns the path to the temporary file.
247
- # Exits with error if download fails.
248
- #
249
- # Usage:
250
- # ```
251
- # settings_file=$(maven::download_settings_xml "${url}")
252
- # ```
253
- maven::download_settings_xml () {
254
- local url=" ${1} "
237
+ local target
238
+ target=$( mktemp --suffix=.xml)
255
239
256
- local target
257
- target=$( mktemp --suffix=.xml)
240
+ if curl --silent --show-error --fail --retry 3 --retry-connrefused --connect-timeout 5 --max-time 10 --location " ${MAVEN_SETTINGS_URL} " --output " ${target} " ; then
241
+ settings_file=" ${target} "
242
+ else
243
+ output::error << -EOF
244
+ Error: Unable to download Maven settings.xml.
258
245
259
- if curl --silent --show-error --fail --retry 3 --retry-connrefused --connect-timeout 5 --max-time 10 --location " ${url} " --output " ${target} " ; then
260
- echo " ${target} "
261
- else
262
- output::error << -EOF
263
- Error: Unable to download Maven settings.xml.
246
+ An error occurred while downloading the Maven settings file from:
247
+ ${MAVEN_SETTINGS_URL}
264
248
265
- An error occurred while downloading the Maven settings file from:
266
- ${url}
249
+ In some cases, this happens due to a temporary issue with
250
+ the network connection or server, or because the URL is
251
+ inaccessible or requires authentication.
267
252
268
- In some cases, this happens due to a temporary issue with
269
- the network connection or server, or because the URL is
270
- inaccessible or requires authentication.
253
+ Check that the URL in your MAVEN_SETTINGS_URL environment
254
+ variable is correct and publicly accessible. If the settings file
255
+ is not needed, you can remove the MAVEN_SETTINGS_URL environment variable
256
+ to use default Maven settings.
271
257
272
- Check that the URL in your MAVEN_SETTINGS_URL environment
273
- variable is correct and publicly accessible. If the settings file
274
- is not needed, you can remove the MAVEN_SETTINGS_URL environment variable
275
- to use default Maven settings.
258
+ Learn more about Maven settings configuration:
259
+ https://devcenter.heroku.com/articles/using-a-custom-maven-settings-xml
260
+ EOF
276
261
277
- Learn more about Maven settings configuration:
278
- https://devcenter.heroku.com/articles/using-a-custom-maven-settings-xml
279
- EOF
262
+ exit 1
263
+ fi
264
+ elif [[ -f " ${build_dir} /settings.xml" ]]; then
265
+ settings_file=" ${build_dir} /settings.xml"
266
+ fi
280
267
281
- exit 1
268
+ if [[ -n " ${settings_file} " ]]; then
269
+ echo -n " -s ${settings_file} "
282
270
fi
283
271
}
0 commit comments