Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ This file is used to list changes made in each version of the Java cookbook.

## Unreleased

- add `skip_alternatives` to resources `corretto_install`, `openjdk_install`, `openjdk_pkg_install`, `openjdk_source_install` for cases when management of alternatives is not desired. (@dschlenk)

## 13.0.0 - *2025-07-13*

- Add new resource `temurin_package_install`
Expand Down
9 changes: 8 additions & 1 deletion documentation/resources/corretto_install.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

[back to resource list](https://github.com/sous-chefs/java#resources)

Installs Amazon Corretto Java distribution. This resource handles downloading, extracting and configuring Amazon's Corretto distribution of OpenJDK, including setting up Java home directories and configuring system alternatives.

Introduced: v8.0.0

## Actions
Expand All @@ -22,10 +24,11 @@ Introduced: v8.0.0
| java_home_mode | Integer, String | `0755` | The permission for the Java home directory |
| java_home_owner | String | `root` | Owner of the Java Home |
| java_home_group | String | `node['root_group']` | Group for the Java Home |
| default | Boolean | `true` | Whether to set this as the defalut Java |
| default | Boolean | `true` | Whether to set this as the default Java |
| bin_cmds | Array | `default_corretto_bin_cmds(version)` | A list of bin_cmds based on the version and variant |
| alternatives_priority | Integer | `1` | Alternatives priority to set for this Java |
| reset_alternatives | Boolean | `true` | Whether to reset alternatives before setting |
| skip_alternatives | Boolean | `false` | Skip alternatives installation completely |

## Examples

Expand All @@ -42,3 +45,7 @@ corretto_install '8' do
alternatives_priority 2
end
```

## Architecture Support

This resource supports installation on both x86_64 and ARM64 architectures. Amazon Corretto provides architecture-specific builds and the resource automatically handles the correct paths and downloads for the target platform.
5 changes: 4 additions & 1 deletion documentation/resources/openjdk_install.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

[back to resource list](https://github.com/sous-chefs/java#resources)

Installs OpenJDK Java via source or package manager. This resource selects the appropriate installation method based on the `install_type` property and handles cross-platform Java installation including alternatives configuration.

Introduced: v8.0.0

## Actions
Expand All @@ -21,10 +23,11 @@ Introduced: v8.0.0
| java_home_mode | Integer, String | | The permission for the Java home directory | |
| java_home_owner | String | | Owner of the Java Home | |
| java_home_group | String | | Group for the Java Home | |
| default | Boolean | | Whether to set this as the defalut Java | |
| default | Boolean | | Whether to set this as the default Java | |
| bin_cmds | Array | | A list of bin_cmds based on the version and variant | |
| alternatives_priority | Integer | | Alternatives priority to set for this Java | |
| reset_alternatives | Boolean | | Whether to reset alternatives before setting | |
| skip_alternatives | Boolean | `false` | Skip alternatives installation completely | |
| pkg_names | Array | | List of packages to install | |
| pkg_version | String | | Package version to install | |
| install_type | String | | Installation type | `package` `source` |
Expand Down
9 changes: 8 additions & 1 deletion documentation/resources/openjdk_pkg_install.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

[back to resource list](https://github.com/sous-chefs/java#resources)

Installs OpenJDK Java packages from the system's package manager. This resource handles platform-specific package installation for OpenJDK across different Linux distributions and versions, and configures the alternatives system appropriately.

Introduced: v8.1.0

## Actions
Expand All @@ -18,10 +20,11 @@ Introduced: v8.1.0
| pkg_names | Array | `default_openjdk_pkg_names(version)` | List of packages to install |
| pkg_version | String | `nil` | Package version to install |
| java_home | String | Based on the version | Set to override the java_home |
| default | Boolean | `true` | Whether to set this as the defalut Java |
| default | Boolean | `true` | Whether to set this as the default Java |
| bin_cmds | Array | `default_bin_cmds(version)` | A list of bin_cmds based on the version and variant |
| alternatives_priority | Integer | `1062` | Alternatives priority to set for this Java |
| reset_alternatives | Boolean | `true` | Whether to reset alternatives before setting |
| skip_alternatives | Boolean | `false` | Skip alternatives installation completely |

## Examples

Expand All @@ -38,3 +41,7 @@ openjdk_pkg_install '11' do
alternatives_priority 2
end
```

## Architecture Support

This resource supports installation on both x86_64 and ARM64 architectures. On ARM64 platforms (like ARM Macs or ARM-based cloud instances), package paths may include architecture-specific suffixes in paths (e.g., `-arm64` or `-aarch64`).
7 changes: 5 additions & 2 deletions documentation/resources/openjdk_source_install.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@

# openjdk_install
# openjdk_source_install

[back to resource list](https://github.com/sous-chefs/java#resources)

Installs OpenJDK Java from source archives. This resource handles downloading, extracting, and configuring OpenJDK from source tarballs, including setting up the Java home directory and alternatives system entries.

Introduced: v8.0.0

## Actions
Expand All @@ -21,10 +23,11 @@ Introduced: v8.0.0
| java_home_mode | Integer, String | `0755` | The permission for the Java home directory |
| java_home_owner | String | `root` | Owner of the Java Home |
| java_home_group | String | `node['root_group']` | Group for the Java Home |
| default | Boolean | `true` | Whether to set this as the defalut Java |
| default | Boolean | `true` | Whether to set this as the default Java |
| bin_cmds | Array | `default_bin_cmds(version)` | A list of bin_cmds based on the version and variant |
| alternatives_priority | Integer | `1` | Alternatives priority to set for this Java |
| reset_alternatives | Boolean | `true` | Whether to reset alternatives before setting |
| skip_alternatives | Boolean | `false` | Skip alternatives installation completely |

## Examples

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
# temurin_package_install

[back to resource list](https://github.com/sous-chefs/java#resources)

Installs Java Temurin (AdoptOpenJDK) packages provided by Adoptium. This resource handles the repository setup and package installation for Temurin JDK packages across various platforms.

Introduced: v12.0.0

## Actions

- `:install` - Installs Temurin JDK packages
Expand All @@ -19,6 +23,21 @@ Installs Java Temurin (AdoptOpenJDK) packages provided by Adoptium. This resourc
| `alternatives_priority` | Integer | 1062 | Priority for alternatives system |
| `reset_alternatives` | Boolean | true | Whether to reset alternatives before setting |
| `default` | Boolean | true | Whether to set this as the default Java |
| `skip_alternatives` | Boolean | false | Skip alternatives installation completely |

## Platform Support

- Debian/Ubuntu: Uses apt_repository with `signed_by false` and `trusted true` options to bypass GPG signature verification issues
- Amazon Linux/CentOS/RHEL: Uses yum_repository with standard configuration
- SUSE: Uses zypper_repository with standard configuration

## Architecture Support

This resource supports installation on both x86_64 and ARM64 architectures. On ARM64 platforms (like ARM Macs or ARM-based cloud instances), the package paths may include architecture-specific suffixes (e.g., `/usr/lib/jvm/temurin-8-jdk-arm64/bin/java`).

## Notes

- Due to a bug in Chef's apt_repository resource ([PR #15043](https://github.com/chef/chef/pull/15043)), GPG key verification is disabled by default on Debian-family systems to ensure the repository can be used successfully

## Examples

Expand Down
2 changes: 1 addition & 1 deletion resources/corretto_install.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
priority new_resource.alternatives_priority
default new_resource.default
reset_alternatives new_resource.reset_alternatives
action :set
not_if { new_resource.skip_alternatives }
end
end

Expand Down
4 changes: 4 additions & 0 deletions resources/openjdk_install.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
java_home new_resource.java_home
default new_resource.default
bin_cmds new_resource.bin_cmds
skip_alternatives new_resource.skip_alternatives
alternatives_priority new_resource.alternatives_priority
reset_alternatives new_resource.reset_alternatives
end
Expand All @@ -59,6 +60,7 @@
java_home_group new_resource.java_home_group
default new_resource.default
bin_cmds new_resource.bin_cmds
skip_alternatives new_resource.skip_alternatives
alternatives_priority new_resource.alternatives_priority
reset_alternatives new_resource.reset_alternatives
end
Expand All @@ -75,6 +77,7 @@
java_home new_resource.java_home
default new_resource.default
bin_cmds new_resource.bin_cmds
skip_alternatives new_resource.skip_alternatives
alternatives_priority new_resource.alternatives_priority
reset_alternatives new_resource.reset_alternatives
action :remove
Expand All @@ -88,6 +91,7 @@
java_home_group new_resource.java_home_group
default new_resource.default
bin_cmds new_resource.bin_cmds
skip_alternatives new_resource.skip_alternatives
alternatives_priority new_resource.alternatives_priority
reset_alternatives new_resource.reset_alternatives
action :remove
Expand Down
1 change: 1 addition & 0 deletions resources/openjdk_pkg_install.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
priority new_resource.alternatives_priority
default new_resource.default
reset_alternatives new_resource.reset_alternatives
skip_alternatives new_resource.skip_alternatives
action :set
end
end
Expand Down
2 changes: 2 additions & 0 deletions resources/openjdk_source_install.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
priority new_resource.alternatives_priority
default new_resource.default
reset_alternatives new_resource.reset_alternatives
not_if { new_resource.skip_alternatives }
action :set
end

Expand All @@ -77,6 +78,7 @@
java_location new_resource.java_home
bin_cmds new_resource.bin_cmds
only_if { ::File.exist?(extract_dir) }
not_if { new_resource.skip_alternatives }
action :unset
end

Expand Down
4 changes: 4 additions & 0 deletions resources/partial/_common.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
property :version, String,
name_property: true,
description: 'Java version to install'

property :skip_alternatives, [true, false],
default: false,
description: 'Skip alternatives installation'
2 changes: 2 additions & 0 deletions resources/temurin_package_install.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ def default_temurin_pkg_name(version)
priority new_resource.alternatives_priority
default new_resource.default
reset_alternatives new_resource.reset_alternatives
not_if { new_resource.skip_alternatives }
end
end

Expand All @@ -91,6 +92,7 @@ def default_temurin_pkg_name(version)
bin_cmds new_resource.bin_cmds
only_if { ::File.exist?(new_resource.java_home) }
action :unset
not_if { new_resource.skip_alternatives }
end

package new_resource.pkg_name do
Expand Down