diff --git a/build.gradle.kts b/build.gradle.kts index 87edbb9..4de06ed 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -16,6 +16,7 @@ dependencies { implementation("com.google.protobuf:protobuf-gradle-plugin:0.9.4") implementation("com.gradle.publish:plugin-publish-plugin:1.3.0") implementation("com.gradle:develocity-gradle-plugin:3.19") + implementation("com.gradleup.shadow:shadow-gradle-plugin:8.3.5") implementation( "gradle.plugin.com.google.cloud.artifactregistry:artifactregistry-gradle-plugin:2.2.2" ) diff --git a/src/main/descriptions/org.hiero.gradle.feature.shadow.txt b/src/main/descriptions/org.hiero.gradle.feature.shadow.txt new file mode 100644 index 0000000..9109715 --- /dev/null +++ b/src/main/descriptions/org.hiero.gradle.feature.shadow.txt @@ -0,0 +1 @@ +Conventions for 'com.gradleup.shadow' to be used to build a fat Jar of an application \ No newline at end of file diff --git a/src/main/kotlin/org.hiero.gradle.feature.shadow.gradle.kts b/src/main/kotlin/org.hiero.gradle.feature.shadow.gradle.kts new file mode 100644 index 0000000..a4e1857 --- /dev/null +++ b/src/main/kotlin/org.hiero.gradle.feature.shadow.gradle.kts @@ -0,0 +1,26 @@ +// SPDX-License-Identifier: Apache-2.0 +import com.github.jengelman.gradle.plugins.shadow.internal.DefaultDependencyFilter +import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar + +plugins { + id("application") + id("com.gradleup.shadow") +} + +tasks.withType().configureEach { + group = "shadow" + mergeServiceFiles() + + manifest { attributes("Multi-Release" to "true") } + + // There is an issue in the shadow plugin that it automatically accesses the + // files in 'runtimeClasspath' while Gradle is building the task graph. + // See: https://github.com/GradleUp/shadow/issues/882 + dependencyFilter = NoResolveDependencyFilter() +} + +class NoResolveDependencyFilter : DefaultDependencyFilter(project) { + override fun resolve(configuration: FileCollection): FileCollection { + return configuration + } +}