From f26b01d8e2ebb178d5c40f856b35fe82b423ce03 Mon Sep 17 00:00:00 2001 From: jmarchel Date: Fri, 6 Oct 2023 11:58:27 +0200 Subject: [PATCH] Add roles for handling java libraries With OpenJDK and Maven. Change-Id: I156d824bab7fdfbe121f5ed4c3a2453c4d7fe848 Depends-On: https://review.opendev.org/c/nebulous/library-template/+/898805 --- playbooks/java-libraries/build.yaml | 14 +++++++++++++- playbooks/java-libraries/promote.yaml | 2 -- playbooks/java-libraries/upload.yaml | 2 -- roles/install-jdk/defaults/main.yaml | 1 + roles/install-jdk/tasks/main.yaml | 7 +++++++ roles/install-maven/defaults/main.yaml | 3 +++ roles/install-maven/tasks/main.yaml | 11 +++++++++++ zuul.d/jobs.yaml | 8 -------- zuul.d/project.yaml | 2 -- 9 files changed, 35 insertions(+), 15 deletions(-) delete mode 100644 playbooks/java-libraries/promote.yaml delete mode 100644 playbooks/java-libraries/upload.yaml create mode 100644 roles/install-jdk/defaults/main.yaml create mode 100644 roles/install-jdk/tasks/main.yaml create mode 100644 roles/install-maven/defaults/main.yaml create mode 100644 roles/install-maven/tasks/main.yaml diff --git a/playbooks/java-libraries/build.yaml b/playbooks/java-libraries/build.yaml index f679dce..dcfcb4a 100644 --- a/playbooks/java-libraries/build.yaml +++ b/playbooks/java-libraries/build.yaml @@ -1,2 +1,14 @@ - hosts: all - tasks: [] + roles: + - install_jdk + - maven + tasks: + - name: Build the project with Maven + shell: mvn clean install -DskipTests + args: + chdir: "{{ project_path }}" # Pointing to the directory with pom.xml + vars: + project_path: "{{ zuul.project.src_dir }}/{{ java_library_path }}" + environment: + MAVEN_HOME: "/opt/apache-maven-3.8.8" + PATH: "{{ ansible_env.PATH }}:/opt/apache-maven-3.8.8/bin" diff --git a/playbooks/java-libraries/promote.yaml b/playbooks/java-libraries/promote.yaml deleted file mode 100644 index f679dce..0000000 --- a/playbooks/java-libraries/promote.yaml +++ /dev/null @@ -1,2 +0,0 @@ -- hosts: all - tasks: [] diff --git a/playbooks/java-libraries/upload.yaml b/playbooks/java-libraries/upload.yaml deleted file mode 100644 index f679dce..0000000 --- a/playbooks/java-libraries/upload.yaml +++ /dev/null @@ -1,2 +0,0 @@ -- hosts: all - tasks: [] diff --git a/roles/install-jdk/defaults/main.yaml b/roles/install-jdk/defaults/main.yaml new file mode 100644 index 0000000..0885089 --- /dev/null +++ b/roles/install-jdk/defaults/main.yaml @@ -0,0 +1 @@ +jdk_version: openjdk-17-jdk diff --git a/roles/install-jdk/tasks/main.yaml b/roles/install-jdk/tasks/main.yaml new file mode 100644 index 0000000..29b2f01 --- /dev/null +++ b/roles/install-jdk/tasks/main.yaml @@ -0,0 +1,7 @@ +- name: Install OpenJDK + apt: + name: "{{ jdk_version }}" + cache_valid_time: 3600 + state: present + become: yes + when: ansible_os_family == "Debian" diff --git a/roles/install-maven/defaults/main.yaml b/roles/install-maven/defaults/main.yaml new file mode 100644 index 0000000..f9401e6 --- /dev/null +++ b/roles/install-maven/defaults/main.yaml @@ -0,0 +1,3 @@ +maven_version: "3.8.8" +maven_archive_name: "apache-maven-{{ maven_version }}-bin.tar.gz" +maven_download_url: "https://downloads.apache.org/maven/maven-3/{{ maven_version }}/binaries/{{ maven_archive_name }}" diff --git a/roles/install-maven/tasks/main.yaml b/roles/install-maven/tasks/main.yaml new file mode 100644 index 0000000..49e2e04 --- /dev/null +++ b/roles/install-maven/tasks/main.yaml @@ -0,0 +1,11 @@ +- name: Download Maven + get_url: + url: "{{ maven_download_url }}" + dest: "/tmp/{{ maven_archive_name }}" + +- name: Extract Maven Archive + unarchive: + src: "/tmp/{{ maven_archive_name }}" + dest: "/opt" + remote_src: yes + become: yes diff --git a/zuul.d/jobs.yaml b/zuul.d/jobs.yaml index 879e1e5..8a8d5b7 100644 --- a/zuul.d/jobs.yaml +++ b/zuul.d/jobs.yaml @@ -30,11 +30,3 @@ - job: name: nebulous-build-java-libraries run: playbooks/java-libraries/build.yaml - -- job: - name: nebulous-upload-java-libraries - run: playbooks/java-libraries/upload.yaml - -- job: - name: nebulous-promote-java-libraries - run: playbooks/java-libraries/promote.yaml diff --git a/zuul.d/project.yaml b/zuul.d/project.yaml index 6e4017b..18de749 100644 --- a/zuul.d/project.yaml +++ b/zuul.d/project.yaml @@ -2,7 +2,6 @@ check: jobs: - nox-linters - # cross-testing with component-template - opendev-buildset-registry - nebulous-component-template-hadolint: &cross_test_component_template @@ -15,7 +14,6 @@ gate: jobs: - nox-linters - # cross-testing with component-template - opendev-buildset-registry - nebulous-component-template-hadolint: *cross_test_component_template