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
1 change: 1 addition & 0 deletions docs/changes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
and `META-INF/groovy` will be merged into `META-INF/groovy/org.codehaus.groovy.runtime.ExtensionModule`.
- Move injecting `Class-Path` manifest attr logic from `doFirst` into `copy`. ([#1720](https://github.com/GradleUp/shadow/pull/1720))
- Deprecate `InheritManifest`. ([#1722](https://github.com/GradleUp/shadow/pull/1722))
- Use default `JavaExec` error message when main class is not set. ([#1725](https://github.com/GradleUp/shadow/pull/1725))

### Fixed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,8 @@ class ApplicationPluginTest : BasePluginTest() {
val result = runWithFailure(runShadowPath)

assertThat(result.output).contains(
"The main class must be specified and not left empty in `application.mainClass` or manifest attributes.",
"Error: Could not find or load main class",
"Caused by: java.lang.ClassNotFoundException:",
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,9 @@ public abstract class ShadowApplicationPlugin : Plugin<Project> {
tasks.shadowJar.configure { task ->
task.inputs.property("mainClassName", mainClassName)
task.doFirst("Set $mainClassAttributeKey attribute in the manifest") {
val realClass = mainClassName.orNull
// Inject the attribute if it is not already present.
if (!task.manifest.attributes.contains(mainClassAttributeKey)) {
val realClass = mainClassName.orNull
if (realClass.isNullOrEmpty()) {
error("The main class must be specified and not left empty in `application.mainClass` or manifest attributes.")
}
if (!task.manifest.attributes.contains(mainClassAttributeKey) && !realClass.isNullOrEmpty()) {
task.manifest.attributes[mainClassAttributeKey] = realClass
}
}
Expand Down