From 7bdc6feed564a6bf912b3a749f04bf2dd0c58a04 Mon Sep 17 00:00:00 2001 From: BONNEFILLE Guilhem <guilhem.bonnefille@csgroup.eu> Date: Fri, 15 Apr 2022 16:05:49 +0000 Subject: [PATCH] feat: Add a MAVEN_PROJECT_DIR Needed to control root directory in a monorepo project. For example, project with frontend in JS and backend in Java. --- README.md | 1 + kicker.json | 6 ++++++ templates/gitlab-ci-maven.yml | 10 +++++++--- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index a9ba2f7..72128d1 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,7 @@ The Maven template uses some global configuration used throughout all jobs. | Name | description | default value | | --------------------- | -------------------------------------- | ----------------- | | `MAVEN_IMAGE` | The Docker image used to run Maven <br/>:warning: **set the version required by your project** | `maven:latest` | +| AVEN_PROJECT_DIR` | Maven projet root directory | `.` | | `MAVEN_CFG_DIR` | The Maven configuration directory | `.m2` | | `MAVEN_OPTS` | [Global Maven options](http://maven.apache.org/configure.html#maven_opts-environment-variable) | `-Dhttps.protocols=TLSv1.2 -Dmaven.repo.local=${MAVEN_CFG_DIR}/repository -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN -Dorg.slf4j.simpleLogger.showDateTime=true -Djava.awt.headless=true` | | `MAVEN_CLI_OPTS` | Additional [Maven options](https://maven.apache.org/ref/3-LATEST/maven-embedder/cli.html) used on the command line | `--batch-mode --errors --fail-at-end --show-version -DinstallAtEnd=true -DdeployAtEnd=true` | diff --git a/kicker.json b/kicker.json index 724dfba..cc9e493 100644 --- a/kicker.json +++ b/kicker.json @@ -9,6 +9,12 @@ "description": "The Docker image used to run Maven - **set the version required by your project**", "default": "maven:latest" }, + { + "name": "MAVEN_PROJECT_DIR", + "description": "Maven project root directory", + "default": ".", + "advanced": true + }, { "name": "MAVEN_CFG_DIR", "description": "The Maven configuration directory", diff --git a/templates/gitlab-ci-maven.yml b/templates/gitlab-ci-maven.yml index b299960..5af3cfa 100644 --- a/templates/gitlab-ci-maven.yml +++ b/templates/gitlab-ci-maven.yml @@ -14,6 +14,9 @@ # Floor, Boston, MA 02110-1301, USA. # ========================================================================================= variables: + # Default Maven project root directory + MAVEN_PROJECT_DIR: . + # Maven image (can be overridden) MAVEN_IMAGE: "maven:latest" @@ -450,6 +453,7 @@ stages: - install_ca_certs "${CUSTOM_CA_CERTS:-$DEFAULT_CA_CERTS}" - eval_java_proxy_args - eval_mvn_settings_opt + - cd ${MAVEN_PROJECT_DIR} # Cache downloaded dependencies and plugins between builds. # To keep cache across branches add 'key: "$CI_JOB_NAME"' cache: @@ -472,9 +476,9 @@ mvn-build: when: always reports: junit: - - "**/target/*-reports/TEST-*.xml" + - "${MAVEN_PROJECT_DIR}/**/target/*-reports/TEST-*.xml" paths: - - "**/target" + - "${MAVEN_PROJECT_DIR}/**/target" rules: # exclude merge requests - if: '$CI_MERGE_REQUEST_ID == null' @@ -533,7 +537,7 @@ mvn-dependency-check: expire_in: 1 day when: always paths: - - "**/target/dependency-check-report.*" + - "${MAVEN_PROJECT_DIR}/**/target/dependency-check-report.*" mvn-forbid-snapshot-dependencies: extends: .mvn-base -- GitLab