diff --git a/android-static-binding-generator/project/build.gradle b/android-static-binding-generator/project/build.gradle index 0f58311d7..c6b7947dc 100644 --- a/android-static-binding-generator/project/build.gradle +++ b/android-static-binding-generator/project/build.gradle @@ -14,9 +14,18 @@ def cachedJarsFilePath = "$projectDir/cached.txt" def jsParserP = "$projectDir/parser/js_parser.js" def jsFilesParametersP = "$projectDir/jsFilesParameters.txt" - - -//def absoluteOutDir = new File("./outDir")//project.outDir +def webpackWorkersExcludePath = "$projectDir/../../src/main/assets/app/__worker-chunks.json" +def webpackWorkersExcludesList = []; + +def workersExcludeFile = file(webpackWorkersExcludePath); +if (workersExcludeFile.exists()) { + // in case the file exists but is malformed + try { + webpackWorkersExcludesList = new JsonSlurper().parseText(workersExcludeFile.text) + } catch (all) { + println "Malformed workers exclude file at ${webpackWorkersExcludePath}" + } +} def absoluteOutDir; if (project.hasProperty("outDir")) { @@ -113,10 +122,9 @@ traverseDirectory = { dir, traverseExplicitly -> } currentDir.eachFile(FileType.FILES) { File f -> - def file = f.getAbsolutePath(); - if (file.substring(file.length() - 3, file.length()).equals(".js")) { - logger.info("Task: traverseDirectory: Visiting JavaScript file: " + f.getName()) - inputJsFiles.add(f.getAbsolutePath()) + def currFile = f.getAbsolutePath(); + if (isJsFile(currFile) && !isWorkerScript(currFile)) { + inputJsFiles.add(currFile) } } @@ -125,6 +133,15 @@ traverseDirectory = { dir, traverseExplicitly -> } } +def isJsFile = { fileName -> return fileName.substring(fileName.length() - 3, fileName.length()).equals(".js") +} + +def isWorkerScript = { fileName -> + // Read __worker-chunks.json file containing a list of webpacked workers + // ignore worker scripts, so as to not attempt to generate bindings for them + return webpackWorkersExcludesList.any{element -> file(element).getAbsolutePath() == fileName} +} + task traverseJsFilesArgs << { //(jsCodeDir, bindingsFilePath, interfaceNamesFilePath, jsParserPath, jsFilesParameter) { jsCodeAbsolutePath = jsCodeDir; inputJsFiles = new LinkedList();