gantsign / ktlint-maven-plugin

Maven plugin for ktlint the Kotlin linter
http://gantsign.com/ktlint-maven-plugin/
MIT License
61 stars 17 forks source link

Plugin has OOM exception when building Docker image #584

Open sgolubovic-interventure opened 10 months ago

sgolubovic-interventure commented 10 months ago

I have a simple example of a Spring Boot application which I'm trying to Dockerize:


In Dockerfile I try to build the JAR using ./mvnw package command in first step, and use produced JAR in the second step:

FROM eclipse-temurin:17-jdk-jammy AS builder

COPY mvnw .
COPY .mvn .mvn
COPY pom.xml .
COPY src src

RUN ./mvnw package -DskipTests -e
# ------------------------------------------------------
FROM amazoncorretto:17-alpine-jdk

WORKDIR /apps

COPY --from=builder /target/demo-*.jar /apps/app.jar

USER nobody
CMD ["java", "-jar", "app.jar"]

When I try to build the image using docker image build -t demo:1 ., at some point I get:

Downloading from central: https://repo.maven.apache.org/maven2/com/pinterest/ktlint/ktlint-reporter-checkstyle/0.48.2/ktlint-reporter-checkstyle-0.48.2.jar
Downloaded from central: https://repo.maven.apache.org/maven2/com/pinterest/ktlint/ktlint-reporter-checkstyle/0.48.2/ktlint-reporter-checkstyle-0.48.2.jar (7.0 kB at 10 kB/s)
17.49 Downloading from central: https://repo.maven.apache.org/maven2/com/pinterest/ktlint/ktlint-reporter-json/0.48.2/ktlint-reporter-json-0.48.2.jar
Downloaded from central: https://repo.maven.apache.org/maven2/commons-collections/commons-collections/3.2.2/commons-collections-3.2.2.jar (588 kB at 866 kB/s)
17.50 Downloading from central: https://repo.maven.apache.org/maven2/com/pinterest/ktlint/ktlint-ruleset-experimental/0.48.2/ktlint-ruleset-experimental-0.48.2.jar
Downloaded from central: https://repo.maven.apache.org/maven2/org/jetbrains/kotlin/kotlin-stdlib-jdk7/1.8.0/kotlin-stdlib-jdk7-1.8.0.jar (963 B at 1.4 kB/s)
17.51 Downloading from central: https://repo.maven.apache.org/maven2/com/pinterest/ktlint/ktlint-ruleset-standard/0.48.2/ktlint-ruleset-standard-0.48.2.jar
Downloaded from central: https://repo.maven.apache.org/maven2/com/pinterest/ktlint/ktlint-reporter-json/0.48.2/ktlint-reporter-json-0.48.2.jar (7.1 kB at 10 kB/s)
17.51 Downloading from central: https://repo.maven.apache.org/maven2/org/dom4j/dom4j/2.1.4/dom4j-2.1.4.jar
Downloaded from central: https://repo.maven.apache.org/maven2/com/pinterest/ktlint/ktlint-ruleset-experimental/0.48.2/ktlint-ruleset-experimental-0.48.2.jar (148 kB at 204 kB/s)
Downloaded from central: https://repo.maven.apache.org/maven2/org/jetbrains/kotlin/kotlin-stdlib/1.8.0/kotlin-stdlib-1.8.0.jar (1.6 MB at 2.2 MB/s)
Downloaded from central: https://repo.maven.apache.org/maven2/org/dom4j/dom4j/2.1.4/dom4j-2.1.4.jar (325 kB at 435 kB/s)
Downloaded from central: https://repo.maven.apache.org/maven2/com/pinterest/ktlint/ktlint-ruleset-standard/0.48.2/ktlint-ruleset-standard-0.48.2.jar (420 kB at 557 kB/s)
Downloaded from central: https://repo.maven.apache.org/maven2/org/jetbrains/kotlin/kotlin-compiler-embeddable/1.8.0/kotlin-compiler-embeddable-1.8.0.jar (54 MB at 37 MB/s)
302.1 [INFO] ------------------------------------------------------------------------
302.1 [INFO] BUILD FAILURE
302.1 [INFO] ------------------------------------------------------------------------
302.1 [INFO] Total time:  05:00 min
302.1 [INFO] Finished at: 2023-11-23T11:26:54Z
302.1 [INFO] ------------------------------------------------------------------------
302.1 [ERROR] Java heap space: failed reallocation of scalar replaced objects -> [Help 1]
302.1 java.lang.OutOfMemoryError: Java heap space: failed reallocation of scalar replaced objects

If I comment out the plugin, everything works fine. Also, if I try to build it locally with ./mvnw clean package -Dmaven.repo.local=.m2/repo it works fine as well.

Does anyone have an idea what could be the issue?


Here is the MWE. demo.zip