Skip to content

Commit

Permalink
Fix broken native build caused by Cloud SQL socket factory
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
nscuro committed Jan 28, 2024
1 parent 3170d4f commit fdae576
Show file tree
Hide file tree
Showing 10 changed files with 127 additions and 37 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/_build-native-meta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
fi
echo "Including resources: ${RESOURCES_INCLUDES:-None}"
echo "Excluding resources: ${RESOURCES_EXCLUDES:-None}"
mvn clean package -Pnative -pl commons,commons-kstreams,commons-persistence,proto,${{ inputs.module }} -DskipTests \
mvn clean package -Dnative -pl commons,commons-kstreams,commons-persistence,proto,${{ inputs.module }} -DskipTests \
-Dquarkus.native.builder-image=quay.io/quarkus/ubi-quarkus-mandrel-builder-image:23.1-java21 \
-Dquarkus.native.container-build=true \
-Dquarkus.native.container-runtime-options='--platform=linux/${{ matrix.arch.name }}' \
Expand All @@ -67,7 +67,7 @@ jobs:
- name: Test Native Image
if: ${{ matrix.arch.name == 'amd64' }}
run: |-
mvn -pl commons,commons-kstreams,commons-persistence,proto,${{ inputs.module }} test-compile failsafe:integration-test -Pnative
mvn -pl commons,commons-kstreams,commons-persistence,proto,${{ inputs.module }} test-compile failsafe:integration-test -Dnative
- name: Upload Build Artifact
uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 # tag=v4.3.0
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ jobs:
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Build Native Image
run: |-
mvn -pl commons,commons-kstreams,commons-persistence,proto,${{ matrix.module }} clean install -Pnative -DskipTests
mvn -pl commons,commons-kstreams,commons-persistence,proto,${{ matrix.module }} clean install -Dnative -DskipTests
- name: Test Native Image
run: |-
mvn -pl commons,commons-kstreams,commons-persistence,proto,${{ matrix.module }} \
test-compile failsafe:integration-test failsafe:verify -Pnative
test-compile failsafe:integration-test failsafe:verify -Dnative
6 changes: 3 additions & 3 deletions .idea/runConfigurations/Build_Native.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 20 additions & 4 deletions .idea/runConfigurations/Run_Native_Integration_Tests.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions commons-persistence/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@
<artifactId>packageurl-java</artifactId>
</dependency>

<dependency>
<groupId>com.google.cloud.sql</groupId>
<artifactId>postgres-socket-factory</artifactId>
</dependency>

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
Expand Down
9 changes: 9 additions & 0 deletions mirror-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,11 @@
<profiles>
<profile>
<id>native</id>
<activation>
<property>
<name>native</name>
</property>
</activation>
<dependencies>
<!--
Required for Apache httpclient5.
Expand All @@ -151,6 +156,10 @@
<version>${lib.conscrypt.version}</version>
</dependency>
</dependencies>
<properties>
<skipITs>false</skipITs>
<quarkus.package.type>native</quarkus.package.type>
</properties>
</profile>
</profiles>

Expand Down
30 changes: 30 additions & 0 deletions notification-publisher/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,36 @@
</dependency>
</dependencies>

<profiles>
<profile>
<id>native</id>
<activation>
<property>
<name>native</name>
</property>
</activation>
<properties>
<skipITs>false</skipITs>
<quarkus.package.type>native</quarkus.package.type>
</properties>
</profile>

<profile>
<id>non-native</id>
<activation>
<property>
<name>!native</name>
</property>
</activation>
<dependencies>
<dependency>
<groupId>com.google.cloud.sql</groupId>
<artifactId>postgres-socket-factory</artifactId>
</dependency>
</dependencies>
</profile>
</profiles>

<build>
<plugins>
<plugin>
Expand Down
13 changes: 0 additions & 13 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -488,19 +488,6 @@
</build>

<profiles>
<profile>
<id>native</id>
<activation>
<property>
<name>native</name>
</property>
</activation>
<properties>
<skipITs>false</skipITs>
<quarkus.package.type>native</quarkus.package.type>
</properties>
</profile>

<profile>
<!--
When running in GitHub Actions, the SCM connection must be via HTTPS
Expand Down
30 changes: 30 additions & 0 deletions repository-meta-analyzer/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,36 @@
</dependency>
</dependencies>

<profiles>
<profile>
<id>native</id>
<activation>
<property>
<name>native</name>
</property>
</activation>
<properties>
<skipITs>false</skipITs>
<quarkus.package.type>native</quarkus.package.type>
</properties>
</profile>

<profile>
<id>non-native</id>
<activation>
<property>
<name>!native</name>
</property>
</activation>
<dependencies>
<dependency>
<groupId>com.google.cloud.sql</groupId>
<artifactId>postgres-socket-factory</artifactId>
</dependency>
</dependencies>
</profile>
</profiles>

<build>
<plugins>
<plugin>
Expand Down
39 changes: 31 additions & 8 deletions vulnerability-analyzer/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,37 @@
<scope>test</scope>
</dependency>
</dependencies>

<profiles>
<profile>
<id>native</id>
<activation>
<property>
<name>native</name>
</property>
</activation>
<properties>
<skipITs>false</skipITs>
<quarkus.package.type>native</quarkus.package.type>
</properties>
</profile>

<profile>
<id>non-native</id>
<activation>
<property>
<name>!native</name>
</property>
</activation>
<dependencies>
<dependency>
<groupId>com.google.cloud.sql</groupId>
<artifactId>postgres-socket-factory</artifactId>
</dependency>
</dependencies>
</profile>
</profiles>

<build>
<plugins>
<plugin>
Expand All @@ -131,12 +162,4 @@
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>native</id>
<properties>
<quarkus.package.type>native</quarkus.package.type>
</properties>
</profile>
</profiles>
</project>

0 comments on commit fdae576

Please sign in to comment.