Skip to content

Commit 17fa3f1

Browse files
authored
Update Temurin support (#722)
- Remove Semeru from test matrix - Remove Semeru as it's currently failing. Will re-add at a later stage when it is known to be working - Add Temurin 21 to the matrix --------- Signed-off-by: Dan Webb <[email protected]>
1 parent f2e340a commit 17fa3f1

31 files changed

+684
-237
lines changed

.github/workflows/ci.yml

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,15 @@ jobs:
3030
- ubuntu-2204
3131
- ubuntu-2004
3232
suite:
33-
# - openjdk-11 # Debian doesn't have an 11 package
34-
- openjdk-16
35-
- openjdk-17
36-
# - temurin-8-hotspot
37-
# - temurin-11-hotspot
38-
# - semeru-11-openj9
39-
# - semeru-17-openj9
40-
- corretto-8
4133
- corretto-11
4234
- corretto-17
4335
- corretto-18
36+
- temurin-8
37+
- temurin-11
38+
- temurin-17
39+
- temurin-21
40+
# - semeru-11
41+
# - semeru-17
4442
fail-fast: false
4543
steps:
4644
- name: Check out code

.tool-versions

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ruby system

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,17 @@ This file is used to list changes made in each version of the Java cookbook.
44

55
## Unreleased
66

7+
- Add new resource `temurin_package_install`
8+
- Add script to check for Java updates
9+
- Update Temurin Java 8 support
10+
- Update Temurin repositories
11+
- Update bin commands for all OpenJDK versions
12+
- Fix Java alternatives to prevent unnecessary removal and re-addition of alternatives
13+
- Move bin_cmds from Java::Cookbook::OpenJdkHelpers to Java::Cookbook::BinCmdHelpers for reuse outside of OpenJDK
14+
- Fix apt_repository failing to install the GPG in the correct location
15+
- Add Temurin 21 to the test matrix
16+
- Remove Semeru from the test matrix
17+
718
## 12.1.1 - *2024-12-05*
819

920
## 12.1.0 - *2024-12-03*

bin/check_java_versions.rb

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
#!/usr/bin/env ruby
2+
3+
require 'net/http'
4+
require 'json'
5+
require 'uri'
6+
7+
TEMURIN_REPOS = {
8+
'11' => 'adoptium/temurin11-binaries',
9+
'17' => 'adoptium/temurin17-binaries',
10+
}.freeze
11+
12+
SEMERU_REPOS = {
13+
'11' => 'ibmruntimes/semeru11-binaries',
14+
'17' => 'ibmruntimes/semeru17-binaries',
15+
}.freeze
16+
17+
CORRETTO_REPOS = {
18+
'11' => 'corretto-11',
19+
'17' => 'corretto-17',
20+
}.freeze
21+
22+
def get_latest_release(repo)
23+
uri = URI("https://api.github.com/repos/#{repo}/releases/latest")
24+
response = Net::HTTP.get_response(uri)
25+
26+
if response.is_a?(Net::HTTPSuccess)
27+
JSON.parse(response.body)
28+
else
29+
puts "Failed to fetch release info for #{repo}: #{response.code} #{response.message}"
30+
nil
31+
end
32+
end
33+
34+
def verify_url(url)
35+
uri = URI(url)
36+
response = Net::HTTP.get_response(uri)
37+
38+
case response
39+
when Net::HTTPRedirection
40+
location = response['location']
41+
puts " ✓ URL redirects successfully to: #{location}"
42+
true
43+
when Net::HTTPSuccess
44+
puts ' ✓ URL is directly accessible'
45+
true
46+
else
47+
puts " ✗ URL is not accessible: #{response.code} #{response.message}"
48+
false
49+
end
50+
end
51+
52+
def find_linux_x64_jdk(assets)
53+
assets.find { |asset| asset['name'] =~ /OpenJDK\d+U-jdk_x64_linux_hotspot.*\.tar\.gz$/ }
54+
end
55+
56+
def check_versions
57+
puts 'Checking Temurin versions...'
58+
puts '-' * 50
59+
60+
TEMURIN_REPOS.each do |version, repo|
61+
puts "\nChecking Java #{version}..."
62+
release = get_latest_release(repo)
63+
next unless release
64+
65+
tag = release['tag_name']
66+
puts "Latest release: #{tag}"
67+
68+
asset = find_linux_x64_jdk(release['assets'])
69+
if asset
70+
url = asset['browser_download_url']
71+
puts "Download URL: #{url}"
72+
if verify_url(url)
73+
puts 'Current version in cookbook needs updating!' if url != current_url_in_cookbook(version)
74+
end
75+
else
76+
puts ' ✗ No Linux x64 JDK found in release assets'
77+
end
78+
end
79+
end
80+
81+
def current_url_in_cookbook(version)
82+
# Read the current URLs from openjdk_helpers.rb
83+
helpers_file = File.join(File.dirname(__FILE__), '..', 'libraries', 'openjdk_helpers.rb')
84+
content = File.read(helpers_file)
85+
86+
case version
87+
when '11'
88+
content.match(/temurin.*when '11'\s+'(.+?)'/m)&.[](1)
89+
when '17'
90+
content.match(/temurin.*when '17'\s+'(.+?)'/m)&.[](1)
91+
end
92+
end
93+
94+
if __FILE__ == $PROGRAM_NAME
95+
check_versions
96+
end

bin/check_temurin_versions.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
# # Fetch latest Temurin versions from endoflife.date API
4+
# curl --request GET \
5+
# --url https://endoflife.date/api/eclipse-temurin.json \
6+
# --header 'Accept: application/json' | jq '.'
7+
8+
# Filter for LTS versions only
9+
echo "LTS Versions:"
10+
curl -s --request GET \
11+
--url https://endoflife.date/api/eclipse-temurin.json \
12+
--header 'Accept: application/json' | \
13+
jq -r '.[] | select(.lts == true) | "Java \(.cycle) (LTS) - Latest: \(.latest), EOL: \(.eol)"'
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# temurin_package_install
2+
3+
Installs Java Temurin (AdoptOpenJDK) packages provided by Adoptium. This resource handles the repository setup and package installation for Temurin JDK packages across various platforms.
4+
5+
## Actions
6+
7+
- `:install` - Installs Temurin JDK packages
8+
- `:remove` - Removes Temurin JDK packages
9+
10+
## Properties
11+
12+
| Property | Type | Default | Description |
13+
|-----------------------|----------------|----------------------------------------|----------------------------------------------|
14+
| `version` | String | Name Property | Java version to install (e.g. '8', '11', '17') |
15+
| `pkg_name` | String | `temurin-#{version}-jdk` | Package name to install |
16+
| `pkg_version` | String | `nil` | Package version to install |
17+
| `java_home` | String | Platform-specific JAVA_HOME | Path to set as JAVA_HOME |
18+
| `bin_cmds` | Array | Version-specific binary commands | Commands for alternatives |
19+
| `alternatives_priority` | Integer | 1062 | Priority for alternatives system |
20+
| `reset_alternatives` | Boolean | true | Whether to reset alternatives before setting |
21+
| `default` | Boolean | true | Whether to set this as the default Java |
22+
23+
## Examples
24+
25+
### Install Temurin JDK 11
26+
27+
```ruby
28+
temurin_package_install '11'
29+
```
30+
31+
### Install Temurin JDK 17 with custom alternatives priority
32+
33+
```ruby
34+
temurin_package_install '17' do
35+
alternatives_priority 1100
36+
end
37+
```
38+
39+
### Install specific version with custom package name
40+
41+
```ruby
42+
temurin_package_install '11' do
43+
pkg_name 'temurin-11-jdk'
44+
end
45+
```
46+
47+
## Platform Support
48+
49+
This resource supports the following platforms:
50+
51+
- Debian
52+
- Ubuntu
53+
- RHEL/CentOS/Rocky Linux
54+
- Fedora
55+
- Amazon Linux
56+
- OpenSUSE/SLES
57+
58+
Each platform will have the appropriate Adoptium repository configured automatically.
59+
60+
## Notes
61+
62+
- This resource uses the Adoptium API to validate available releases.
63+
- The resource will warn if a requested version is not available as an LTS release.
64+
- For most use cases, you can simply specify the major version number.

documentation/resources/openjdk_pkg_install.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Introduced: v8.1.0
1919
| pkg_version | String | `nil` | Package version to install |
2020
| java_home | String | Based on the version | Set to override the java_home |
2121
| default | Boolean | `true` | Whether to set this as the defalut Java |
22-
| bin_cmds | Array | `default_openjdk_bin_cmds(version)` | A list of bin_cmds based on the version and variant |
22+
| bin_cmds | Array | `default_bin_cmds(version)` | A list of bin_cmds based on the version and variant |
2323
| alternatives_priority | Integer | `1062` | Alternatives priority to set for this Java |
2424
| reset_alternatives | Boolean | `true` | Whether to reset alternatives before setting |
2525

documentation/resources/openjdk_source_install.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Introduced: v8.0.0
2222
| java_home_owner | String | `root` | Owner of the Java Home |
2323
| java_home_group | String | `node['root_group']` | Group for the Java Home |
2424
| default | Boolean | `true` | Whether to set this as the defalut Java |
25-
| bin_cmds | Array | `default_openjdk_bin_cmds(version)` | A list of bin_cmds based on the version and variant |
25+
| bin_cmds | Array | `default_bin_cmds(version)` | A list of bin_cmds based on the version and variant |
2626
| alternatives_priority | Integer | `1` | Alternatives priority to set for this Java |
2727
| reset_alternatives | Boolean | `true` | Whether to reset alternatives before setting |
2828

kitchen.yml

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -48,42 +48,61 @@ suites:
4848
inputs: { java_version: "17" }
4949

5050
# Temurin/Semeru
51-
- name: temurin-8-hotspot
51+
- name: temurin-8
5252
run_list:
53-
- recipe[test::openjdk]
53+
- recipe[test::temurin_pkg]
5454
attributes:
5555
version: 8
56-
variant: hotspot
5756
verifier:
58-
inspec_tests: [test/integration/openjdk]
57+
inspec_tests: [test/integration/temurin]
5958
inputs: { java_version: "8" }
6059

61-
- name: temurin-11-hotspot
60+
- name: temurin-11
6261
run_list:
63-
- recipe[test::openjdk]
62+
- recipe[test::temurin_pkg]
6463
attributes:
6564
version: 11
66-
variant: hotspot
6765
verifier:
68-
inspec_tests: [test/integration/openjdk]
66+
inspec_tests:
67+
- test/integration/temurin
6968
inputs: { java_version: "11" }
7069

71-
- name: semeru-11-openj9
70+
- name: temurin-17
71+
run_list:
72+
- recipe[test::temurin_pkg]
73+
attributes:
74+
version: 17
75+
verifier:
76+
inspec_tests:
77+
- test/integration/temurin
78+
inputs: { java_version: "17" }
79+
80+
- name: temurin-21
81+
run_list:
82+
- recipe[test::temurin_pkg]
83+
attributes:
84+
version: 21
85+
verifier:
86+
inspec_tests:
87+
- test/integration/temurin
88+
inputs: { java_version: "21" }
89+
90+
- name: semeru-11
7291
run_list:
7392
- recipe[test::openjdk]
7493
attributes:
7594
version: 11
76-
variant: openj9
95+
variant: semeru
7796
verifier:
7897
inspec_tests: [test/integration/openjdk]
7998
inputs: { java_version: "11" }
8099

81-
- name: semeru-17-openj9
100+
- name: semeru-17
82101
run_list:
83102
- recipe[test::openjdk]
84103
attributes:
85104
version: 17
86-
variant: openj9
105+
variant: semeru
87106
verifier:
88107
inspec_tests: [test/integration/openjdk]
89108
inputs: { java_version: "17" }

lefthook.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
pre-commit:
2+
commands:
3+
rubocop:
4+
glob: "*.rb"
5+
run: chef exec rubocop {staged_files}
6+
skip:
7+
- merge
8+
- rebase

0 commit comments

Comments
 (0)