forked from gildegoma/chef-android-sdk
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmaven-rescue.rb
66 lines (56 loc) · 3 KB
/
maven-rescue.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# TODO: decide which way we depend on maven (weak dependency, conditional include_recipe or always include_recipe?)
# include_recipe "maven"
#
# Install Maven Android SDK Deployer from tarball package, but it also could make sense
# to clone the git repository (especially when provisioning a developer box)
#
ark node['android-sdk']['maven-android-sdk-deployer']['name'] do
url node['android-sdk']['maven-android-sdk-deployer']['download_url']
# TODO: checksum check here is maybe overkill optimization without real safety added value
checksum node['android-sdk']['maven-android-sdk-deployer']['checksum']
version node['android-sdk']['maven-android-sdk-deployer']['version']
prefix_root node['android-sdk']['setup_root']
prefix_home node['android-sdk']['setup_root']
append_env_path false
owner node['android-sdk']['owner']
group node['android-sdk']['group']
end
maven_android_sdk_deployer_root = node['android-sdk']['setup_root'].to_s.empty? ? node['ark']['prefix_home'] : node['android-sdk']['setup_root']
maven_android_sdk_deployer_home = File.join(maven_android_sdk_deployer_root, node['android-sdk']['maven-android-sdk-deployer']['name'])
#
# Deploy Android SDK jar files to a Maven local repository
# TODO: fix a few target name mismatches in the extra folder (fe. admob, google-play-services-for-froyo, ...)
#
# Loop over node['android-sdk']['components'],
# convert android component name to the target names used in maven-android-sdk-deployer
# and generate `mvn -pl component1,component2,... install` command.
#
components = Array.new
node['android-sdk']['components'].each do |sdk_component|
# android APIs
if sdk_component =~ /android-[0-9]+/
components << sdk_component.sub("android", "platforms/android")
# android and GDK addon APIs
elsif sdk_component =~ /addon-google_(apis|gdk)-google-[0-9]+/
components << sdk_component.sub("addon-google_", "add-ons/google-").sub("-google","")
# m2 repositories
elsif sdk_component =~ /extra-(google|android)-m2repository/
components << sdk_component.sub("extra-", "repositories/")
# extras
elsif sdk_component =~ /extra-google-+/
components << sdk_component.sub("extra-google-", "extras/").gsub("_","-")
end
end
# only run maven-android-sdk-deployer when targets are defined
if components.length > 0
execute 'Execute maven-android-sdk-deployer' do
command "mvn clean install -pl #{components.join(",")} -Dmaven.repo.local=#{node['android-sdk']['maven-local-repository']} --fail-never -B"
user node['android-sdk']['owner']
group node['android-sdk']['group']
cwd maven_android_sdk_deployer_home
# FIXME: setting HOME might be required (if $HOME used in node['android-sdk']['maven-local-repository'],
# or if -Dmaven.repo.local is unset (default to ~/.m2/repository)
# environment ({ 'HOME' => '/home/vagrant' })
# Note: There is no idempotent guard for now. Pending on https://github.com/gildegoma/chef-android-sdk/issues/12.
end
end