How to set project.version by passing version property on gradle command line?

前端 未结 6 891
被撕碎了的回忆
被撕碎了的回忆 2020-12-13 03:55

I want to build JAR with self-defined version passed via command line, such as:

When I execute gradle build task like this:

gradle build -Pversion=1.         


        
6条回答
  •  情书的邮戳
    2020-12-13 04:58

    You can pass the project version on cli with -Pversion=... as long as you don't set it in build.gradle. If you need a custom default value for when no version is passed on the cli, use gradle.properties file like so: version=...

    TL;DR: Don't set the version in build.gradle file if you want to change it later on via cli.

提交回复
热议问题