Skip to content
Closed
19 changes: 19 additions & 0 deletions react.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ void runBefore(String dependentTaskName, Task task) {
}

afterEvaluate {
def isAndroidLibrary = plugins.hasPlugin("com.android.library")
// Grab all build types and product flavors
def buildTypes = android.buildTypes.collect { type -> type.name }
def productFlavors = android.productFlavors.collect { flavor -> flavor.name }
Expand Down Expand Up @@ -101,6 +102,24 @@ afterEvaluate {
enabled config."bundleIn${targetName}" ||
config."bundleIn${buildTypeName.capitalize()}" ?:
targetName.toLowerCase().contains("release")

if (isAndroidLibrary) {
doLast {
def moveFunc = { resSuffix ->
File originalDir = file("${resourcesDir}/drawable-${resSuffix}")
if (originalDir.exists()) {
File destDir = file("${resourcesDir}/drawable-${resSuffix}-v4")
ant.move(file: originalDir, tofile: destDir)
}
}
moveFunc.curry("ldpi").call()
moveFunc.curry("mdpi").call()
moveFunc.curry("hdpi").call()
moveFunc.curry("xhdpi").call()
moveFunc.curry("xxhdpi").call()
moveFunc.curry("xxxhdpi").call()
}
}
}

// Hook bundle${productFlavor}${buildType}JsAndAssets into the android build process
Expand Down