Create playbook which installs and configures an Android SDK. Ensures Flutter has everything it needs for Android deployment.
This commit is contained in:
parent
07ba3e8e35
commit
d0d5a5306b
@ -156,6 +156,9 @@
|
|||||||
- include_tasks: tasks/workstation/linux/software/flutter.yml
|
- include_tasks: tasks/workstation/linux/software/flutter.yml
|
||||||
when: ansible_system == "Linux"
|
when: ansible_system == "Linux"
|
||||||
|
|
||||||
|
- include_tasks: tasks/workstation/linux/software/android.yml
|
||||||
|
when: ansible_system == "Linux"
|
||||||
|
|
||||||
- include_tasks: tasks/workstation/linux/software/flatpaks.yml
|
- include_tasks: tasks/workstation/linux/software/flatpaks.yml
|
||||||
when: ansible_system == "Linux" and flatpak_distro
|
when: ansible_system == "Linux" and flatpak_distro
|
||||||
|
|
||||||
|
196
tasks/workstation/linux/software/android.yml
Normal file
196
tasks/workstation/linux/software/android.yml
Normal file
@ -0,0 +1,196 @@
|
|||||||
|
---
|
||||||
|
# Android Studio (and SDK?). Copied and adjusted from Flutter playbook.
|
||||||
|
# https://wiki.debian.org/AndroidStudio
|
||||||
|
# https://developer.android.com/studio/install
|
||||||
|
|
||||||
|
## Facts ##
|
||||||
|
|
||||||
|
# Studio download URLs:
|
||||||
|
# https://developer.android.com/studio/archive
|
||||||
|
# Current version:
|
||||||
|
# https://redirector.gvt1.com/edgedl/android/studio/ide-zips/2024.2.2.14/android-studio-2024.2.2.14-linux.tar.gz
|
||||||
|
# Command-line tools is all Flutter actually needs:
|
||||||
|
# https://dl.google.com/android/repository/commandlinetools-linux-11076708_latest.zip
|
||||||
|
|
||||||
|
- name: Workstation | Linux | Software | Android | Facts [1/2]
|
||||||
|
set_fact:
|
||||||
|
android_url: "https://dl.google.com/android/repository/commandlinetools-linux-11076708_latest.zip"
|
||||||
|
android_download_file: "{{ user_user.home }}/Downloads/android-cmdline-tools.tar.xz"
|
||||||
|
android_sdk_location: "{{ user_user.home }}/SDKs/Android/Sdk"
|
||||||
|
|
||||||
|
- name: Workstation | Linux | Software | Android | Facts [2/2]
|
||||||
|
set_fact:
|
||||||
|
android_bin_location: "{{ android_sdk_location }}/platform-tools"
|
||||||
|
android_sdkmanager: "{{ android_sdk_location }}/cmdline-tools/bin/sdkmanager"
|
||||||
|
|
||||||
|
## Checks ##
|
||||||
|
|
||||||
|
- name: Workstation | Linux | Software | Android | Check SDK Exists
|
||||||
|
stat:
|
||||||
|
path: "{{ android_bin_location }}"
|
||||||
|
register: android_sdk_stat
|
||||||
|
|
||||||
|
- name: Workstation | Linux | Software | Android | Check Download Exists
|
||||||
|
stat:
|
||||||
|
path: "{{ android_download_file }}"
|
||||||
|
register: android_download_stat
|
||||||
|
|
||||||
|
## Packages ##
|
||||||
|
|
||||||
|
# https://docs.flutter.dev/get-started/install/linux/android
|
||||||
|
- name: Workstation | Linux | Software | Android | Dependencies [Install]
|
||||||
|
package:
|
||||||
|
name:
|
||||||
|
- default-jdk
|
||||||
|
- libc6
|
||||||
|
- libncurses5
|
||||||
|
- libstdc++6
|
||||||
|
- lib32z1
|
||||||
|
- libbz2-1.0
|
||||||
|
state: present
|
||||||
|
when: coding == true
|
||||||
|
|
||||||
|
- name: Workstation | Linux | Software | Android | Dependencies [Remove]
|
||||||
|
package:
|
||||||
|
name:
|
||||||
|
- sdkmanager
|
||||||
|
state: absent
|
||||||
|
when: coding == true
|
||||||
|
|
||||||
|
## Install SDK ##
|
||||||
|
|
||||||
|
- name: Workstation | Linux | Software | Android | SDK
|
||||||
|
block:
|
||||||
|
|
||||||
|
- name: Workstation | Linux | Software | Android | Download Commandline Tools
|
||||||
|
get_url:
|
||||||
|
url: "{{ android_url }}"
|
||||||
|
dest: "{{ android_download_file }}"
|
||||||
|
owner: "{{ user }}"
|
||||||
|
group: "{{ user }}"
|
||||||
|
mode: '0664'
|
||||||
|
when: not android_download_stat.stat.exists
|
||||||
|
|
||||||
|
- name: Workstation | Linux | Software | Android | Create Folder
|
||||||
|
file:
|
||||||
|
path: "{{ android_sdk_location }}"
|
||||||
|
state: directory
|
||||||
|
owner: "{{ user }}"
|
||||||
|
group: "{{ user }}"
|
||||||
|
mode: '0755'
|
||||||
|
|
||||||
|
- name: Workstation | Linux | Software | Android | Extract Tools
|
||||||
|
unarchive:
|
||||||
|
src: "{{ android_download_file }}"
|
||||||
|
dest: "{{ android_sdk_location }}"
|
||||||
|
owner: "{{ user }}"
|
||||||
|
group: "{{ user }}"
|
||||||
|
|
||||||
|
when: coding == true and not android_sdk_stat.stat.exists
|
||||||
|
|
||||||
|
- name: Workstation | Linux | Software | Android | Delete Archive
|
||||||
|
file:
|
||||||
|
path: "{{ android_download_file }}"
|
||||||
|
state: absent
|
||||||
|
|
||||||
|
## Configure Modules ##
|
||||||
|
|
||||||
|
- name: Workstation | Linux | Software | Android | Install Modules
|
||||||
|
shell: "yes | {{ android_sdkmanager }} '{{ item }}' --sdk_root={{ android_sdk_location }}"
|
||||||
|
loop:
|
||||||
|
# latest
|
||||||
|
- cmdline-tools;latest
|
||||||
|
- platform-tools
|
||||||
|
- emulator
|
||||||
|
# 34
|
||||||
|
- build-tools;34.0.0
|
||||||
|
- platforms;android-34
|
||||||
|
- sources;android-34
|
||||||
|
# 35
|
||||||
|
- build-tools;35.0.0
|
||||||
|
- build-tools;35.0.1
|
||||||
|
- platforms;android-35
|
||||||
|
- sources;android-35
|
||||||
|
# Images
|
||||||
|
- system-images;android-35;default;x86_64
|
||||||
|
- system-images;android-35;aosp_atd;x86_64
|
||||||
|
- system-images;android-35;google_apis_playstore;x86_64
|
||||||
|
become_user: "{{ user }}"
|
||||||
|
|
||||||
|
- name: Workstation | Linux | Software | Android | Update Modules
|
||||||
|
shell: "yes | {{ android_sdkmanager }} --update --sdk_root={{ android_sdk_location }}"
|
||||||
|
become_user: "{{ user }}"
|
||||||
|
|
||||||
|
- name: Workstation | Linux | Software | Android | Inform Flutter
|
||||||
|
shell: "{{ flutter }} config --android-sdk={{ android_sdk_location }}"
|
||||||
|
become_user: "{{ user }}"
|
||||||
|
|
||||||
|
- name: Workstation | Linux | Software | Android | License Agreements
|
||||||
|
shell: "yes | {{ flutter }} doctor --android-licenses"
|
||||||
|
become_user: "{{ user }}"
|
||||||
|
|
||||||
|
- name: Workstation | Linux | Software | Android | Refresh Flutter Doctor Report
|
||||||
|
shell: "{{ item }}"
|
||||||
|
loop: "{{ flutter_report_commands }}"
|
||||||
|
become_user: "{{ user }}"
|
||||||
|
when: coding == true
|
||||||
|
|
||||||
|
## Configure Environment ##
|
||||||
|
|
||||||
|
- name: Workstation | Linux | Software | Android | Modify PATH (.bashrc)
|
||||||
|
blockinfile:
|
||||||
|
path: "{{ item }}/.bashrc"
|
||||||
|
block: |
|
||||||
|
export PATH="$PATH:{{ android_bin_location }}"
|
||||||
|
marker: '# {mark} MANAGED BY ANSIBLE | Android'
|
||||||
|
state: present
|
||||||
|
create: yes
|
||||||
|
backup: yes
|
||||||
|
loop:
|
||||||
|
- "{{ user_root.home }}"
|
||||||
|
- "{{ user_user.home }}"
|
||||||
|
ignore_errors: yes
|
||||||
|
when: coding == true and user_root.home != "" and user_user.home != ""
|
||||||
|
|
||||||
|
- name: Workstation | Linux | Software | Android | Modify PATH (.zshrc)
|
||||||
|
blockinfile:
|
||||||
|
path: "{{ item }}/.zshrc"
|
||||||
|
block: |
|
||||||
|
export PATH="$PATH:{{ android_bin_location }}"
|
||||||
|
marker: '# {mark} MANAGED BY ANSIBLE | Android'
|
||||||
|
state: present
|
||||||
|
create: yes
|
||||||
|
backup: yes
|
||||||
|
loop:
|
||||||
|
- "{{ user_root.home }}"
|
||||||
|
- "{{ user_user.home }}"
|
||||||
|
ignore_errors: yes
|
||||||
|
when: coding == true and user_root.home != "" and user_user.home != ""
|
||||||
|
|
||||||
|
## Uninstall SDK ##
|
||||||
|
|
||||||
|
- name: Workstation | Linux | Software | Android | Remove SDK
|
||||||
|
file:
|
||||||
|
path: "{{ android_sdk_location }}"
|
||||||
|
state: absent
|
||||||
|
when: not coding == true
|
||||||
|
|
||||||
|
## User Tools ##
|
||||||
|
# Only needed from repo if not a development device,
|
||||||
|
# otherwise better versions are in the SDK.
|
||||||
|
|
||||||
|
- name: Workstation | Linux | Software | Android | System Tools [Install]
|
||||||
|
package:
|
||||||
|
name:
|
||||||
|
- fastboot
|
||||||
|
- adb
|
||||||
|
state: present
|
||||||
|
when: not coding == true
|
||||||
|
|
||||||
|
- name: Workstation | Linux | Software | Android | System Tools [Remove]
|
||||||
|
package:
|
||||||
|
name:
|
||||||
|
- fastboot
|
||||||
|
- adb
|
||||||
|
state: absent
|
||||||
|
when: coding == true
|
Loading…
x
Reference in New Issue
Block a user