GarouDan
04/25/2019, 2:42 PM<https://github.com/johnrengelman/shadow> plugin, to create fatJars.
I’ve already done the integration in my project but I’m seeing only a knows task. (I’m using gradle 5.3.1)
My current configuration is:
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
...
plugins {
kotlin("multiplatform")
id("com.github.johnrengelman.shadow") version "5.0.0"
}
...
tasks.withType<ShadowJar> {
baseName = "app"
classifier = ""
version = ""
}
With ./gradlew tasks I can se only a knows task
Shadow tasks
------------
knows - Do you know who knows?
and if I run ./gradlew shadowJar I receive an error like:
* What went wrong:
Task 'shadowJar' not found in root project 'my_project'.
Does someone have a working example with a kotlin mpp project and fatJars?
It looks like the shadowJar task is created only in the presence of the JavaPlugin and because I’m using Kotlin it is not being created.
Thanks in advance!ribesg
04/25/2019, 2:47 PMGarouDan
04/25/2019, 4:01 PM.kts and handle with the internal implementations of this plugin.
https://github.com/johnrengelman/shadow/blob/5.0.0/src/main/groovy/com/github/jengelman/gradle/plugins/shadow/ShadowJavaPlugin.groovy#L41-L66Dominaezzz
04/25/2019, 4:29 PMDominaezzz
04/25/2019, 4:29 PMwithType to create.Dominaezzz
04/25/2019, 4:29 PMGarouDan
04/25/2019, 4:35 PMtasks.create("shadowJar", ShadowJar::class.java) {
baseName = "my_project"
classifier = ""
version = ""
}
and after running the shadowJar a file named my_project.jar was created.
But when I tried to run java -jar my_project.jar I’ve received
no main manifest attribute, in my_project.jar
So I think it is still not a fat jar yet =/
If you have any clues, please kindly let me knowGarouDan
04/25/2019, 4:37 PMMETA-INF/
META-INF/MANIFEST.MF
and inside the manifest:
Manifest-Version: 1.0Dominaezzz
04/25/2019, 4:57 PMGarouDan
04/25/2019, 6:45 PMtasks.withType<ShadowJar> {
manifest {
attributes.put("Main-Class", "com.example.ExampleKt")
}
val target = kotlin.targets.jvm("myTarget")
from(target.compilations["main"].output)
val runtimeClasspath = target.compilations["main"].compileDependencyFiles as Configuration
configurations = mutableListOf(runtimeClasspath)
}
I still need to check some other options, but finally something working 😉