MANIFEST.MF is empty

Hi all,

After some extensive googling, I’m stuck and could use some help. I have a gradle project started in intellij that I’m unable to build correctly into my dockerfile. I’m realizing that the jar being produced has an empty MANIFEST.MF file. Here are the details:

plugins {
    id 'application'
    id 'java-library'
}

group 'org.myorg'
version '1.0-SNAPSHOT'

repositories {
    mavenCentral()
}

dependencies {
    testImplementation('org.junit.jupiter:junit-jupiter-api:5.7.0')
    testImplementation("org.assertj:assertj-core:3.21.0")
    testRuntimeOnly('org.junit.jupiter:junit-jupiter-engine:5.7.0')
    implementation("com.slack.api:bolt:1.13.0")
    implementation("com.slack.api:bolt-servlet:1.13.0")
    implementation("com.slack.api:bolt-jetty:1.13.0")
    implementation("org.slf4j:slf4j-simple:1.7.32")
    implementation("org.slf4j:slf4j-api:1.7.32")
    implementation 'org.slf4j:slf4j-log4j12:1.7.29'
    implementation platform('com.amazonaws:aws-java-sdk-bom:1.12.99')
    implementation platform("org.apache.logging.log4j:log4j-bom:2.14.1")
    implementation 'com.amazonaws:aws-java-sdk-dynamodb'
    implementation 'org.apache.logging.log4j:log4j-api'
    implementation 'org.apache.logging.log4j:log4j-core'
    implementation 'javax.json:javax.json-api:1.1.4'
    implementation "org.apache.commons:commons-lang3:3.12.0"
    testImplementation "org.mockito:mockito-core:4.+"
}

test {
    useJUnitPlatform()
}

application {
    mainClass = "myapp.AppServer"
}

I’m on 7.3 gradle and here are the commands I’m running:

▶ gradlew jar --warning-mode all

BUILD SUCCESSFUL in 1s
2 actionable tasks: 2 up-to-date
jar xf build/libs/myjar-1.0-SNAPSHOT.jar META-INF/MANIFEST.MF

(no output from the above)

If I try to run the jar I get:

no main manifest attribute, in myjar.jar

One thing I’m noticing is that if I use gradle init rather than intellij to start a new application, gradle init puts the java project in an app directory where intellij did not. At this point i’m grasping at straws and could use some help . Thanks!

The application plugin does not create executable jars, it sets up the project to create start scripts for unix and windows. See Application Plugin docs for details.

If you wish to add a Main-Class attribute to the manifest in order to make it executable, you’ll need to configure it.

jar {
    manifest {
        attributes 'Main-Class': 'myapp.AppServer'
    }
}