ansible-desktop/roles/flutter/tasks/install-android-sdk.yml

62 lines
1.6 KiB
YAML

- name: create android-sdk directory
become: yes
file:
path: "{{ android.dir }}"
state: directory
owner: "{{ ansible_user_id }}"
- name: Create temp dir
file:
path: "{{ tmp_dir }}"
state: directory
- name: "Download Android studio"
unarchive:
src: "https://dl.google.com/android/repository/commandlinetools-linux-{{ android.commandlinetools.version }}.zip"
dest: "{{ tmp_dir }}"
remote_src: yes
- name: get folder name
shell: ls "{{ tmp_dir }}"
register: dir_name
- name: create android-sdk cmdline-tools directory
become: yes
file:
path: "{{ android.dir }}/cmdline-tools"
state: directory
owner: "{{ ansible_user_id }}"
- name: Copy to final directory
command: "cp -ra {{ tmp_dir }}/{{ dir_name.stdout }} {{ android.dir }}/cmdline-tools/latest"
- name: Remove temp directory
file:
path: "{{ tmp_dir }}"
state: absent
- name: Create symbolic link for sdkmanager
become: yes
file:
src: "{{ android.dir }}/cmdline-tools/latest/bin/sdkmanager"
dest: "/usr/local/bin/sdkmanager"
state: link
- name: Create symbolic link for avdmanager
become: yes
file:
src: "{{ android.dir }}/cmdline-tools/latest/bin/avdmanager"
dest: "/usr/local/bin/avdmanager"
state: link
- name: Install SDK
shell:
cmd: |
yes | sdkmanager --licenses
sdkmanager --install "build-tools;{{ android.sdk.version }}.0.0"
sdkmanager --install "emulator"
sdkmanager --install "patcher;v4"
sdkmanager --install "platform-tools"
sdkmanager --install "platforms;android-{{ android.sdk.version }}"
sdkmanager --install "sources;android-{{ android.sdk.version }}"