diff --git a/playbooks/java-libraries/build.yaml b/playbooks/java-libraries/build.yaml index 279b32d..e7e1bad 100644 --- a/playbooks/java-libraries/build.yaml +++ b/playbooks/java-libraries/build.yaml @@ -2,13 +2,8 @@ roles: - install-jdk - install-maven - tasks: - - name: Build the project with Maven - shell: mvn clean install - args: - chdir: "{{ library_path }}" # Pointing to the directory with pom.xml + - role: maven vars: - library_path: "{{ zuul.project.src_dir }}/{{ java_libraries[0].context }}" - environment: - MAVEN_HOME: "/opt/apache-maven-3.8.8" - PATH: "{{ ansible_env.PATH }}:/opt/apache-maven-3.8.8/bin" + # TODO: support more + maven_pom_dir: "{{ java_libraries[0].context }}" + maven_phases: ["install"] diff --git a/roles/maven/defaults/main.yml b/roles/maven/defaults/main.yml new file mode 100644 index 0000000..9ae6652 --- /dev/null +++ b/roles/maven/defaults/main.yml @@ -0,0 +1,5 @@ +zuul_work_dir: "{{ zuul.project.src_dir }}" + +maven_version: "3.8.8" +maven_phases: [] +maven_pom_dir: "" diff --git a/roles/maven/tasks/main.yml b/roles/maven/tasks/main.yml new file mode 100644 index 0000000..b17d15b --- /dev/null +++ b/roles/maven/tasks/main.yml @@ -0,0 +1,9 @@ +- name: Run Maven + command: + argv: "{{ ['mvn'] + maven_phases }}" + chdir: "{{ zuul_work_dir }}/{{ maven_pom_dir }}" + vars: + maven_home: "/opt/apache-maven-{{ maven_version }}" + environment: + MAVEN_HOME: "{{ maven_home }}" + PATH: "{{ maven_home }}/bin:{{ ansible_env.PATH }}" diff --git a/zuul.d/project.yaml b/zuul.d/project.yaml index d576e80..3997aca 100644 --- a/zuul.d/project.yaml +++ b/zuul.d/project.yaml @@ -34,5 +34,16 @@ - opendev-buildset-registry: files: *nebulous-component-template-apply-helm-charts-files + # cross-testing with library-template + - nebulous-library-template-build-java-libraries: + vars: + zuul_work_dir: src/opendev.org/nebulous/library-template + required-projects: + - nebulous/library-template + files: + - ^playbooks/java-libraries/ + - ^roles/install-jdk/ + - ^roles/install-maven/ + gate: jobs: *check-jobs