quarkusio/quarkus · error · BuildException

Google Cloud Function deployment need to use a uberjar, plea

Error message

Google Cloud Function deployment need to use a uberjar, please set 'quarkus.package.jar.type=uber-jar' inside your application.properties

What it means

Google Cloud Function deployment for production requires a single uber-jar so gcloud can deploy it; if the build produced a non-uber jar, this build step fails with a BuildException telling you to set the uber-jar package type. It enforces the packaging requirement of GCF's Java runtime.

Source

Thrown at extensions/google-cloud-functions/deployment/src/main/java/io/quarkus/gcp/functions/deployment/CloudFunctionDeploymentBuildStep.java:34

import io.quarkus.deployment.pkg.steps.NativeBuild;
import io.quarkus.deployment.pkg.steps.NativeSourcesBuild;

public class CloudFunctionDeploymentBuildStep {
    @BuildStep(onlyIf = NativeSourcesBuild.class)
    void failForNativeSources(BuildProducer<ArtifactResultBuildItem> artifactResultProducer) {
        throw new IllegalArgumentException(
                "The Google Cloud extensions are incompatible with the 'native-sources' package type.");
    }

    /**
     * Creates a target/deployment dir and copy the uber jar in it.
     * This facilitates the usage of the 'gcloud' command.
     */
    @BuildStep(onlyIf = IsProduction.class, onlyIfNot = NativeBuild.class)
    public ArtifactResultBuildItem functionDeployment(OutputTargetBuildItem target, JarBuildItem jar)
            throws BuildException, IOException {
        if (!jar.isUberJar()) {
            throw new BuildException("Google Cloud Function deployment need to use a uberjar, " +
                    "please set 'quarkus.package.jar.type=uber-jar' inside your application.properties",
                    List.of());
        }

        Path deployment = target.getOutputDirectory().resolve("deployment");
        if (Files.notExists(deployment)) {
            Files.createDirectory(deployment);
        }

        Path jarPath = jar.getPath();
        Path targetJarPath = deployment.resolve(jarPath.getFileName());
        Files.deleteIfExists(targetJarPath);
        Files.copy(jarPath, targetJarPath);

        return new ArtifactResultBuildItem(targetJarPath, "function", Map.of());
    }
}

View on GitHub (pinned to e1c734241f)

Solutions

  1. Set quarkus.package.jar.type=uber-jar in application.properties.
  2. Or build with -Dquarkus.package.jar.type=uber-jar on the command line.
  3. If you intend a native GCF function, build with -Dnative instead (this check is skipped for native builds).

Example fix

// before (application.properties)
# no package config (defaults to fast jar)
// after
quarkus.package.jar.type=uber-jar
Defensive patterns

Strategy: validation

Validate before calling

// CI pre-check
if ! grep -q 'quarkus.package.jar.type=uber-jar' src/main/resources/application.properties; then
  echo "GCF requires quarkus.package.jar.type=uber-jar"; exit 1;
fi

Prevention

When it happens

Trigger: Running the production build of a Google Cloud Functions project with a package type other than uber-jar (e.g. quarkus.package.type=jar, the default fast-jar), while not building native.

Common situations: Upgraded projects where the default packaging changed away from uber-jar; new projects created without GCF-specific packaging config; CI builds overriding quarkus.package.jar.type.

Related errors


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/460339e482024ee2. Report an issue: GitHub.