Skip to content

Override Main-Class with custom value #613

@aalmiray

Description

@aalmiray

Shadow Version

6.1.0

Gradle Version

6.3

Expected Behavior

A project with application and shadow plugins applied.
The project makes use of Java modules, thus mainClassName is set to

ext.moduleName = 'org.kordamp.ikonli.browser'
ext.moduleMainClass = 'org.kordamp.ikonli.browser.Launcher'

mainClassName = "${moduleName}/${moduleMainClass}"

The shaded JAR should not be a modular JAR thus its entry point should only be moduleMainClass.

shadowJar {
    manifest {
        attributes('Main-Class': moduleMainClass)
    }
}

Should result in the manifest containing an entry as the following one

Main-Class: org.kordamp.ikonli.browser.Launcher

Actual Behavior

The generated manifest contains the full modularized main class

Main-Class: org.kordamp.ikonli.browser/org.kordamp.ikonli.browser.Launch
  er

Even if the following is added

shadowJar.doLast {
    manifest.attributes('Main-Class': moduleMainClass)
}

It seems https://github.com/johnrengelman/shadow/blob/master/src/main/groovy/com/github/jengelman/gradle/plugins/shadow/ShadowApplicationPlugin.groovy#L59-L64 always takes effect no matter what.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions