Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import kotlin.io.path.appendText
import kotlin.io.path.readText
import kotlin.io.path.writeText
import org.gradle.api.file.DuplicatesStrategy
import org.junit.jupiter.api.Disabled
import org.junit.jupiter.api.Test

class ShadowJarCachingTest : BaseCachingTest() {
Expand Down Expand Up @@ -211,7 +210,6 @@ class ShadowJarCachingTest : BaseCachingTest() {
}
}

@Disabled("TODO: https://github.com/GradleUp/shadow/pull/1601#discussion_r2260096815")
@Test
fun shadowJarIsCachedCorrectlyAfterApplicationChanged() {
val mainClassName = "my.Main"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,16 +127,18 @@ public abstract class ShadowApplicationPlugin : Plugin<Project> {
}

protected open fun Project.configureShadowJarMainClass() {
val mainClassName = applicationExtension.mainClass
// Default to empty string to avoid the error of the value not being configured yet.
val mainClassName = applicationExtension.mainClass.convention("")
tasks.shadowJar.configure { task ->
task.inputs.property("mainClassName", mainClassName)
task.doFirst {
// Inject the attribute if it is not already present.
if (!task.manifest.attributes.contains(mainClassAttributeKey)) {
task.manifest.attributes[mainClassAttributeKey] = mainClassName.orNull.also { value ->
if (value.isNullOrEmpty()) {
error("The main class must be specified and not left empty in `application.mainClass` or manifest attributes.")
}
val realClass = mainClassName.orNull
if (realClass.isNullOrEmpty()) {
error("The main class must be specified and not left empty in `application.mainClass` or manifest attributes.")
}
task.manifest.attributes[mainClassAttributeKey] = realClass
}
}
}
Expand Down
Loading