mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-06 10:40:32 -07:00
Add android sdk module (#9236) * adds simple implementation of adding and removing android sdk packages * adds package update * adds simple installed packages parsing * moves parsing logic to a separate class * adds absent state for sdkmanager packages and setup for tests * adds output for installing and removing packages * removes version from Package object since it is not possible to specify version for a package while using sdkmanager * adds 'latest' state * adds tests * fixes crash when sdkmanager is invoked from python with LC_ALL=C * fixes latest state * adds sdk_root parameter * adds channel parameter * simplifies regexps, removes unused named groups * minor refactoring of sdkmanager parsing * adds java dependency variable for different distributions * adds RETURN documentation * adds check for nonexisting package * adds check for non-accepted licenses * removes excessive methods from sdkmanager * removes unused 'update' module parameter, packages may be updated using 'latest' state * minor refactoring * adds EXAMPLES doc section * adds DOCUMENTATION section and license headers * fixes formatting issues * removes diff_params * adds maintainer * fixes sanity check issues in sdkmanager * adds java dependency for macos and moves some tests to a separate FreeBSD configuration * fixes dependencies setup for OSX * fixes dependencies setup for OSX (2) * fixes dependencies setup for OSX (3) * Apply minor suggestions from code review Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com> * applies code review suggestions * changes force_lang from C.UTF-8 to auto in sdkmanager (as per discussion https://github.com/ansible-collections/community.general/pull/9236#discussion_r1881114326) * Revert "changes force_lang from C.UTF-8 to auto in sdkmanager (as per discussion https://github.com/ansible-collections/community.general/pull/9236#discussion_r1881114326)" This reverts commit619f28dd58
. * fixes some more comments from review * minor sanity issue fix * uses the 'changed' test instead of checking the 'changed' attribute * adds 'accept_licenses' parameter. Installation is now performed independently for each package specified. * removes "Accept licenses" task from examples * fixes docs sanity issues * applies minor suggestions from code review * fixes regexps. The previous version didn't match versions like "32.1.0 rc1". Also, this allows to simplify the parsing logic as there is no need to skip table headers anymore. * renamed sdkmanager.py to android_sdkmanager.py * applies minor suggestions from code review Co-authored-by: Felix Fontein <felix@fontein.de> * updates BOTMETA * reordered BOTMETA --------- Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com> Co-authored-by: Felix Fontein <felix@fontein.de> (cherry picked from commit2b2872f0ef
) Co-authored-by: Stanislav Shamilov <shamilovstas@protonmail.com>
86 lines
2.6 KiB
YAML
86 lines
2.6 KiB
YAML
---
|
|
####################################################################
|
|
# WARNING: These are designed specifically for Ansible tests #
|
|
# and should not be used as examples of how to write Ansible roles #
|
|
####################################################################
|
|
|
|
# Copyright (c) Ansible Project
|
|
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
- name: Include OS-specific variables
|
|
include_vars: '{{ ansible_os_family }}.yml'
|
|
|
|
- name: Install dependencies
|
|
become: true
|
|
package:
|
|
name:
|
|
- "{{ openjdk_pkg }}"
|
|
- unzip
|
|
state: present
|
|
when: ansible_os_family != 'Darwin'
|
|
|
|
- name: Install dependencies (OSX)
|
|
block:
|
|
- name: Find brew binary
|
|
command: which brew
|
|
register: brew_which
|
|
- name: Get owner of brew binary
|
|
stat:
|
|
path: "{{ brew_which.stdout }}"
|
|
register: brew_stat
|
|
- name: "Install package"
|
|
homebrew:
|
|
name:
|
|
- "{{ openjdk_pkg }}"
|
|
- unzip
|
|
state: present
|
|
update_homebrew: false
|
|
become: true
|
|
become_user: "{{ brew_stat.stat.pw_name }}"
|
|
environment:
|
|
HOMEBREW_NO_AUTO_UPDATE: "True"
|
|
- name: Symlink java
|
|
become: true
|
|
file:
|
|
src: "/usr/local/opt/openjdk@17/libexec/openjdk.jdk"
|
|
dest: "/Library/Java/JavaVirtualMachines/openjdk-17.jdk"
|
|
state: link
|
|
when:
|
|
- ansible_os_family == 'Darwin'
|
|
|
|
- name: Create Android SDK directory
|
|
file:
|
|
path: "{{ android_sdk_location }}"
|
|
state: directory
|
|
|
|
- name: Check that sdkmanager is installed
|
|
stat:
|
|
path: "{{ android_sdk_location }}/cmdline-tools/latest/bin/sdkmanager"
|
|
register: sdkmanager_installed
|
|
|
|
- name: Install Android command line tools
|
|
when: not sdkmanager_installed.stat.exists
|
|
block:
|
|
- name: Create Android SDK dir structure
|
|
file:
|
|
path: "{{ item.path }}"
|
|
state: "{{ item.state }}"
|
|
with_items:
|
|
- { path: "{{ android_cmdline_temp_dir }}", state: "directory" }
|
|
- { path: "{{ android_sdk_location }}/cmdline-tools/latest", state: "directory" }
|
|
|
|
- name: Download Android command line tools
|
|
unarchive:
|
|
src: "{{ commandline_tools_link }}"
|
|
dest: "{{ android_cmdline_temp_dir }}"
|
|
remote_src: yes
|
|
creates: "{{ android_cmdline_temp_dir }}/cmdline-tools"
|
|
when: not sdkmanager_installed.stat.exists
|
|
|
|
|
|
- name: Fix directory structure
|
|
copy:
|
|
src: "{{ android_cmdline_temp_dir }}/cmdline-tools/"
|
|
dest: "{{ android_sdk_location }}/cmdline-tools/latest"
|
|
remote_src: yes
|