发布构建时,Gradle war清单版本号错误 [英] Gradle war manifest version number wrong for release build

查看:113
本文介绍了发布构建时,Gradle war清单版本号错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  war {
archiveName

我有一个构建war文件的gradle项目,并包含一个清单: 'archive.war'
manifest {
attributes(Implementation-Title:project.name,Implementation-Version:version,Implementation-Timestamp:new Date())
}
}

这很好,但是如果我运行一个发布版本(使用gradle - 发布插件 https://github.com/townsfolk/gradle-release ),它会更新项目版本,然后战争文件创建与旧的版本号,而不是新的。



我可能是错的,但我怀疑这是因为清单代码在配置阶段运行,而不是在执行阶段。解决这个问题的最好方法是什么?

解决方案

解决方案

包装doFirst中的清单部分修复了它。使用doLast导致创建一个空的清单文件。



工作代码:

  war {
doFirst {
manifest {
attributes(Implementation-Title:project.name,Implementation-Version:version,Implementation-Timestamp:new日期())
}
}
archiveName'infoserverws.war'
}


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'
}

这篇关于发布构建时,Gradle war清单版本号错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆