Any hints how to properly configurate shadow plug...
# getting-started
j
Any hints how to properly configurate shadow plugin? Getting these errors and since I have very limited experience with gradle and shadow plugin it’s not clear wha’t wrong (except for that some things are obviously missing) https://gist.github.com/jcechace/96e8dd2801b677a50a87cebb42e81748
n
can you share your gradle file ? its possible you may be forced to use `compile`/`api` instead of
implementation
on some things - but thats just a random guess
j
ok, on all the things
n
first thing:
Copy code
base {
    archivesBaseName = "app"
}
second: shadowJar does not like being applied before setting the mainclassname (at least when i am using it) you can get around that with
id("shadojar etc" version "2.0.4" )apply false
i configure it like this:
Copy code
plugins {
    ...
    id("com.github.johnrengelman.shadow") version "4.0.0" apply false
}
apply<ApplicationPlugin>()

                configure<JavaApplication> {
                    mainClassName = "package.MainKt"
                }

                apply(plugin = "com.github.johnrengelman.shadow")

                val runDir = rootProject.file("run")

                val run by tasks.getting(JavaExec::class) {
                    workingDir = runDir
                }

                val runShadow by tasks.getting(JavaExec::class) {
                    workingDir = runDir
                }

                val shadowJar by tasks.getting(ShadowJar::class) {
                    classifier = ""
                    archiveName = "${project.name.toLowerCase()}-${Env.versionSuffix}.$extension"
                }

                val build by tasks.getting(Task::class) {
                    dependsOn(shadowJar)
                }
i am not sure if the Java Application stuff is stil necessary, at least for a while it did not like using the generated accesors
i vopied it out of a much more complex usecase where i set up runnable subprojects based on a Map<Project, String>
j
it shoudlnt/
Copy code
application {
    mainClassName = "io.apiman.watcher.WatcherAppKt"
}
should do the same
also is there something else going on beside configuring the runDir to the one where “run” file is located”
val runDir = rootProject.file("run")
n
i use it in a few more places
like adding it to idea ignore folder
so you can inline it
j
Hmm fails with
Copy code
gradle assembleShadowDist --warning-mode all
The AbstractFileCollection.getBuildDependencies() method has been deprecated. This is scheduled to be removed in Gradle 5.0. com.github.jengelman.gradle.plugins.shadow.internal.DependencyFileCollection extends AbstractFileCollection. Do not extend AbstractFileCollection. Use Project.files() instead.

BUILD SUCCESSFUL in 0s
6 actionable tasks: 6 up-to-date
Turn out, only
apply(plugin = "com.github.johnrengelman.shadow")
was needed. Thanks @Nikky