简体   繁体   中英

Gradle add compileClasspath to configurations in ShadowJar (kotlin)

Shadowjar's docs say to do this:

shadowJar {
  configurations = [project.configurations.compileClasspath]
}

This appears to be in Groovy. If I run this in my Kotlin based gradle project, I get the following error:

Type mismatch:
  inferred type is
    Array<NamedDomainObjectProvider<Configuration>>, but
    (Mutable)List<FileCollection!>! was expected

How can I perform this in Kotlin?

The equivalent would be:

tasks {
    shadowJar {
        configurations = listOf(project.configurations.compileClasspath.get())
    }
}

The call to .get() is required because the return is NamedDomainObjectProvider<Configuration> . The Shadow plugin does not appear to support the lazy properties Gradle provides.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM