想要在build.gradle中同时指定jar名称和版本 [英] Want to specify jar name and version both in build.gradle

查看:1157
本文介绍了想要在build.gradle中同时指定jar名称和版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在build.gradle中指定jar名称和版本,所以我的build.gradle如下所示.

I want to specify the jar name and version in build.gradle, so my build.gradle looks like below.

apply plugin: 'java'

version = "1.00.00"

 dependencies { 
     compile files('../../lib/abc.jar') 
} 

jar{
    manifest{
        attributes ("Fw-Version" : "2.50.00", "${parent.manifestSectionName}")

    }
    archiveName 'abc.jar'
}

所以当我这样做

渐变干净版本,我期望的是生成的jar名称为abc-1.00.00.jar

gradle clean build, what I was expecting was that the generated jar name would be abc-1.00.00.jar

但是它没有发生,输出jar名称仅以abc.jar的形式出现,而只是忽略了版本.我想同时指定jar名称和版本,那么如何实现呢?

But its not happening, the output jar name is getting as abc.jar only and its just ignoring the version. I want to specify both jar name and version, so how can I achieve that?

推荐答案

archiveName 'abc.jar'强制名称为'abc.jar'. jar名称的默认格式为${baseName}-${appendix}-${version}-${classifier}.${extension},其中baseName是项目的名称,而version是项目的版本.如果您在配置中删除archiveName行,则将具有您想要的格式.如果您希望归档文件的名称与项目名称不同,请设置baseName,例如

archiveName 'abc.jar' in your jar configuration is forcing the name to be 'abc.jar'. The default format for the jar name is ${baseName}-${appendix}-${version}-${classifier}.${extension}, where baseName is the name of your project and version is the version of the project. If you remove the archiveName line in your configuration you'll have the format you're after. If you want the name of the archive to be different from the project name set the baseName instead, e.g.

jar {
    manifest{
        attributes ("Fw-Version" : "2.50.00", "${parent.manifestSectionName}")
    }
    baseName 'abc'
}

请参见

See https://docs.gradle.org/current/dsl/org.gradle.api.tasks.bundling.Jar.html#org.gradle.api.tasks.bundling.Jar:archiveName for more info on configuring the jar task.

这篇关于想要在build.gradle中同时指定jar名称和版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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