Android/Apk build

[android] api, aar파일명 변경(version정보 포함)

개미맨 2018. 3. 29. 11:22

aar파일명 변경 gradle plug-in 3.0- 이하버전


gradle plug-in 2.3.3 ,gradle 3.3에서 진행

android {
compileSdkVersion 27
buildToolsVersion '27.0.3'
defaultConfig {
minSdkVersion 19
targetSdkVersion 25
versionCode 7
versionName "1.0.8"
archivesBaseName = "dabom_video_module"
version = android.defaultConfig.versionName
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}

libraryVariants.all { variant ->
variant.outputs.each { output ->
def outputFile = output.outputFile
if (outputFile != null && outputFile.name.endsWith('.aar')) {
def fileName = "${archivesBaseName}-${version}-${variant.buildType.name}.aar"
output.outputFile = new File(outputFile.parent, fileName)
}
}
}
}


aar파일명 변경 gradle plug-in 3.0+ 이상버전


gradle plug-in 3.1.0 ,gradle 4.4에서 진행

android {
compileSdkVersion 27
buildToolsVersion '27.0.3'
defaultConfig {
minSdkVersion 19
targetSdkVersion 25
versionCode 7
versionName "1.0.8"
archivesBaseName = "dabom_video_module"
version = android.defaultConfig.versionName
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}

libraryVariants.all { variant ->
variant.outputs.all { output ->
if (outputFile != null && outputFileName.endsWith('.aar')) {
outputFileName = "${archivesBaseName}-${version}-${variant.buildType.name}.aar"
}
}
}
}


apk 파일명 변경

android {
compileSdkVersion 27
buildToolsVersion '27.0.3'
defaultConfig {
applicationId "xxx.xxx.xxx"
minSdkVersion 21
targetSdkVersion 25
versionCode 50
versionName "3.2.20"
setProperty("archivesBaseName", "dabom_tvlet_v${versionName}")
}
}

결과

aar  파일명: dabom_video_module-1.0.8-debug.aar

apk 파일명: dabom_tvlet_v3.2.20-debug.apk