Dynamic version in manifest

Hi,

I am trying include version in manifest of war plugin, but its writing as ‘unspecified’ in manifest file .

Below is my code
war{
manifest{
attributes(“build version”:version)
}
}
when i print it also, its displaying as ‘unspecified’ in the console.

But when i use println in doLast, its work fine and i able to see the version in the console as below:
doLast{
println version
}

I tried by including manifest in doLast, but its not working. Below is my code

war{
manifest{
doLast{
attributes(“build version”:version)
}
}
}

can anyone help on this, Thanks in advance

This works fine for me:

apply plugin: 'war'

version = '1.0'

war {
    manifest {
        attributes "build-version": version
    }
}

Keep in mind that build version is not a valid manifest key. It has to be a String without spaces.

Hi bmuschko,

I tried, but i got below error:
The value of a manifest attribute must not be null (Key=build-version).

I have a separate plugin for generating version, i want that version from the plugin to my subproject.

How to get that version to my subproject manifest file.?

Hi bmuschko,

I got the answer for getting version dynamically,i have included inside doFirst, below is my code

doFirst{
war.manifest{
attributes “build-version”:version
}
}