Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added maven-shade-plugin to build uber jar with all dependencies #11

Merged
merged 9 commits into from
Oct 19, 2022
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 31 additions & 8 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,30 @@ on:
branches: '*'

jobs:
build-shaded:
name: Build jar
runs-on: ubuntu-latest
steps:
- name: Checkout git
uses: actions/checkout@v3
- name: Build
env:
ACCESS_KEY: ${{ secrets.TEAMSCALE_ACCESS_KEY }}
run: mvn clean verify -Pfailsafe -Pshaded
- name: 'Upload Artifact'
if: ${{ always() }}
uses: actions/upload-artifact@v3
with:
name: target-jar
path: ./target
retention-days: 5

build-linux:
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:
Expand All @@ -22,15 +41,16 @@ 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
LumnitzF marked this conversation as resolved.
Show resolved Hide resolved
with:
version: latest
file: ./target/teamscale-buildbreaker
files: |
./target/teamscale-buildbreaker
- name: 'Upload Artifact'
if: ${{ always() }}
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: target-linux
path: ./target
Expand All @@ -40,7 +60,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
LumnitzF marked this conversation as resolved.
Show resolved Hide resolved
with:
Expand All @@ -55,10 +76,11 @@ jobs:
uses: crazy-max/ghaction-upx@v1
LumnitzF marked this conversation as resolved.
Show resolved Hide resolved
with:
version: latest
file: ./target/teamscale-buildbreaker.exe
files: |
./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
Expand All @@ -77,12 +99,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-jar && cp ./teamscale-buildbreaker-*-shaded.jar ../teamscale-buildbreaker.jar)
LumnitzF marked this conversation as resolved.
Show resolved Hide resolved
- 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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion build-windows.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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
./mvnw.cmd clean verify -Pfailsafe -Pnative
91 changes: 68 additions & 23 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -146,33 +146,15 @@
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.0</version>
</plugin>
</plugins>
</pluginManagement>

<plugins>
<plugin>
<groupId>org.graalvm.nativeimage</groupId>
<artifactId>native-image-maven-plugin</artifactId>
<configuration>
<imageName>${project.name}</imageName>
<mainClass>${mainClass}</mainClass>
<buildArgs>
-H:+AddAllCharsets
--no-fallback
--enable-http
--enable-https
--report-unsupported-elements-at-runtime
</buildArgs>
</configuration>
<executions>
<execution>
<goals>
<goal>native-image</goal>
</goals>
<phase>package</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
Expand Down Expand Up @@ -287,5 +269,68 @@
</plugins>
</build>
</profile>
<profile>
<id>native</id>
<build>
<plugins>
<plugin>
<groupId>org.graalvm.nativeimage</groupId>
<artifactId>native-image-maven-plugin</artifactId>
<configuration>
<imageName>${project.name}</imageName>
<mainClass>${mainClass}</mainClass>
<buildArgs>
-H:+AddAllCharsets
--no-fallback
--enable-http
--enable-https
--report-unsupported-elements-at-runtime
</buildArgs>
</configuration>
<executions>
<execution>
<goals>
<goal>native-image</goal>
</goals>
<phase>package</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>shaded</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<executions>
<execution>
<id>build-uber-jar</id>
<goals>
<goal>shade</goal>
</goals>
<phase>package</phase>
<configuration>
<shadedArtifactAttached>true</shadedArtifactAttached>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<manifestEntries>
<!-- Remove the Class-Path entry, as everything is included in the shaded jar -->
<Class-Path/>
</manifestEntries>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>

</plugins>
</build>
</profile>
</profiles>
</project>