Configure manifest in gradle 9

Im using gradle 8.5 and Im preparing my build files for gradle 9.
Its a multi module build that produces Jar, War and Ear files that all need a “base” manifest.
Im getting a warning that I don’t know how to solve.

Main build file

ext {
    sharedManifest = manifest { // (line 31)
        attributes(
                'Built-By': System.properties['user.name'],
                'Created-By': "Gradle ${gradle.gradleVersion}",
                'Build-Jdk': "${System.properties['java.version']} (${System.properties['java.vendor']} ${System.properties['java.vm.version']})",
                'Build-OS': "${System.properties['os.name']} ${System.properties['os.arch']} ${System.properties['os.version']}",
                'FooBar-Version': "${versionBuild}.${versionClient}.${versionServer}",
                'FooBar-Build-Date': "$versionBuildDate"
        )
    }
Build file '/home/klaus/git/foobar/build.gradle': line 31
The org.gradle.api.plugins.JavaPluginConvention type has been deprecated. This is scheduled to be removed in Gradle 9.0. Consult the upgrading guide for further information: https://docs.gradle.org/8.5/userguide/upgrading_version_8.html#java_convention_deprecation
        at build_c7y2peejtowptq0xb3mjb04jd$_run_closure2.doCall$original(/home/klaus/git/foobar/build.gradle:31)
        (Run with --stacktrace to get the full stack trace of this deprecation warning.)
        at build_c7y2peejtowptq0xb3mjb04jd.run(/home/klaus/git/foobar/build.gradle:21)
        (Run with --stacktrace to get the full stack trace of this deprecation warning.)
Build file '/home/klaus/git/foobar/build.gradle': line 31
The org.gradle.api.plugins.Convention type has been deprecated. This is scheduled to be removed in Gradle 9.0. Consult the upgrading guide for further information: https://docs.gradle.org/8.5/userguide/upgrading_version_8.html#deprecated_access_to_conventions
        at build_c7y2peejtowptq0xb3mjb04jd$_run_closure2.doCall$original(/home/klaus/git/foobar/build.gradle:31)
        (Run with --stacktrace to get the full stack trace of this deprecation warning.)
        at build_c7y2peejtowptq0xb3mjb04jd.run(/home/klaus/git/foobar/build.gradle:21)
        (Run with --stacktrace to get the full stack trace of this deprecation warning.)

The way it is used in sub modules is like this:

war {
    archiveFileName = 'api-v7.war'

    manifest {
        from sharedManifest
        attributes(
                'someKey': 'someValue'
        )
}

It means that the manifest { ... } function is part of the Java Convention the usage of which is deprecated.
But the Java Extension also has that function, so just do java.manifest { ... } and it should probably work.

But I’ll instead recommend you use a convention plugin in buildSrc or an included build for example implemented as precompiled script plugin.

1 Like

The java.manifest {} works.

We do have a convention plugin and I’ll have a look to see if I can fit it in there in stead.
Tanks.

1 Like