Skip to content

第九章getAppVersionName()方法是不是要移除掉最后的换行符号? #7

@jhwsx

Description

@jhwsx
/**
 * 从 git tag 中获取应用的版本名称
 *
 * @return git tag 的名称
 */
def getAppVersionName() {
    def stdout = new ByteArrayOutputStream()
    // exec 是 Project 类中的一个方法
    exec {
        commandLine 'git','describe','--abbrev=0','--tags'
        setStandardOutput(stdout)
    }
    return stdout.toString().replace("\n", "") // 移除最后的换行符
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions