---
- name: Create dir
  file: path=/opt/gradle state=directory
  sudo: yes

- name: Download
  get_url: dest="/opt/gradle" url=https://services.gradle.org/distributions/gradle-{{gradle_version}}-bin.zip
  sudo: yes

- name: Extract zip
  unarchive:
    src: "/opt/gradle/gradle-{{gradle_version}}-bin.zip"
    dest: "/opt/gradle"

- name: Add to path
  shell: ln -s /opt/gradle/gradle-{{gradle_version}}/bin/gradle /usr/local/bin/gradle creates=/usr/local/bin/gradle
  sudo: yes


- name: Delete zip
  file: path=/opt/gradle/gradle-{{gradle_version}}-bin.zip state=absent

---
- name: Create dir
  file: path=/opt/gradle state=directory
  sudo: yes

- name: Download
  get_url: dest="/opt/gradle" url=https://services.gradle.org/distributions/gradle-{{gradle_version}}-bin.zip
  sudo: yes

- name: Extract zip
  unarchive:
    src: "/opt/gradle/gradle-{{gradle_version}}-bin.zip"
    dest: "/opt/gradle"

- name: Add to path
  file: src="/opt/gradle/gradle-{{gradle_version}}/bin/gradle"
    dest=/usr/local/bin/gradle
    owner=root
    group=root
    state=link

- name: Delete zip
  file: path=/opt/gradle/gradle-{{gradle_version}}-bin.zip state=absent

Use file operation for gradle simlink
Use file operation for gradle simlink
