Environment
- Cloud Functions Gen2
- Java 21
- Google Java Buildpacks
- Maven multi-module project
Project structure
root/
├── pom.xml (packaging=pom)
├── application/
│ ├── pom.xml
│ └── src/...
├── billing/
├── booking/
├── facility/
└── ...
The root project is an aggregator (packaging=pom).
The deployable Cloud Function is contained in the application module. The remaining modules are regular Maven dependencies.
Deployment is performed using:
- name: Deploy HTTP Function
run: |
gcloud functions deploy "${{ matrix.function.name }}" \
--gen2 \
--project="$PROJECT_ID" \
--region="$REGION" \
--runtime="java21" \
--source="." \
--entry-point="io.micronaut.gcp.function.http.HttpFunction" \
--trigger-http \
--allow-unauthenticated
Problem
The buildpack correctly respects GOOGLE_MAVEN_BUILD_ARGS during the Maven build.
For example:
[_]
schema-version = "0.2"
[[io.buildpacks.build.env]]
name = "GOOGLE_MAVEN_BUILD_ARGS"
value = "-pl application -am clean install --batch-mode -DskipTests"
The reactor builds successfully.
However, immediately afterwards the buildpack executes:
mvn help:evaluate -q -DforceStdout -Dexpression=project.build.finalName
without applying the configured Maven arguments.
As a result it evaluates the reactor root project instead of the deployable module and returns:
underground-football-1.0-SNAPSHOT
The buildpack then expects the output artifact to exist at:
target/underground-football-1.0-SNAPSHOT.jar
However, the root project has:
<packaging>pom</packaging>
and therefore never produces a JAR.
The actual deployable artifact is located at:
application/target/application-1.0-SNAPSHOT.jar
The build fails with:
expected output jar target/underground-football-1.0-SNAPSHOT.jar does not exist
Expected behavior
Either:
-
The buildpack should evaluate the deployable Maven module (respecting GOOGLE_MAVEN_BUILD_ARGS), or
-
There should be a documented way to specify which Maven module produces the deployable artifact.
At the moment I could not find a supported way to deploy a standard Maven multi-module project where the deployable module is not the reactor root.
Environment
Project structure
The root project is an aggregator (
packaging=pom).The deployable Cloud Function is contained in the
applicationmodule. The remaining modules are regular Maven dependencies.Deployment is performed using:
Problem
The buildpack correctly respects
GOOGLE_MAVEN_BUILD_ARGSduring the Maven build.For example:
The reactor builds successfully.
However, immediately afterwards the buildpack executes:
without applying the configured Maven arguments.
As a result it evaluates the reactor root project instead of the deployable module and returns:
The buildpack then expects the output artifact to exist at:
However, the root project has:
and therefore never produces a JAR.
The actual deployable artifact is located at:
The build fails with:
Expected behavior
Either:
The buildpack should evaluate the deployable Maven module (respecting
GOOGLE_MAVEN_BUILD_ARGS), orThere should be a documented way to specify which Maven module produces the deployable artifact.
At the moment I could not find a supported way to deploy a standard Maven multi-module project where the deployable module is not the reactor root.