Skip to content

Commit 81baabe

Browse files
committed
fix: set JAVA_HOME before install Android SDK
1 parent ec2187a commit 81baabe

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

native-script.rb

+9-6
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,18 @@ def install_environment_variable(name, value)
105105
# Allow brew to lookup versions
106106
execute("brew tap caskroom/versions", "", false)
107107

108+
# Install Google Chrome
108109
install("Google Chrome", "Installing Google Chrome (required to debug NativeScript apps)", "brew cask install google-chrome", false, false);
110+
111+
# Install JDK 1.8
109112
install("Java SE Development Kit 8", "Installing the Java SE Development Kit 8 ... This might take some time, please, be patient. (You will be prompted for your password)", 'brew cask install java8', false, false)
110-
install("Android SDK", "Installing Android SDK", 'brew tap caskroom/cask; brew cask install android-sdk', false)
113+
unless ENV["JAVA_HOME"]
114+
puts "Set JAVA_HOME=$(/usr/libexec/java_home -v 1.8)"
115+
install_environment_variable("JAVA_HOME", "$(/usr/libexec/java_home -v 1.8)")
116+
end
111117

118+
# Install Android SDK
119+
install("Android SDK", "Installing Android SDK", 'brew tap caskroom/cask; brew cask install android-sdk', false)
112120
unless ENV["ANDROID_HOME"]
113121
require 'pathname'
114122
android_home = "/usr/local/share/android-sdk"
@@ -121,14 +129,9 @@ def install_environment_variable(name, value)
121129
android_home = Pathname.new(android_home_joined_path).realpath
122130
end
123131
end
124-
125132
install_environment_variable("ANDROID_HOME", android_home)
126133
end
127134

128-
unless ENV["JAVA_HOME"]
129-
install_environment_variable("JAVA_HOME", "/Library/Java/Home")
130-
end
131-
132135
# the -p flag is set in order to ensure zero status code even if the directory exists
133136
execute("mkdir -p ~/.cocoapods", "There was a problem in creating ~/.cocoapods directory")
134137
# CocoaPods already has a dependency to xcodeproj and also has a dependency to a lower version of activesupport

0 commit comments

Comments
 (0)