Allow goal override for maven-build macro 38/8438/2
authorThanh Ha <thanh.ha@linuxfoundation.org>
Fri, 19 Jan 2018 01:24:26 +0000 (20:24 -0500)
committerThanh Ha <thanh.ha@linuxfoundation.org>
Fri, 2 Feb 2018 01:00:42 +0000 (20:00 -0500)
Splits out the maven-build into a macro that can be used
to allow projects to override the default goals if they
wish to tweak them for their projects.

Change-Id: I8cabbac997d165bfe8b68d76b78cdb4bb7cc4bbc
Signed-off-by: Thanh Ha <thanh.ha@linuxfoundation.org>
docs/jjb/lf-maven-jobs.rst
jjb/lf-maven-jobs.yaml
shell/maven-build.sh

index 71b6893..939aaf8 100644 (file)
@@ -52,6 +52,16 @@ Jobs for Maven projects to generate javadoc using GitHub.
 Macros
 ======
 
+lf-maven-build
+--------------
+
+Calls the maven build script to perform a maven build.
+
+:Required parameters:
+
+    :mvn-goals: The maven goals to perform for the build.
+        (default: clean deploy)
+
 lf-maven-common
 ---------------
 
index 9f7173a..f127e91 100644 (file)
 # Macros #
 ##########
 
+- builder:
+    name: lf-maven-build
+    builders:
+      - inject:
+          properties-content: 'MAVEN_GOALS={mvn-goals}'
+      - shell: !include-raw-escape:
+          - ../shell/common-variables.sh
+          - ../shell/maven-build.sh
+
 - builder:
     name: lf-maven-deploy
     builders:
     git-url: '$GIT_URL/$PROJECT'
     java-version: openjdk8
     mvn-global-settings: global-settings
+    mvn-goals: clean deploy
     mvn-opts: ''
     mvn-params: '-Dmerge'
     mvn-version: mvn33
               NEXUS_REPO={nexus-snapshot-repo}
       - shell: !include-raw-escape:
           - ../shell/lftools-install.sh
-          - ../shell/common-variables.sh
           - ../shell/maven-fetch-metadata.sh
-          - ../shell/maven-build.sh
+      - lf-maven-build:
+          mvn-goals: '{mvn-goals}'
       - lf-maven-deploy
       - lf-provide-maven-settings-cleanup
 
     git-url: '$GIT_URL/$PROJECT'
     java-version: openjdk8
     mvn-global-settings: global-settings
+    mvn-goals: clean deploy
     mvn-opts: ''
     mvn-params: ''
     mvn-version: mvn33
           server-id: '{mvn-staging-id}'
       - shell: !include-raw-escape:
           - ../shell/lftools-install.sh
-          - ../shell/common-variables.sh
           - ../shell/maven-patch-release.sh
-          - ../shell/maven-build.sh
+      - lf-maven-build:
+          mvn-goals: '{mvn-goals}'
       - lf-maven-stage
       - lf-provide-maven-settings-cleanup
 
     git-url: '$GIT_URL/$PROJECT'
     java-version: openjdk8
     mvn-global-settings: global-settings
+    mvn-goals: clean deploy
     mvn-opts: ''
     mvn-params: '-Dstream=$STREAM'
     mvn-version: mvn33
           settings-file: '{mvn-settings}'
       - shell: !include-raw-escape:
           - ../shell/lftools-install.sh
-          - ../shell/common-variables.sh
-          - ../shell/maven-build.sh
+      - lf-maven-build:
+          mvn-goals: '{mvn-goals}'
       - lf-provide-maven-settings-cleanup
 
     publishers:
     git-url: '$GIT_URL/$PROJECT'
     java-version: openjdk8
     mvn-global-settings: global-settings
+    mvn-goals: clean deploy
     mvn-opts: ''
     mvn-params: '-Dstream=$STREAM'
     mvn-version: mvn33
       - shell: !include-raw-escape:
           - ../shell/common-variables.sh
           - ../shell/maven-build-deps.sh
-      - shell: !include-raw-escape:
-          - ../shell/common-variables.sh
-          - ../shell/maven-build.sh
+      - lf-maven-build:
+          mvn-goals: '{mvn-goals}'
       - lf-provide-maven-settings-cleanup
 
     publishers:
index a807a03..c00aa06 100644 (file)
@@ -21,7 +21,7 @@ export MAVEN_OPTS
 
 # Disable SC2086 because we want to allow word splitting for $MAVEN_* parameters.
 # shellcheck disable=SC2086
-$MVN clean deploy \
+$MVN $MAVEN_GOALS \
     -e \
     --global-settings "$GLOBAL_SETTINGS_FILE" \
     --settings "$SETTINGS_FILE" \