Skip to content

Commit

Permalink
fix gcp build with latest maven (#750)
Browse files Browse the repository at this point in the history
* script to help check for the issue

* pom that pins good version of maven-assembly-plugin (3.6.0)

* more correct uber-jar assembly pom

* revert assembly plugin version to latest, although leave pinned
  • Loading branch information
eschultink authored Jul 10, 2024
1 parent 14de947 commit 13ef435
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 4 deletions.
18 changes: 18 additions & 0 deletions java/impl/gcp/check-grpc-services.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash

# helper script to quickly check the gRPC services in a jar file, which seems to be root cause
# of the gRPC issue in the cloud function

# determine the jar file to check
VERSION=$1
JAR_FILE=target/psoxy-gcp-${VERSION}.jar

BLUE='\e[34m'
NC='\e[0m' # No Color

printf "Checking grpc load balancer services in jar file: ${BLUE}${JAR_FILE}${NC}\n"
printf " (as of 2024-07-10, good one contains 3 files, including 'io.grpc.internal.PickFirstLoadBalancerProvider')\n"
jar xf $JAR_FILE META-INF/services/io.grpc.LoadBalancerProvider

cat META-INF/services/io.grpc.LoadBalancerProvider
rm -rf META-INF
9 changes: 5 additions & 4 deletions java/impl/gcp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -182,15 +182,16 @@
<!-- produces an 'uber' JAR, with all deps pkg'd -->
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.7.1</version>
<configuration>
<archive>
<manifest>
<mainClass>co.worklytics.psoxy.Route</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<descriptors>
<descriptor>uber-jar.xml</descriptor>
</descriptors>
<appendAssemblyId>false</appendAssemblyId>
</configuration>
<executions>
Expand Down Expand Up @@ -251,7 +252,7 @@

<!-- add license plugin -->
<!-- use mvn goal license:aggregate-third-party-report to get report on licenses about
dependencies, to facillitate eventual distribution of built JAR -->
dependencies, to facilitate eventual distribution of built JAR -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>license-maven-plugin</artifactId>
Expand Down
25 changes: 25 additions & 0 deletions java/impl/gcp/uber-jar.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.2.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.2.0 http://maven.apache.org/xsd/assembly-2.2.0.xsd">

<id>uber-jar</id>
<formats>
<format>jar</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<dependencySets>
<dependencySet>
<outputDirectory>/</outputDirectory>
<useProjectArtifact>true</useProjectArtifact>
<unpack>true</unpack>
<scope>runtime</scope>
</dependencySet>
</dependencySets>
<!-- above from https://maven.apache.org/plugins/maven-assembly-plugin/descriptor-refs.html#jar-with-dependencies -->
<!-- what we need is below, to merge all the META-INF/services files -->
<containerDescriptorHandlers>
<containerDescriptorHandler>
<handlerName>metaInf-services</handlerName>
</containerDescriptorHandler>
</containerDescriptorHandlers>
</assembly>

0 comments on commit 13ef435

Please sign in to comment.