Tony
Tony

Reputation: 1528

How to specify my own manifest file in the Gradle war plugin?

How to specify my own manifest file in the Gradle war plugin? I need a one to one translation of the below maven pom snippets to Gradle. I wish there is a one to one translation tool from maven to grade. btw, the gradle init does not address the details such as exlcude, manifestFile.

from maven pom.xml:

<build>
    <defaultGoal>validate</defaultGoal>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <configuration>
                <failOnMissingWebXml>false</failOnMissingWebXml>
                <archiveClasses>true</archiveClasses>
                <warSourceExcludes>WEB-INF/classes/**</warSourceExcludes>
                <archive>
                    <manifestFile>src/main/webapp/META-INF/MANIFEST.MF</manifestFile>
                </archive>
            </configuration>
        </plugin>
    </plugins>
</build>

Upvotes: 1

Views: 2680

Answers (1)

M.Ricciuti
M.Ricciuti

Reputation: 12096

See official documentation : you can customize the Jar/war manifest as follows (more details in the Manifest API )

war{
    manifest {
        // include attributes from a custom manifest file
        from("src/main/resources/CUSTOM-MANIFEST.MF")

        // specify custom attributes
        attributes('My-Attribute': 'value')
    }
}

Note that Gradle will merge your custom attributes with the ones generated by the war task itself, if any.

Upvotes: 3

Related Questions