Module: Calabash::Android::Dependencies

Defined in:
lib/calabash-android/dependencies.rb

Defined Under Namespace

Classes: ScanningTimedOutError

Class Method Summary collapse

Class Method Details

.aapt_pathObject



63
64
65
# File 'lib/calabash-android/dependencies.rb', line 63

def self.aapt_path
    android_dependencies(:aapt_path)
end

.adb_pathObject



59
60
61
# File 'lib/calabash-android/dependencies.rb', line 59

def self.adb_path
    android_dependencies(:adb_path)
end

.android_jar_pathObject



71
72
73
# File 'lib/calabash-android/dependencies.rb', line 71

def self.android_jar_path
    android_dependencies(:android_jar_path)
end

.ant_pathObject



87
88
89
# File 'lib/calabash-android/dependencies.rb', line 87

def self.ant_path
    java_dependencies(:ant_path)
end

.jarsigner_pathObject



83
84
85
# File 'lib/calabash-android/dependencies.rb', line 83

def self.jarsigner_path
    java_dependencies(:jarsigner_path)
end

.java_pathObject



75
76
77
# File 'lib/calabash-android/dependencies.rb', line 75

def self.java_path
    java_dependencies(:java_path)
end

.keytool_pathObject



79
80
81
# File 'lib/calabash-android/dependencies.rb', line 79

def self.keytool_path
    java_dependencies(:keytool_path)
end

.setupObject



91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
# File 'lib/calabash-android/dependencies.rb', line 91

def self.setup
    if ENV['CI_NO_ANDROID_RUNTIME'] == '1'
        @@android_dependencies = {}
        @@java_dependencies = {}
        return
    end

    @@halt_scanning = false
    @@halt_scanning_thread = nil

    if ENV['ANDROID_HOME']
        android_sdk_location = ENV['ANDROID_HOME']
        Logging.log_debug("Setting Android SDK location to $ANDROID_HOME")
    else
        android_sdk_location = detect_android_sdk_location
    end

    if android_sdk_location.nil?
        Logging.log_error 'Could not find an Android SDK please make sure it is installed.'
        Logging.log_error 'You can read about how Calabash is searching for an Android SDK and how you can help here:'
        Logging.log_error 'https://github.com/calabash/calabash-android/blob/master/documentation/installation.md#prerequisites'

        raise 'Could not find an Android SDK'
    end

    Logging.log_debug("Android SDK location set to '#{android_sdk_location}'")

    @@halt_scanning_thread = Thread.new do
        sleep 60
        @@halt_scanning = true
    end

    begin
        set_android_dependencies(locate_android_dependencies(android_sdk_location))
    rescue ScanningTimedOutError => e
        Logging.log_error 'Timed out locating Android dependency'
        Logging.log_error 'You can read about how Calabash is searching for an Android SDK and how you can help here:'
        Logging.log_error 'https://github.com/calabash/calabash-android/blob/master/documentation/installation.md#prerequisites'

        raise e.message
    rescue Environment::InvalidEnvironmentError => e
        Logging.log_error 'Could not locate Android dependency'
        Logging.log_error 'You can read about how Calabash is searching for an Android SDK and how you can help here:'
        Logging.log_error 'https://github.com/calabash/calabash-android/blob/master/documentation/installation.md#prerequisites'

        raise e
    end

    if ENV['JAVA_HOME']
        java_sdk_home = ENV['JAVA_HOME']
        Logging.log_debug("Setting Java SDK location to $JAVA_HOME")
    else
        java_sdk_home = detect_java_sdk_location
    end

    Logging.log_debug("Java SDK location set to '#{java_sdk_home}'")

    Thread.kill(@@halt_scanning_thread) if @@halt_scanning_thread
    @@halt_scanning = false

    @@halt_scanning_thread = Thread.new do
        sleep 60
        @@halt_scanning = true
    end

    begin
        set_java_dependencies(locate_java_dependencies(java_sdk_home))
    rescue ScanningTimedOutError => e
        Logging.log_error 'Timed out locating Java dependency'
        Logging.log_error "You can read about how Calabash is searching for a JDK and how you can help here:"
        Logging.log_error "https://github.com/calabash/calabash-android/blob/master/documentation/installation.md#prerequisites"

        raise e.message
    rescue Environment::InvalidJavaSDKHome => e
        Logging.log_error "Could not find Java Development Kit please make sure it is installed."
        Logging.log_error "You can read about how Calabash is searching for a JDK and how you can help here:"
        Logging.log_error "https://github.com/calabash/calabash-android/blob/master/documentation/installation.md#prerequisites"

        raise e
    rescue Environment::InvalidEnvironmentError => e
        Logging.log_error "Could not find Java dependency"
        Logging.log_error "You can read about how Calabash is searching for a JDK and how you can help here:"
        Logging.log_error "https://github.com/calabash/calabash-android/blob/master/documentation/installation.md#prerequisites"

        raise e
    end

    Thread.kill(@@halt_scanning_thread) if @@halt_scanning_thread
end

.zipalign_pathObject



67
68
69
# File 'lib/calabash-android/dependencies.rb', line 67

def self.zipalign_path
    android_dependencies(:zipalign_path)
end