GradleUp / shadow

Gradle plugin to create fat/uber JARs, apply file transforms, and relocate packages for applications and libraries. Gradle version of Maven's Shade plugin.
https://www.gradleup.com/shadow/
Apache License 2.0
3.77k stars 395 forks source link

Support Kotlin Script Gradle DSL #533

Open ScottPierce opened 4 years ago

ScottPierce commented 4 years ago

Shadow Version

5.2.0

Gradle Version

6.0.1

Expected Behavior

The DSL for this plugin is strongly typed and easy to use.

Actual Behavior

The DSL for this plugin is difficult to use, and weakly typed. I spent a few hours before I found someone who had deconstructed it on stack overflow.

Gradle Build Script(s)

In order to use this plugin, this is what we have to do. Obviously it should be easier than this:

val shadowJar: com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar by tasks
shadowJar.apply {
    manifest.attributes.apply {
        put("Main-Class", serverClassName)
    }

    baseName = project.name + "-fat"
}
johnrengelman commented 4 years ago

Happy to incorporate any pull requests that tighten it up. I don't use the Kotlin DSL though, so I'm not likely to do this myself any time soon.

dector commented 4 years ago

+1 for Kotlin Gradle DSL.

@ScottPierce I'm doing this (more readable):

import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar

tasks.withType<ShadowJar> {
    archiveFileName.set("my-app.jar")   // Use other properties as well
}
Proximyst commented 4 years ago

Due to how even the Kotlin compile task requires the tasks.withType syntax, I doubt anything extra would be the norm.

AHeise commented 4 years ago

I'm usually defining typealias ShadowJar = com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar in my multi-module projects to get rid of the import, but it can't get much crisper. Having some kind of an auto import for fun shadowJar(configure: Action<ShadowJar>): Unit would be nice.

toddiuszho commented 4 years ago

Also please put examples in the publishing doc with Kotlin DSL syntax.

johnrengelman commented 4 years ago

^ again, contributions welcome. I don’t use Kotlin.

serpro69 commented 4 years ago

Anyone figured out how to use this with maven-publish plugin in kotlin-dsl?

elect86 commented 4 years ago

@johnrengelman I offer:

What might you be interested in?

sharmando commented 8 months ago

+1 for Kotlin Gradle DSL.

@ScottPierce I'm doing this (more readable):

import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar

tasks.withType<ShadowJar> {
    archiveFileName.set("my-app.jar") // Use other properties as well
}

This should be in the docs. Thanks a lot!