@@ -15,18 +15,18 @@ def jsParserP = "$projectDir/parser/js_parser.js"
15
15
def jsFilesParametersP = " $projectDir /jsFilesParameters.txt"
16
16
17
17
def webpackWorkersExcludePath = " $projectDir /../../src/main/assets/app/__worker-chunks.json"
18
- def webpackWorkersExcludesList;
18
+ def webpackWorkersExcludesList = [] ;
19
19
20
20
def workersExcludeFile = file(webpackWorkersExcludePath);
21
- def filterWorkerFiles = false ;
22
21
if (workersExcludeFile. exists()) {
23
- filterWorkerFiles = true ;
24
- webpackWorkersExcludesList = new JsonSlurper (). parseText(workersExcludeFile. text)
22
+ // in case the file exists but is malformed
23
+ try {
24
+ webpackWorkersExcludesList = new JsonSlurper (). parseText(workersExcludeFile. text)
25
+ } catch (all) {
26
+ println " Malformed workers exclude file at ${ webpackWorkersExcludePath} "
27
+ }
25
28
}
26
29
27
-
28
- // def absoluteOutDir = new File("./outDir")//project.outDir
29
-
30
30
def absoluteOutDir;
31
31
if (project. hasProperty(" outDir" )) {
32
32
absoluteOutDir = project. outDir;
@@ -123,15 +123,7 @@ traverseDirectory = { dir, traverseExplicitly ->
123
123
124
124
currentDir. eachFile(FileType . FILES ) { File f ->
125
125
def currFile = f. getAbsolutePath();
126
- if (currFile. substring(currFile. length() - 3 , currFile. length()). equals(" .js" )) {
127
- // Read __worker-chunks.json file containing a list of webpacked workers
128
- // ignore worker scripts, so as to not attempt to generate bindings for them
129
- if (filterWorkerFiles) {
130
- if (webpackWorkersExcludesList. any{element -> file(element). getAbsolutePath() == currFile}) {
131
- return
132
- }
133
- }
134
-
126
+ if (isJsFile(currFile) && ! isWorkerScript(currFile)) {
135
127
inputJsFiles. add(currFile)
136
128
}
137
129
}
@@ -141,6 +133,15 @@ traverseDirectory = { dir, traverseExplicitly ->
141
133
}
142
134
}
143
135
136
+ def isJsFile = { fileName -> return fileName. substring(fileName. length() - 3 , fileName. length()). equals(" .js" )
137
+ }
138
+
139
+ def isWorkerScript = { fileName ->
140
+ // Read __worker-chunks.json file containing a list of webpacked workers
141
+ // ignore worker scripts, so as to not attempt to generate bindings for them
142
+ return webpackWorkersExcludesList. any{element -> file(element). getAbsolutePath() == fileName}
143
+ }
144
+
144
145
task traverseJsFilesArgs << { // (jsCodeDir, bindingsFilePath, interfaceNamesFilePath, jsParserPath, jsFilesParameter) {
145
146
jsCodeAbsolutePath = jsCodeDir;
146
147
inputJsFiles = new LinkedList<String > ();
0 commit comments