Skip to content

Commit 057fe87

Browse files
author
jtimberman
committed
[COOK-2903] - move java_home resources to their own recipe
1 parent d8fdc40 commit 057fe87

File tree

4 files changed

+39
-36
lines changed

4 files changed

+39
-36
lines changed

recipes/openjdk.rb

+1-15
Original file line numberDiff line numberDiff line change
@@ -35,21 +35,7 @@
3535
"default" => ["openjdk-#{jdk_version}-jdk"]
3636
)
3737

38-
# done by special request for rberger
39-
ruby_block "set-env-java-home" do
40-
block do
41-
ENV["JAVA_HOME"] = java_home
42-
end
43-
not_if { ENV["JAVA_HOME"] == java_home }
44-
end
45-
46-
file "/etc/profile.d/jdk.sh" do
47-
content <<-EOS
48-
export JAVA_HOME=#{node['java']['java_home']}
49-
EOS
50-
mode 0755
51-
end
52-
38+
include_recipe "java::set_java_home"
5339

5440
if platform?("ubuntu","debian","redhat","centos","fedora","scientific","amazon","oracle")
5541
ruby_block "update-java-alternatives" do

recipes/oracle.rb

+1-14
Original file line numberDiff line numberDiff line change
@@ -42,20 +42,7 @@
4242
Chef::Application.fatal!("You must change the download link to your private repository. You can no longer download java directly from http://download.oracle.com without a web broswer")
4343
end
4444

45-
ruby_block "set-env-java-home" do
46-
block do
47-
ENV["JAVA_HOME"] = java_home
48-
end
49-
not_if { ENV["JAVA_HOME"] == java_home }
50-
end
51-
52-
file "/etc/profile.d/jdk.sh" do
53-
content <<-EOS
54-
export JAVA_HOME=#{node['java']['java_home']}
55-
EOS
56-
mode 0755
57-
end
58-
45+
include_recipe "java::set_java_home"
5946

6047
java_ark "jdk" do
6148
url tarball_url

recipes/oracle_i386.rb

+2-7
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,7 @@
3030
bin_cmds = node['java']['jdk']['7']['bin_cmds']
3131
end
3232

33-
ruby_block "set-env-java-home" do
34-
block do
35-
ENV["JAVA_HOME"] = java_home
36-
end
37-
not_if { ENV["JAVA_HOME"] == java_home }
38-
end
33+
include_recipe "java::set_java_home"
3934

4035
yum_package "glibc" do
4136
arch "i686"
@@ -45,7 +40,7 @@
4540
java_ark "jdk-alt" do
4641
url tarball_url
4742
checksum tarball_checksum
48-
app_home java_home
43+
app_home java_home
4944
bin_cmds bin_cmds
5045
action :install
5146
default false

recipes/set_java_home.rb

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Author:: Joshua Timberman (<[email protected]>)
2+
# Cookbook Name:: java
3+
# Recipe:: set_java_home
4+
#
5+
# Copyright 2013, Opscode, Inc.
6+
#
7+
# Licensed under the Apache License, Version 2.0 (the "License");
8+
# you may not use this file except in compliance with the License.
9+
# You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS,
15+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
# See the License for the specific language governing permissions and
17+
# limitations under the License.
18+
19+
ruby_block "set-env-java-home" do
20+
block do
21+
ENV["JAVA_HOME"] = node['java']['java_home']
22+
end
23+
not_if { ENV["JAVA_HOME"] == node['java']['java_home'] }
24+
end
25+
26+
directory "/etc/profile.d" do
27+
mode 00755
28+
end
29+
30+
file "/etc/profile.d/jdk.sh" do
31+
content <<-EOS.gsub(/^\s+/, '')
32+
export JAVA_HOME=#{node['java']['java_home']}
33+
EOS
34+
mode 00755
35+
end

0 commit comments

Comments
 (0)