Install android sdk with flutter
This commit is contained in:
parent
9c26b5df18
commit
06c26a8aaa
61
roles/flutter/tasks/install-android-sdk.yml
Normal file
61
roles/flutter/tasks/install-android-sdk.yml
Normal file
@ -0,0 +1,61 @@
|
||||
- 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 }}"
|
@ -1,19 +1,12 @@
|
||||
- name: install jmespath for json_query
|
||||
become: yes
|
||||
apt:
|
||||
update_cache: yes
|
||||
pkg:
|
||||
- python3-jmespath
|
||||
|
||||
- name: Create temp dir
|
||||
file:
|
||||
path: "{{ tmp_dir }}"
|
||||
state: directory
|
||||
|
||||
- name: "Flutter"
|
||||
- name: "Install Flutter"
|
||||
become: yes
|
||||
unarchive:
|
||||
src: "https://storage.googleapis.com/flutter_infra_release/releases/stable/linux/flutter_linux_{{ version }}-stable.tar.xz"
|
||||
src: "https://storage.googleapis.com/flutter_infra_release/releases/stable/linux/flutter_linux_{{ flutter.version }}-stable.tar.xz"
|
||||
dest: "{{ tmp_dir }}"
|
||||
remote_src: yes
|
||||
|
||||
@ -23,7 +16,7 @@
|
||||
|
||||
- name: Copy to final directory
|
||||
become: yes
|
||||
command: "cp -ra {{ tmp_dir }}/{{ dir_name.stdout }} {{ flutter_dir }}"
|
||||
command: "cp -ra {{ tmp_dir }}/{{ dir_name.stdout }} {{ flutter.dir }}"
|
||||
|
||||
- name: Remove temp directory
|
||||
become: yes
|
||||
@ -34,13 +27,13 @@
|
||||
- name: Create symbolic link for flutter
|
||||
become: yes
|
||||
file:
|
||||
src: "/opt/flutter/bin/flutter"
|
||||
src: "{{ flutter.dir }}/bin/flutter"
|
||||
dest: "/usr/local/bin/flutter"
|
||||
state: link
|
||||
|
||||
- name: Create symbolic link for dart
|
||||
become: yes
|
||||
file:
|
||||
src: "/opt/flutter/bin/dart"
|
||||
src: "{{ flutter.dir }}/bin/dart"
|
||||
dest: "/usr/local/bin/dart"
|
||||
state: link
|
@ -1,8 +1,23 @@
|
||||
- name: Check if old version exists
|
||||
- name: install jmespath for json_query
|
||||
become: yes
|
||||
apt:
|
||||
pkg:
|
||||
- python3-jmespath
|
||||
|
||||
- name: Check if flutter has been installed
|
||||
stat:
|
||||
path: "{{ flutter_dir }}"
|
||||
path: "{{ flutter.dir }}"
|
||||
register: flutter_dir_status
|
||||
|
||||
- import_tasks: install.yml
|
||||
- import_tasks: install-flutter.yml
|
||||
when:
|
||||
- not flutter_dir_status.stat.exists
|
||||
- not flutter_dir_status.stat.exists
|
||||
|
||||
- name: Check if android-sdk has been installed
|
||||
stat:
|
||||
path: "{{ android.dir }}"
|
||||
register: android_sdk_dir_status
|
||||
|
||||
- import_tasks: install-android-sdk.yml
|
||||
when:
|
||||
- not android_sdk_dir_status.stat.exists
|
@ -1,4 +1,11 @@
|
||||
---
|
||||
tmp_dir: /tmp/flutter
|
||||
flutter_dir: /opt/flutter
|
||||
version: 3.13.0
|
||||
flutter:
|
||||
dir: /opt/flutter
|
||||
version: 3.13.0
|
||||
android:
|
||||
dir: /opt/android-sdk
|
||||
sdk:
|
||||
version: 34
|
||||
commandlinetools:
|
||||
version: 10406996_latest
|
Loading…
Reference in New Issue
Block a user