Gradle 팁 – APK를 생성할 때 파일명에 원하는 정보 추가하기

Gradle 팁 – APK를 생성할 때 파일명에 원하는 정보 추가하기

모듈 build.gradle의 android 블록 아래에 다음 내용을 기입하면 APK를 생성할 때 파일명에 원하는 정보를 추가할 수 있습니다.

    buildTypes {
        applicationVariants.all { variant ->
            variant.outputs.each { output ->
                output.outputFile = new File(output.outputFile.parent,
                        output.outputFile.name.replace(".apk",
                                " -${variant.versionName}.apk"))
            }
        }
    }

applicationVariants 객체는 각 빌드 변형의 내부 속정을 참조할 수 있는데, 이는 안드로이드 앱 모듈 전용으로 만약 안드로이드 라이브러리 모듈에서 활용하려면 library Variants로 대체합니다. output. outputFile은 assemble 태 스크 결과로 생성되는 APK/AAR 파일을 의미합니다.

답글 남기기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다