buildpacks: Kotlin http4k pack gets stuck after running gradlew

I have a very simple Kotlin application using http4k. My main file is:

package com.sample

import org.http4k.core.Request
import org.http4k.core.Response
import org.http4k.core.Status.Companion.OK
import org.http4k.server.Undertow
import org.http4k.server.asServer

fun main() {
    { _: Request -> Response(OK).body("Hello World") }.asServer(Undertow(8000)).start()
}

And my build.gradle.kts is:

import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
    kotlin("jvm") version "1.8.10"
    kotlin("plugin.serialization") version "1.8.10"
    application
}

group = "com.sample"
version = "1.0-SNAPSHOT"

repositories {
    mavenCentral()
}

dependencies {
    implementation("org.http4k:http4k-client-okhttp:4.35.4.0")
    testImplementation(kotlin("test"))
    testImplementation("org.http4k:http4k-testing-hamkrest:4.35.4.0")
    testImplementation("org.junit.jupiter:junit-jupiter:5.9.2")
    implementation(platform("org.http4k:http4k-bom:4.36.0.0"))
    implementation("org.http4k:http4k-core")
    implementation("org.http4k:http4k-format-jackson:4.36.0.0")
    implementation("org.http4k:http4k-server-undertow")
    implementation("org.http4k:http4k-client-apache")
}

tasks.test {
    useJUnitPlatform()
}

tasks.withType<KotlinCompile> {
    kotlinOptions.jvmTarget = "1.8"
}

application {
    mainClass.set("com.sample.MainKt")
}

If I run ./gradlew clean assemble -x test --build-cache --quiet it succeeds, But when I run: pack build --builder=gcr.io/buildpacks/builder:v1 sample it gets stuck with this log:

1: Pulling from buildpacks/builder
Digest: sha256:fef6485ba433bdc568059bbff157bd605d1462c603c485a821461851de2a132f
Status: Image is up to date for gcr.io/buildpacks/builder:v1
v1: Pulling from buildpacks/gcp/run
Digest: sha256:f01b91323fbe89c1b1914f45f43e9f606b0feefef0401e25f0a7126141e4b3e3
Status: Image is up to date for gcr.io/buildpacks/gcp/run:v1
===> ANALYZING
Previous image with name "sample" not found
===> DETECTING
4 of 5 buildpacks participating
google.java.runtime    0.9.1
google.java.gradle     0.9.0
google.java.entrypoint 0.9.0
google.utils.label     0.0.2
===> RESTORING
===> BUILDING
=== Java - Runtime (google.java.runtime@0.9.1) ===
Using latest Java 11 runtime version. You can specify a different version with GOOGLE_RUNTIME_VERSION: https://github.com/GoogleCloudPlatform/buildpacks#configuration
2023/03/13 16:05:52 [DEBUG] GET https://dl.google.com/runtimes/ubuntu1804/openjdk/version.json
Installing  v11.0.18+10.
2023/03/13 16:05:53 [DEBUG] GET https://dl.google.com/runtimes/ubuntu1804/openjdk/openjdk-11.0.18_10.tar.gz
Warning: BOM table is deprecated in this buildpack api version, though it remains supported for backwards compatibility. Buildpack authors should write BOM information to <layer>.sbom.<ext>, launch.sbom.<ext>, or build.sbom.<ext>.
Warning: BOM table is deprecated in this buildpack api version, though it remains supported for backwards compatibility. Buildpack authors should write BOM information to <layer>.sbom.<ext>, launch.sbom.<ext>, or build.sbom.<ext>.
Warning: BOM table is deprecated in this buildpack api version, though it remains supported for backwards compatibility. Buildpack authors should write BOM information to <layer>.sbom.<ext>, launch.sbom.<ext>, or build.sbom.<ext>.
=== Java - Gradle (google.java.gradle@0.9.0) ===
--------------------------------------------------------------------------------
Running "./gradlew clean assemble -x test --build-cache --quiet"
Downloading https://services.gradle.org/distributions/gradle-7.5.1-bin.zip
...........10%............20%...........30%............40%...........50%............60%...........70%............80%...........90%............100%

If I run ./gradlew run the server starts as expected.

What am I doing wrong? The sample java project from https://github.com/GoogleCloudPlatform/buildpack-samples/tree/master/sample-java-gradle works just fine, so I don’t think there’s an issue with my local set-up.

I also tried running on Google Cloud Build and got slightly more information:

[builder] Downloading https://services.gradle.org/distributions/gradle-7.5.1-bin.zip
[builder] ...........10%............20%...........30%............40%...........50%............60%...........70%............80%...........90%............100%
[builder] Done "./gradlew clean assemble -x test --build-cache --quiet" (2m23.226743201s)
[builder] === Java - Entrypoint (google.java.entrypoint@0.9.0) ===
[builder] Failure: (ID: 838926df) did not find any jar files with a Main-Class manifest entry
[builder] --------------------------------------------------------------------------------
[builder] Sorry your project couldn't be built.
[builder] Our documentation explains ways to configure Buildpacks to better recognise your project:
[builder]  -> https://cloud.google.com/docs/buildpacks/overview
[builder] If you think you've found an issue, please report it:
[builder]  -> https://github.com/GoogleCloudPlatform/buildpacks/issues/new

I don’t know where it’s trying to find the main class. The application plugin should be taking care of this with the

application {
    mainClass.set("com.sample.MainKt")
}

section.

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 15 (6 by maintainers)

Most upvoted comments

I received that BOM debug warning in my build step as well, the flag that fixed it for me was to add ‘–no-cache’ to the deploy command. I see you have used --build-cache in your solution as well - Might be something wrong with the cached version of the buildpack?

Taking a look…