From c57f7ccc7366d215ae48d8a6cdcb78b14e93d5ba Mon Sep 17 00:00:00 2001 From: Fritz Lumnitz Date: Tue, 18 Oct 2022 17:29:29 +0200 Subject: [PATCH 1/9] Added maven-shade-plugin to build uber jar with all dependencies --- pom.xml | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/pom.xml b/pom.xml index 5472332..51c9b99 100644 --- a/pom.xml +++ b/pom.xml @@ -146,10 +146,40 @@ + + org.apache.maven.plugins + maven-shade-plugin + 3.2.0 + + + org.apache.maven.plugins + maven-shade-plugin + + + build-uber-jar + + shade + + package + + true + + + + + + + + + + + + org.graalvm.nativeimage native-image-maven-plugin From dbb8e82b187cb9d9836c8cc4ab80406a2ff262d5 Mon Sep 17 00:00:00 2001 From: Fritz Lumnitz Date: Tue, 18 Oct 2022 17:52:11 +0200 Subject: [PATCH 2/9] Move native/shaded build into own profiles, and execute respective build actions --- .github/workflows/actions.yml | 22 ++++++- build-windows.bat | 2 +- pom.xml | 111 +++++++++++++++++++--------------- 3 files changed, 84 insertions(+), 51 deletions(-) diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index 0402500..b24b598 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -8,6 +8,23 @@ on: branches: '*' jobs: + build-shaded: + name: Build shaded jar + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Build + env: + ACCESS_KEY: ${{ secrets.TEAMSCALE_ACCESS_KEY }} + run: mvn clean verify -Pfailsafe -Pshaded + - name: 'Upload Artifact' + if: ${{ always() }} + uses: actions/upload-artifact@v2 + with: + name: target-shaded + path: ./target + retention-days: 5 + build-linux: name: Linux Build runs-on: ubuntu-latest @@ -22,7 +39,7 @@ jobs: - name: Build env: ACCESS_KEY: ${{ secrets.TEAMSCALE_ACCESS_KEY }} - run: mvn clean verify -Pfailsafe + run: mvn clean verify -Pfailsafe -Pnative - name: Reduce Image Size uses: crazy-max/ghaction-upx@v1 with: @@ -77,12 +94,13 @@ jobs: run: | (cd ./target-linux && zip ../teamscale-buildbreaker-linux.zip ./teamscale-buildbreaker) (cd ./target-windows && zip ../teamscale-buildbreaker-windows.zip ./teamscale-buildbreaker.exe) + (cd ./target-shaded && cp ./teamscale-buildbreaker-*-shaded.jar ./teamscale-buildbreaker-shaded.jar) - name: Upload Release Assets id: create_release uses: svenstaro/upload-release-action@v2 with: repo_token: ${{ secrets.GITHUB_TOKEN }} tag: ${{ github.ref }} - file: teamscale-buildbreaker-*.zip + file: teamscale-buildbreaker-*.{zip,jar} file_glob: true overwrite: true diff --git a/build-windows.bat b/build-windows.bat index 665f973..54a57b3 100644 --- a/build-windows.bat +++ b/build-windows.bat @@ -2,4 +2,4 @@ rem calling this is required so cl.exe is on the path when native-image tries to rem we can't do this from the travis bash script as the env variables set by this bat file are not rem propagated to the shell environment call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x86_amd64 -./mvnw.cmd clean verify -Pfailsafe \ No newline at end of file +./mvnw.cmd clean verify -Pfailsafe -Pnative \ No newline at end of file diff --git a/pom.xml b/pom.xml index 51c9b99..7c4ad23 100644 --- a/pom.xml +++ b/pom.xml @@ -155,54 +155,6 @@ - - org.apache.maven.plugins - maven-shade-plugin - - - build-uber-jar - - shade - - package - - true - - - - - - - - - - - - - - org.graalvm.nativeimage - native-image-maven-plugin - - ${project.name} - ${mainClass} - - -H:+AddAllCharsets - --no-fallback - --enable-http - --enable-https - --report-unsupported-elements-at-runtime - - - - - - native-image - - package - - - org.codehaus.mojo exec-maven-plugin @@ -317,5 +269,68 @@ + + native + + + + org.graalvm.nativeimage + native-image-maven-plugin + + ${project.name} + ${mainClass} + + -H:+AddAllCharsets + --no-fallback + --enable-http + --enable-https + --report-unsupported-elements-at-runtime + + + + + + native-image + + package + + + + + + + + shaded + + + + org.apache.maven.plugins + maven-shade-plugin + + + build-uber-jar + + shade + + package + + true + + + + + + + + + + + + + + + + From d12e011731cea97fa3ce6c1b9b80e95ff259d7cc Mon Sep 17 00:00:00 2001 From: Fritz Lumnitz Date: Wed, 19 Oct 2022 09:52:51 +0200 Subject: [PATCH 3/9] Renamed "shaded" to "jar" --- .github/workflows/actions.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index b24b598..d82f27b 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -9,7 +9,7 @@ on: jobs: build-shaded: - name: Build shaded jar + name: Build jar runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 @@ -21,7 +21,7 @@ jobs: if: ${{ always() }} uses: actions/upload-artifact@v2 with: - name: target-shaded + name: target-jar path: ./target retention-days: 5 @@ -94,13 +94,13 @@ jobs: run: | (cd ./target-linux && zip ../teamscale-buildbreaker-linux.zip ./teamscale-buildbreaker) (cd ./target-windows && zip ../teamscale-buildbreaker-windows.zip ./teamscale-buildbreaker.exe) - (cd ./target-shaded && cp ./teamscale-buildbreaker-*-shaded.jar ./teamscale-buildbreaker-shaded.jar) + (cd ./target-jar && cp ./teamscale-buildbreaker-*-shaded.jar ../teamscale-buildbreaker.jar) - name: Upload Release Assets id: create_release uses: svenstaro/upload-release-action@v2 with: repo_token: ${{ secrets.GITHUB_TOKEN }} tag: ${{ github.ref }} - file: teamscale-buildbreaker-*.{zip,jar} + file: teamscale-buildbreaker*.{zip,jar} file_glob: true overwrite: true From 2654f55262ad4f4fac4f5804547d3428a5baeb20 Mon Sep 17 00:00:00 2001 From: Fritz Lumnitz Date: Wed, 19 Oct 2022 09:55:11 +0200 Subject: [PATCH 4/9] Update actions/upload-artifact --- .github/workflows/actions.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index d82f27b..b86f0f2 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -19,7 +19,7 @@ jobs: run: mvn clean verify -Pfailsafe -Pshaded - name: 'Upload Artifact' if: ${{ always() }} - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: target-jar path: ./target @@ -47,7 +47,7 @@ jobs: file: ./target/teamscale-buildbreaker - name: 'Upload Artifact' if: ${{ always() }} - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: target-linux path: ./target @@ -75,7 +75,7 @@ jobs: file: ./target/teamscale-buildbreaker.exe - name: 'Upload Artifact' if: ${{ always() }} - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: target-windows path: ./target From 1f1ff2f63c01a137f2347a80014fef06460862dd Mon Sep 17 00:00:00 2001 From: Fritz Lumnitz Date: Wed, 19 Oct 2022 09:58:28 +0200 Subject: [PATCH 5/9] Update actions/checkout --- .github/workflows/actions.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index b86f0f2..e9fbc58 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -12,7 +12,8 @@ jobs: name: Build jar runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - name: Checkout git + uses: actions/checkout@v3 - name: Build env: ACCESS_KEY: ${{ secrets.TEAMSCALE_ACCESS_KEY }} @@ -29,7 +30,8 @@ jobs: name: Linux Build runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - name: Checkout git + uses: actions/checkout@v3 - name: Set up GraalVM uses: ayltai/setup-graalvm@v1 with: @@ -57,7 +59,8 @@ jobs: name: Windows Build runs-on: windows-2019 steps: - - uses: actions/checkout@v2 + - name: Checkout git + uses: actions/checkout@v3 - name: Set up GraalVM uses: ayltai/setup-graalvm@v1 with: From 9bcf9e001ed48cdef9cb5f50b9c81c4989357673 Mon Sep 17 00:00:00 2001 From: Fritz Lumnitz Date: Wed, 19 Oct 2022 10:00:17 +0200 Subject: [PATCH 6/9] Use "files" instead of deprecated "file" --- .github/workflows/actions.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index e9fbc58..b7ca64b 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -46,7 +46,8 @@ jobs: uses: crazy-max/ghaction-upx@v1 with: version: latest - file: ./target/teamscale-buildbreaker + files: | + ./target/teamscale-buildbreaker - name: 'Upload Artifact' if: ${{ always() }} uses: actions/upload-artifact@v3 @@ -75,7 +76,8 @@ jobs: uses: crazy-max/ghaction-upx@v1 with: version: latest - file: ./target/teamscale-buildbreaker.exe + files: | + ./target/teamscale-buildbreaker.exe - name: 'Upload Artifact' if: ${{ always() }} uses: actions/upload-artifact@v3 From a1270f7965097209b29f18114add3a82174cf428 Mon Sep 17 00:00:00 2001 From: Fritz Lumnitz Date: Wed, 19 Oct 2022 10:04:15 +0200 Subject: [PATCH 7/9] Update README to include profile for native image --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c9ce83f..d05cfad 100644 --- a/README.md +++ b/README.md @@ -170,5 +170,5 @@ necessary. - Make sure that maven is executed with the graalvm JDK - In the command line, navigate to the root directory of the project -- Run ```mvn package``` +- Run ```mvn package -Pnative``` - if build was successful, the new native image is located in the ```target``` subfolder of the project From fcc95b2c4077ffbf370bc2be364da256721cd879 Mon Sep 17 00:00:00 2001 From: Fritz Lumnitz Date: Wed, 19 Oct 2022 17:27:18 +0200 Subject: [PATCH 8/9] Add missing link to build-jar --- .github/workflows/actions.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index b7ca64b..81f731e 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -8,7 +8,7 @@ on: branches: '*' jobs: - build-shaded: + build-jar: name: Build jar runs-on: ubuntu-latest steps: @@ -91,6 +91,7 @@ jobs: needs: - build-windows - build-linux + - build-jar name: Create Release runs-on: ubuntu-latest steps: From d8003d610ddbb0eb4af7d2d022f0fb94884ce673 Mon Sep 17 00:00:00 2001 From: Fritz Lumnitz Date: Wed, 19 Oct 2022 17:28:45 +0200 Subject: [PATCH 9/9] Update crazy-max/ghaction-upx action to v2 --- .github/workflows/actions.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index 81f731e..a90a966 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -43,7 +43,7 @@ jobs: ACCESS_KEY: ${{ secrets.TEAMSCALE_ACCESS_KEY }} run: mvn clean verify -Pfailsafe -Pnative - name: Reduce Image Size - uses: crazy-max/ghaction-upx@v1 + uses: crazy-max/ghaction-upx@v2 with: version: latest files: | @@ -73,7 +73,7 @@ jobs: ACCESS_KEY: ${{ secrets.TEAMSCALE_ACCESS_KEY }} run: ./build-windows.bat - name: Reduce Image Size - uses: crazy-max/ghaction-upx@v1 + uses: crazy-max/ghaction-upx@v2 with: version: latest files: |