Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix mkcodecache issue #110

Merged
merged 1 commit into from
May 23, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 20 additions & 15 deletions android/mkcodecache.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,12 @@ import java.nio.file.Paths
import org.apache.tools.ant.taskdefs.condition.Os


def appProject = rootProject.allprojects.find { it.plugins.hasPlugin('com.android.application') }
def appProjectName = findProperty('v8.appProject')
def appProject = appProjectName ? project(":${appProjectName}") : rootProject.allprojects.find { it.plugins.hasPlugin('com.android.application') }
if (!appProject) {
return;
}

def appConfig = appProject.hasProperty("react") ? appProject.react : [:];
def bundleAssetName = appConfig.bundleAssetName ?: "index.android.bundle"

// Set bundleForVariant to a function to configure per variant,
// defaults to `bundleIn${targetName}` or True for Release variants and False for debug variants
def bundleForVariant = appConfig.bundleForVariant ?: {
def variant ->
appConfig."bundleIn${variant.name.capitalize()}" ||
appConfig."bundleIn${variant.buildType.name.capitalize()}" ||
variant.name.toLowerCase().contains("release")
}

File findNodePackageDir(String packageName, boolean absolute = true) {
def nodeCommand = ["node", "--print", "require.resolve('${packageName}/package.json')"]
def proc = nodeCommand.execute(null, rootDir)
Expand Down Expand Up @@ -64,6 +53,18 @@ def getV8ToolsDir() {
}

def setupClosure = {
def appConfig = appProject.hasProperty("react") ? appProject.react : [:];
def bundleAssetName = appConfig.bundleAssetName ?: "index.android.bundle"

// Set bundleForVariant to a function to configure per variant,
// defaults to `bundleIn${targetName}` or True for Release variants and False for debug variants
def bundleForVariant = appConfig.bundleForVariant ?: {
def variant ->
appConfig."bundleIn${variant.name.capitalize()}" ||
appConfig."bundleIn${variant.buildType.name.capitalize()}" ||
variant.name.toLowerCase().contains("release")
}

def variants = appProject.android.applicationVariants
variants.all { def variant ->
def targetName = variant.name.capitalize()
Expand Down Expand Up @@ -96,8 +97,12 @@ def setupClosure = {
}
}

dependsOn(variant.ext.bundleJsAndAssets)
enabled bundleForVariant(variant)
if (variant.ext.has('bundleJsAndAssets')) {
dependsOn(variant.ext.bundleJsAndAssets)
enabled bundleForVariant(variant)
} else {
enabled false
}
}

def currentWipeBundleTask = tasks.create(name: "wipe${targetName}BundledJs") {
Expand Down