当前位置: 首页 > 软件库 > 手机/移动开发 > >

gradle-advanced-build-version

授权协议 Apache-2.0 License
开发语言 Java
所属分类 手机/移动开发
软件类型 开源软件
地区 不详
投 递 者 杜鸿彩
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

Gradle Advanced Build Version Plugin

A plugin to generate the Android version code and version name automatically based on git commits number, date and Semantic Versioning.

GitHub Workflow Status

Contents

  1. Installation
  2. How to use
  3. Version Name Configuration
  4. Version Code Configuration
  5. File output options

Installation

Add the advanced-build-version plugin to your build script and use the property advancedVersioning.versionName andadvancedVersioning.versionCode where you need:

buildscript {
  repositories {
    jcenter()
  }

  dependencies {
    classpath 'me.moallemi.gradle:advanced-build-version:1.7.3'
  }
}

apply plugin: 'me.moallemi.advanced-build-version'

How to use

advancedVersioning {
  nameOptions { }
  codeOptions { }
  outputOptions { }
}

def appVersionName = advancedVersioning.versionName
def appVersionCode = advancedVersioning.versionCode

Version Name Configuration

You can customize version name in your build.gradle file as follows:

advancedVersioning {
  nameOptions {
    versionMajor 1
    versionMinor 3
    versionPatch 6
    versionBuild 8
  }
}

the above configuration will output 1.3.6.8

there is no need to specify all params because they will be handled automatically. for example:

advancedVersioning {
  nameOptions {
    versionMajor 1
    versionBuild 8
  }
}

will output 1.0.0.8 and

advancedVersioning {
  nameOptions {
    versionMajor 1
    versionMinor 3
  }
}

will output 1.3

Version Code Configuration

To customize version code in your build.gradle file write:

Groovy:

advancedVersioning {
  codeOptions {
    versionCodeType 'GIT_COMMIT_COUNT'
  }
}

Kotlin:

import me.moallemi.gradle.advancedbuildversion.gradleextensions.VersionCodeType.*

advancedVersioning {
  codeOptions {
    versionCodeType(GIT_COMMIT_COUNT)
  }
}

versionCodeType can be one of following params:

  • GIT_COMMIT_COUNT will output total commits number in current branch
  • DATE formatted number e.g.: 1501101614
  • AUTO_INCREMENT_DATE will output 101101614
  • AUTO_INCREMENT_ONE_STEP will output e.g: 24
  • AUTO_INCREMENT_STEP will output e.g: 26

AUTO_INCREMENT_ONE_STEP and AUTO_INCREMENT_STEP store AI_VERSION_CODE in version.properties file in build.gradledirectory, you may also change dependsOnTasks property to specify that on witch tasks should increase version code(default is every task that contains 'release' in its name)

advancedVersioning {
  codeOptions {
    versionCodeType 'AUTO_INCREMENT_ONE_STEP'
    dependsOnTasks 'release' // defaultValue
  }
}

Setting multiple tasks for dependsOnTasks property:

advancedVersioning {
  codeOptions {
    versionCodeType 'AUTO_INCREMENT_ONE_STEP'
    dependsOnTasks 'debug', 'release', 'assemble'
  }
}

AUTO_INCREMENT_STEP allows you to set a step different from 1:

advancedVersioning {
  codeOptions {
    versionCodeType 'AUTO_INCREMENT_STEP'
    versionCodeStep 2
  }
}

File output options

You can also rename the output generated apk file with this plugin. it can be done just by enablingthe renameOutput option:

advancedVersioning {
  outputOptions {
    renameOutput true
  }
}

If your app name is MyApp with 2.7 version name, and you are in debug mode, the output apk file namewill be: MyApp-2.7-debug.apk

NOTE: Android Gradle Plugin 4.1.0 drops support for renaming apk. We are using a workaround to keep renaming option for gradle-advanced-build-version library.So if you are using AGP 4.1.0+, you have to add advancedVersioning.renameOutputApk() after android configuration. The order is important:

advancedVersioning {
  outputOptions {
    renameOutput true
  }
}
android {
  ...
}
advancedVersioning.renameOutputApk()

You can customize the output name by using this params:

  • ${appName}: name of main module
  • ${projectName}: name of root project
  • ${flavorName}: flavor name
  • ${buildType}: build type
  • ${versionName}: version name
  • ${versionCode}: version code

Groovy:

advancedVersioning {
  outputOptions {
    renameOutput true
    nameFormat '${appName}-${buildType}-${versionName}'
  }
}

Kotlin:

advancedVersioning {
  outputOptions {
    renameOutput(true)
    nameFormat("\${appName}-\${buildType}-\${versionName}-\${versionCode}")
  }
}

And you can also use custom string in nameFormat like:

Groovy:

advancedVersioning {
  outputOptions {
    renameOutput true
    nameFormat '${appName}-google-play-${versionName}'
  }
}

Kotlin:

advancedVersioning {
  outputOptions {
    renameOutput(true)
    nameFormat("\${appName}-google-play-\${versionName}")
  }
}

If your app name is MyApp with 4.6.1 version name the output apk file name will be:MyApp-google-play-4.6.1.apk

License

Copyright 2020 Reza Moallemi.

Licensed to the Apache Software Foundation (ASF) under one or more contributor
license agreements. See the NOTICE file distributed with this work for
additional information regarding copyright ownership. The ASF licenses this
file to you under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance with the License. You may obtain a copy of
the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
License for the specific language governing permissions and limitations under
the License.
  • 1. 在build.gradle 中  buildConfigField  的参数有3个 第一个类型 第二个为名称 第三个是值 如果是字符串类型 请不要忘记 双引号! buildTypes { release { buildConfigField 'String','CUSTOMIZED_VERSION','"common"' }

  • 目录 内部原理 从命令行调用 选项 可调试 build 与发布 build 要求 JSON 编译数据库 Android.mk 概览 基础知识 变量和宏 NDK 定义的 include 变量 CLEAR_VARS BUILD_EXECUTABLE BUILD_SHARED_LIBRARY BUILD_STATIC_LIBRARY PREBUILT_SHARED_LIBRARY PREBUILT_ST

  • Gradle介绍 Gradle is an advanced build system as well as an advanced build toolkit allowing to create custom build logic through plugins. Gradle是一个先进的构建系统,也是一个允许通过插件创建自定义构建逻辑先进的构建工具。 Gradle 允许通过插件创建自定义的

  • 昨天还运行的好好地,今天上班打卡as提示:“INFO - e.project.sync.GradleSyncState - Gradle sync failed: Illegal char <:> at index 8: D:/pos/D:.pos.iml (4 s 246 ms)” 具体如下: INFO - e.project.sync.GradleSyncState - Gradle sync

  • 先附上错误信息: 2021-09-17 10:32:44,355 [1924382] INFO - System.util.ExternalSystemUtil - External project [E:/space-persional/git/oldmoon-frame] resolution task started 2021-09-17 10:32:44,438 [1924465]

  • Gradle 下载与安装 前言 博客书 版本说明 gradle=6.0 windows=10 linux.centos=7 相关链接 Gradle 官网:https://gradle.org/ Gradle 官网安装参考:https://gradle.org/install/ Gradle 官网下载地址: https://gradle.org/releases/ SDK 官网: https://

  • 一、现在的Kotlin项目,主要是基于Gradle构建的,那么首先得先了解一下Gradle。 Gradle官网:Gradle官网 官网介绍说: 1.建造任何东西 用Java,C ++,Python或您选择的语言编写。打包在任何平台上部署。去monorepo或多回购。并依靠Gradle无与伦比的多功能性来构建这一切。 2.自动化一切 使用Gradle丰富的API和成熟的插件和集成生态系统来实现雄心勃

  • Installation The current Gradle release is 4.10.2. You can download binaries and view docs for all Gradle versions from the releases page. Prerequisites Additional resources Install Install with a pac

  • 转载注明出处:http://blog.csdn.net/xiaohanluo/article/details/72644979 0. 前言 完全由个人翻译,能力有限,有些细节地方翻译不是很通顺,大家可以参考Gradle Plugin User Guide英文版本阅读,如果有问题,欢迎指正。 译文git工程:https://github.com/Kyogirante/gradle_user_guid

 相关资料
  • 我正在尝试将https://code.google.com/p/android-serialport-api/导入Android Studio。由于此项目涉及ndk,因此我按照说明从以下链接构建NDK:http://tools.android.com/tech-docs/new-build-system/gradle-experimental 但是在构建后,我收到此错误:Gradle项目刷新失败错

  • 我执行以下命令 分级清理生成--调试--扫描--信息--堆栈跟踪

  • 尝试使用unity 2019.4.26f1为android 30构建,请点击以下链接:https://developers.google.com/ar/develop/unity/android-11-build 错误:CommandInvokationFailure:渐变生成失败。C:\Program Files\Java\jdk1。8.0_191\bin\java。exe-classpath“

  • Gradle Enterprise build configuration samples This repository contains code samples that demonstrate how to customize your Gradle Enterprise build configuration using Gradle or Maven. The samples aim

  • 嗨,在添加apache poi gradle构建之后,我得到了这个期望。你能给我解释一下怎么解决吗。 我尝试过以多种方式排除套餐选项,但都没有成功 错误:任务': app: transformResourcesSusMergeJavaResForDebug'执行失败。 com.android.build.api.transform.TransformException:com.android.bu