문제

I have a gradle project that builds a war file, and includes a manifest:

war {
    archiveName 'archive.war'
    manifest {
        attributes("Implementation-Title": project.name, "Implementation-Version": version, "Implementation-Timestamp": new Date())
    }
}

This is fine, but if I run a release build (using the gradle-release plugin https://github.com/townsfolk/gradle-release), which updates the project version, then the war file is created with the old version number rather than the new one.

I may be wrong, but I suspect this is happening because the manifest code is running during the Configuration phase rather than the Execution phase. What is the best way to fix this?

도움이 되었습니까?

해결책

Wrapping the manifest section in "doFirst" fixed it. Using "doLast" resulted in an empty manifest file being created.

Working code:

war {
    doFirst {
        manifest {
            attributes("Implementation-Title": project.name, "Implementation-Version": version, "Implementation-Timestamp": new Date())
        }
    }
    archiveName 'infoserverws.war'
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top