My goal is to create a FatJar from the module "custom-wiremock-extension" and automatically place it in the extensions folder of Wiremock.
My project is structured in the following way:
.
├── ...
│
├── e2e (module)
│ ...
│ └── build.gradle.kts
│
├── custom-wiremock-extension (module)
│ ...
│ └── build.gradle.kts
│
├── src
│ ...
│
├── wiremock
│ ...
│ └── extensions
│
├── build.gradle.kts
└── settings.gradle.kts
This is the build.gradle.kts of "custom-wiremock-extension"-module:
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
alias(libs.plugins.kotlin.jvm)
kotlin("plugin.serialization") version "1.8.10"
id("com.github.johnrengelman.shadow") version "8.1.0"
}
apply(from = "${rootProject.rootDir}/gradle/scripts/repositories.gradle.kts")
dependencies {
...
}
group = "my.wiremock.extension"
version = "1.0-SNAPSHOT"
kotlin {
jvmToolchain {
this.languageVersion.set(JavaLanguageVersion.of(17))
}
}
tasks.withType<KotlinCompile>().configureEach {
kotlinOptions {
freeCompilerArgs = listOf("-Xjsr305=strict", "-Xjvm-default=all-compatibility")
jvmTarget = "17"
apiVersion = "1.7"
}
}
val extensionJar by tasks.registering(ShadowJar::class) {
archiveBaseName.set("custom-wiremock-extension")
archiveClassifier.set("sources")
}
artifacts {
archives(extensionJar)
}
FatJar creation is working. But is it possible to automate the relocation within the build.gradle.kts?