Skip to content

Java buildpack cannot deploy Maven multi-module projects when the deployable module is not the reactor root #668

Description

@WojciechNiemiec

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:

  1. The buildpack should evaluate the deployable Maven module (respecting GOOGLE_MAVEN_BUILD_ARGS), or

  2. 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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions