Skip to content

Commit fdae576

Browse files
committed
Fix broken native build caused by Cloud SQL socket factory
As per Mandrel 23.1, the native image build fails when modules depend on `com.google.cloud.sql:postgres-socket-factory`: https://github.com/DependencyTrack/hyades/actions/runs/7686438316/job/20945288653. Apparently it uses a special way to call native libraries, which is not supported. This change only includes the dependency when explicitly *not* building in native mode. Also added an IntelliJ run profile to build native executables using containers, removing the requirement of having Graal / Mandrel installed. Signed-off-by: nscuro <[email protected]>
1 parent 3170d4f commit fdae576

File tree

10 files changed

+127
-37
lines changed

10 files changed

+127
-37
lines changed

.github/workflows/_build-native-meta.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ jobs:
5858
fi
5959
echo "Including resources: ${RESOURCES_INCLUDES:-None}"
6060
echo "Excluding resources: ${RESOURCES_EXCLUDES:-None}"
61-
mvn clean package -Pnative -pl commons,commons-kstreams,commons-persistence,proto,${{ inputs.module }} -DskipTests \
61+
mvn clean package -Dnative -pl commons,commons-kstreams,commons-persistence,proto,${{ inputs.module }} -DskipTests \
6262
-Dquarkus.native.builder-image=quay.io/quarkus/ubi-quarkus-mandrel-builder-image:23.1-java21 \
6363
-Dquarkus.native.container-build=true \
6464
-Dquarkus.native.container-runtime-options='--platform=linux/${{ matrix.arch.name }}' \
@@ -67,7 +67,7 @@ jobs:
6767
- name: Test Native Image
6868
if: ${{ matrix.arch.name == 'amd64' }}
6969
run: |-
70-
mvn -pl commons,commons-kstreams,commons-persistence,proto,${{ inputs.module }} test-compile failsafe:integration-test -Pnative
70+
mvn -pl commons,commons-kstreams,commons-persistence,proto,${{ inputs.module }} test-compile failsafe:integration-test -Dnative
7171
- name: Upload Build Artifact
7272
uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 # tag=v4.3.0
7373
with:

.github/workflows/ci.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ jobs:
7171
github-token: ${{ secrets.GITHUB_TOKEN }}
7272
- name: Build Native Image
7373
run: |-
74-
mvn -pl commons,commons-kstreams,commons-persistence,proto,${{ matrix.module }} clean install -Pnative -DskipTests
74+
mvn -pl commons,commons-kstreams,commons-persistence,proto,${{ matrix.module }} clean install -Dnative -DskipTests
7575
- name: Test Native Image
7676
run: |-
7777
mvn -pl commons,commons-kstreams,commons-persistence,proto,${{ matrix.module }} \
78-
test-compile failsafe:integration-test failsafe:verify -Pnative
78+
test-compile failsafe:integration-test failsafe:verify -Dnative

.idea/runConfigurations/Build_Native.xml

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/runConfigurations/Run_Native_Integration_Tests.xml

+20-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

commons-persistence/pom.xml

-5
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,6 @@
4242
<artifactId>packageurl-java</artifactId>
4343
</dependency>
4444

45-
<dependency>
46-
<groupId>com.google.cloud.sql</groupId>
47-
<artifactId>postgres-socket-factory</artifactId>
48-
</dependency>
49-
5045
<dependency>
5146
<groupId>org.apache.commons</groupId>
5247
<artifactId>commons-lang3</artifactId>

mirror-service/pom.xml

+9
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,11 @@
136136
<profiles>
137137
<profile>
138138
<id>native</id>
139+
<activation>
140+
<property>
141+
<name>native</name>
142+
</property>
143+
</activation>
139144
<dependencies>
140145
<!--
141146
Required for Apache httpclient5.
@@ -151,6 +156,10 @@
151156
<version>${lib.conscrypt.version}</version>
152157
</dependency>
153158
</dependencies>
159+
<properties>
160+
<skipITs>false</skipITs>
161+
<quarkus.package.type>native</quarkus.package.type>
162+
</properties>
154163
</profile>
155164
</profiles>
156165

notification-publisher/pom.xml

+30
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,36 @@
9999
</dependency>
100100
</dependencies>
101101

102+
<profiles>
103+
<profile>
104+
<id>native</id>
105+
<activation>
106+
<property>
107+
<name>native</name>
108+
</property>
109+
</activation>
110+
<properties>
111+
<skipITs>false</skipITs>
112+
<quarkus.package.type>native</quarkus.package.type>
113+
</properties>
114+
</profile>
115+
116+
<profile>
117+
<id>non-native</id>
118+
<activation>
119+
<property>
120+
<name>!native</name>
121+
</property>
122+
</activation>
123+
<dependencies>
124+
<dependency>
125+
<groupId>com.google.cloud.sql</groupId>
126+
<artifactId>postgres-socket-factory</artifactId>
127+
</dependency>
128+
</dependencies>
129+
</profile>
130+
</profiles>
131+
102132
<build>
103133
<plugins>
104134
<plugin>

pom.xml

-13
Original file line numberDiff line numberDiff line change
@@ -488,19 +488,6 @@
488488
</build>
489489

490490
<profiles>
491-
<profile>
492-
<id>native</id>
493-
<activation>
494-
<property>
495-
<name>native</name>
496-
</property>
497-
</activation>
498-
<properties>
499-
<skipITs>false</skipITs>
500-
<quarkus.package.type>native</quarkus.package.type>
501-
</properties>
502-
</profile>
503-
504491
<profile>
505492
<!--
506493
When running in GitHub Actions, the SCM connection must be via HTTPS

repository-meta-analyzer/pom.xml

+30
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,36 @@
130130
</dependency>
131131
</dependencies>
132132

133+
<profiles>
134+
<profile>
135+
<id>native</id>
136+
<activation>
137+
<property>
138+
<name>native</name>
139+
</property>
140+
</activation>
141+
<properties>
142+
<skipITs>false</skipITs>
143+
<quarkus.package.type>native</quarkus.package.type>
144+
</properties>
145+
</profile>
146+
147+
<profile>
148+
<id>non-native</id>
149+
<activation>
150+
<property>
151+
<name>!native</name>
152+
</property>
153+
</activation>
154+
<dependencies>
155+
<dependency>
156+
<groupId>com.google.cloud.sql</groupId>
157+
<artifactId>postgres-socket-factory</artifactId>
158+
</dependency>
159+
</dependencies>
160+
</profile>
161+
</profiles>
162+
133163
<build>
134164
<plugins>
135165
<plugin>

vulnerability-analyzer/pom.xml

+31-8
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,37 @@
119119
<scope>test</scope>
120120
</dependency>
121121
</dependencies>
122+
123+
<profiles>
124+
<profile>
125+
<id>native</id>
126+
<activation>
127+
<property>
128+
<name>native</name>
129+
</property>
130+
</activation>
131+
<properties>
132+
<skipITs>false</skipITs>
133+
<quarkus.package.type>native</quarkus.package.type>
134+
</properties>
135+
</profile>
136+
137+
<profile>
138+
<id>non-native</id>
139+
<activation>
140+
<property>
141+
<name>!native</name>
142+
</property>
143+
</activation>
144+
<dependencies>
145+
<dependency>
146+
<groupId>com.google.cloud.sql</groupId>
147+
<artifactId>postgres-socket-factory</artifactId>
148+
</dependency>
149+
</dependencies>
150+
</profile>
151+
</profiles>
152+
122153
<build>
123154
<plugins>
124155
<plugin>
@@ -131,12 +162,4 @@
131162
</plugin>
132163
</plugins>
133164
</build>
134-
<profiles>
135-
<profile>
136-
<id>native</id>
137-
<properties>
138-
<quarkus.package.type>native</quarkus.package.type>
139-
</properties>
140-
</profile>
141-
</profiles>
142165
</project>

0 commit comments

Comments
 (0)