0

I have a multi-module-gradle-build. Some projects have a build.gradle, others have a build.gradle.kts.

Upgrading gradle from 4.10 to 5.4.1 has a strange effect on war projects if and only if they are defined in build.gradle.kts.

$ unzip -l myproject.war
                       ... // WEB-INF/classes left out
        0  2019-05-27 15:23   WEB-INF/lib/
125552613  2019-05-27 15:10   WEB-INF/lib/gradle-api-5.4.1.jar
  8566737  2019-05-27 15:10   WEB-INF/lib/groovy-all-1.0-2.5.4.jar
     1607  2019-05-27 15:10   WEB-INF/lib/gradle-installation-beacon-5.4.1.jar

These jars are not needed and bloat the war file.

They were not contained when built with gradle-4.10.

They are not contained in projects with build.gradle.

How to get rid of them?

I cannot paste the entire build logic. But one of the projects build.gradle.kts that suffers the phenomenon looks so:

import groovy.lang.Closure

plugins {
    `kotlin-dsl`
}

fun gradleScript(name: String) = rootDir.resolve("gradle-scripts/$name.gradle")

apply(from = gradleScript("java8-project"))
apply(from = gradleScript("war-no-version"))
apply(from = gradleScript("deploy-jboss"))
apply(from = gradleScript("kotlin"))
apply(from = gradleScript("jpa-provider"))

val testJpaWith: Closure<String> by extra
//testJpaWith("openjpa")
testJpaWith("hibernate")

val test by tasks.getting(Test::class) {
    useJUnitPlatform()
}

dependencies {
    compileOnly(Libs.javaee_api)

    testCompileOnly(Libs.javaee_api)
    testImplementation(Libs.assertj_core)
    testRuntimeOnly("org.glassfish:javax.json:1.0.4")

    testImplementation(Libs.javalin)
    testRuntimeOnly("com.fasterxml.jackson.core:jackson-databind:2.9.6")
    testImplementation("khttp:khttp:1.0.0")
    testImplementation(project(":test-jpa"))

    testImplementation(Libs.junit_jupiter_api)
    testRuntimeOnly(Libs.junit_jupiter_engine)
}
Frank Neblung
  • 3,047
  • 17
  • 34
  • 1
    Most probably by fixing your build. But you haven't posted any code... Post a complete minimal example reproducing the issue. – JB Nizet May 28 '19 at 07:04

1 Answers1

0

Answering my own question:

Replacing

plugins {
    `kotlin-dsl`
}

by

plugins {
    id("org.jetbrains.kotlin.jvm")
}

solved the issue

Frank Neblung
  • 3,047
  • 17
  • 34