Skip to content

Commit e56e000

Browse files
committed
Make JAR, not WAR!
Switches from an executable WAR distribution to normal JAR one. Instead of shading dependencies, ships them as separate JARs in a lib directory. This is a better fit for container because it allows for more effective layer caching. The build is faster because the expensive WAR overlays are no longer required. The development setup also becomes less involved, as it removes the need to go through the Jetty Maven plugin. Signed-off-by: nscuro <nscuro@protonmail.com>
1 parent a1b14b2 commit e56e000

22 files changed

Lines changed: 403 additions & 984 deletions

File tree

.github/workflows/_meta-build.yaml

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,20 @@ jobs:
6464
6565
- name: Build with Maven
6666
run: |-
67-
mvn -B -Pquick -Dservices.bom.merge.skip=false package
67+
mvn -B -Pquick,dist -Dservices.bom.merge.skip=false package
6868
69-
- name: Upload Artifacts
69+
- name: Upload Distribution Archive
7070
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # tag=v6.0.0
7171
with:
72-
name: assembled-wars
72+
name: assembled-dist
73+
path: |-
74+
apiserver/target/dependency-track-apiserver-dist.tar.gz
75+
76+
- name: Upload BOM
77+
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # tag=v6.0.0
78+
with:
79+
name: bom
7380
path: |-
74-
apiserver/target/*.jar
7581
apiserver/target/bom.json
7682
7783
- name: Upload OpenAPI Spec
@@ -95,9 +101,12 @@ jobs:
95101
- name: Download Artifacts
96102
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # tag=v7.0.0
97103
with:
98-
name: assembled-wars
104+
name: assembled-dist
99105
path: apiserver/target
100106

107+
- name: Extract Distribution Archive
108+
run: tar xzf apiserver/target/dependency-track-apiserver-dist.tar.gz -C apiserver/target
109+
101110
- name: Set up QEMU
102111
uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # tag=v3.7.0
103112

.github/workflows/ci-publish.yaml

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,21 +71,30 @@ jobs:
7171
- name: Checkout Repository
7272
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # tag=v6.0.2
7373

74-
- name: Download Artifacts
74+
- name: Download Distribution Archive
7575
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # tag=v7.0.0
7676
with:
77-
name: assembled-wars
77+
name: assembled-dist
7878
path: target
7979

80-
- name: Create Checksums and SBOM
80+
- name: Download BOM
81+
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # tag=v7.0.0
82+
with:
83+
name: bom
84+
path: target
85+
86+
- name: Create Checksums
8187
run: |-
8288
pushd target
8389
echo "# SHA1" >> checksums.txt
84-
sha1sum dependency-track-apiserver.jar >> checksums.txt
90+
sha1sum dependency-track-apiserver-dist.tar.gz >> checksums.txt
91+
sha1sum bom.json >> checksums.txt
8592
echo "# SHA256" >> checksums.txt
86-
sha256sum dependency-track-apiserver.jar >> checksums.txt
93+
sha256sum dependency-track-apiserver-dist.tar.gz >> checksums.txt
94+
sha256sum bom.json >> checksums.txt
8795
echo "# SHA512" >> checksums.txt
88-
sha512sum dependency-track-apiserver.jar >> checksums.txt
96+
sha512sum dependency-track-apiserver-dist.tar.gz >> checksums.txt
97+
sha512sum bom.json >> checksums.txt
8998
popd
9099
91100
- name: Update Release
@@ -94,6 +103,6 @@ jobs:
94103
run: |-
95104
gh release upload ${{ needs.read-version.outputs.version }} \
96105
--clobber \
97-
target/dependency-track-apiserver.jar \
98-
target/checksums.txt \
99-
target/bom.json
106+
target/dependency-track-apiserver-dist.tar.gz \
107+
target/bom.json \
108+
target/checksums.txt

.idea/runConfigurations/Jetty.xml

Lines changed: 0 additions & 56 deletions
This file was deleted.

.mvn/maven-build-cache-config.xml

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,6 @@
2222
<configuration>
2323
<enabled>true</enabled>
2424
<hashAlgorithm>XX</hashAlgorithm>
25-
<attachedOutputs>
26-
<dirNames>
27-
<!-- Required by Jetty plugin. -->
28-
<dirName>classes</dirName>
29-
</dirNames>
30-
</attachedOutputs>
3125
</configuration>
3226
<input>
3327
<global>
@@ -40,13 +34,9 @@
4034
<executionControl>
4135
<runAlways>
4236
<executions>
43-
<execution artifactId="maven-antrun-plugin">
37+
<execution artifactId="maven-dependency-plugin">
4438
<execIds>
45-
<!--
46-
The build cache only restores the API server WAR file,
47-
but the JAR file is required for container image builds.
48-
-->
49-
<execId>rename-war-file</execId>
39+
<execId>copy-dependencies</execId>
5040
</execIds>
5141
</execution>
5242
</executions>
@@ -59,4 +49,4 @@
5949
</goalsLists>
6050
</runAlways>
6151
</executionControl>
62-
</cache>
52+
</cache>

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ build:
3535
$(MVND) $(MVN_FLAGS) -q -Pquick package
3636
.PHONY: build
3737

38+
build-dist:
39+
$(MVND) $(MVN_FLAGS) -q -Pdist,quick package
40+
.PHONY: build-dist
41+
3842
build-image: build
3943
docker build \
4044
-t ghcr.io/dependencytrack/hyades-apiserver:local \

alpine/alpine-executable-war/pom.xml

Lines changed: 0 additions & 123 deletions
This file was deleted.

0 commit comments

Comments
 (0)