Skip to content

Commit

Permalink
fix fat jar
Browse files Browse the repository at this point in the history
  • Loading branch information
wagyourtail committed Jan 2, 2024
1 parent d7c4cf1 commit 7ccb777
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ repositories {
val testA by sourceSets.creating
val testB by sourceSets.creating

kotlinVersion("1.5.21", isPrimaryVersion = true)
kotlinVersion("1.6.20")
val kotlin1521 = kotlinVersion("1.5.21", isPrimaryVersion = true)
val kotlin1620 = kotlinVersion("1.6.20")


dependencies {
Expand All @@ -70,6 +70,8 @@ dependencies {
}

tasks.jar {
from(sourceSets.main.get().output, kotlin1521.output, kotlin1620.output)

manifest {
attributes(
"Implementation-Title" to base.archivesName.get(),
Expand All @@ -80,6 +82,7 @@ tasks.jar {
}

tasks.shadowJar {
from(sourceSets.main.get().output, kotlin1521.output, kotlin1620.output)

configurations = listOf(
project.configurations.shadow.get()
Expand All @@ -98,7 +101,7 @@ tasks.test {
useJUnitPlatform()
}

fun kotlinVersion(version: String, isPrimaryVersion: Boolean = false) {
fun kotlinVersion(version: String, isPrimaryVersion: Boolean = false): SourceSet {
val name = version.replace(".", "")

val sourceSet = sourceSets.create("kotlin$name")
Expand All @@ -113,10 +116,6 @@ fun kotlinVersion(version: String, isPrimaryVersion: Boolean = false) {
sourceSet.compileOnlyConfigurationName("org.jetbrains.kotlin:kotlin-compiler-embeddable:$version")
}

tasks.jar {
from(sourceSet.output)
}

if (!isPrimaryVersion) {
val testTask = tasks.register("testKotlin$name", Test::class) {
useJUnitPlatform()
Expand All @@ -125,6 +124,8 @@ fun kotlinVersion(version: String, isPrimaryVersion: Boolean = false) {
}
tasks.check { dependsOn(testTask) }
}

return sourceSet
}

publishing {
Expand Down

0 comments on commit 7ccb777

Please sign in to comment.