Skip to content

Commit bf37ad2

Browse files
committed
fixed static binding generator caching
1 parent cf3703c commit bf37ad2

File tree

1 file changed

+40
-32
lines changed
  • build/project-template-gradle/build-tools/android-static-binding-generator

1 file changed

+40
-32
lines changed

build/project-template-gradle/build-tools/android-static-binding-generator/build.gradle

Lines changed: 40 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -39,65 +39,73 @@ task generateInterfaceNamesList() {
3939

4040
args str.toArray()
4141
}
42+
java.nio.file.Files.write(java.nio.file.Paths.get(cachedJarsFilePath), [current.toString()], utf8)
4243
}
4344
}
4445
}
4546

4647
// won't run if node_modules are installed
4748
task runNpmInstallForAstParser () {
49+
50+
//check this way so it doesn't slow down the build by snapshot-ing the node_modules
51+
outputs.upToDateWhen {
52+
(new File("$astParserDir/node_modules")).exists()
53+
}
54+
4855
doFirst {
49-
if (shouldRun) {
50-
exec {
51-
workingDir astParserDir
52-
53-
if(isWinOs) {
54-
commandLine "cmd", "/c", "npm", "install"
55-
}
56-
else {
57-
commandLine "npm", "install"
58-
}
56+
exec {
57+
workingDir astParserDir
58+
59+
if(isWinOs) {
60+
commandLine "cmd", "/c", "npm", "install"
61+
}
62+
else {
63+
commandLine "npm", "install"
5964
}
6065
}
6166
}
6267
}
6368

6469
// if there are new dependencies the parser will run again
6570
task runAstParser () {
71+
inputs.files fileTree(dir: absoluteJsCodeDir)
72+
outputs.files(bindingsFilePath)
73+
6674
doFirst {
67-
if (shouldRun) {
68-
exec {
69-
workingDir astParserDir
70-
71-
if(isWinOs) {
72-
commandLine "cmd", "/c", "node", "js_parser.js" , absoluteJsCodeDir, "../bindings.txt"
73-
}
74-
else {
75-
commandLine "node", "js_parser.js", absoluteJsCodeDir, "../bindings.txt"
76-
}
75+
exec {
76+
workingDir astParserDir
77+
78+
if(isWinOs) {
79+
commandLine "cmd", "/c", "node", "js_parser.js" , absoluteJsCodeDir, "../bindings.txt"
80+
}
81+
else {
82+
commandLine "node", "js_parser.js", absoluteJsCodeDir, "../bindings.txt"
7783
}
7884
}
7985
}
8086
}
8187
// run the static binding generator
8288
task generateBindings() {
89+
90+
inputs.files(bindingsFilePath)
91+
outputs.dir(absoluteOutDir)
92+
8393
doFirst {
84-
if (shouldRun) {
85-
javaexec {
86-
main "-jar"
94+
javaexec {
95+
main "-jar"
8796

88-
def str = new LinkedList <String> ();
89-
str.add("staticbindinggenerator.jar")
90-
str.add(bindingsFilePath)
91-
str.add(absoluteOutDir)
92-
str.addAll(project.jarFiles)
97+
def str = new LinkedList <String> ();
98+
str.add("staticbindinggenerator.jar")
99+
str.add(bindingsFilePath)
100+
str.add(absoluteOutDir)
101+
str.addAll(project.jarFiles)
93102

94-
args str.toArray()
95-
}
96-
java.nio.file.Files.write(java.nio.file.Paths.get(cachedJarsFilePath), [current.toString()], utf8)
103+
args str.toArray()
97104
}
98105
}
99106
}
100107

101108
runNpmInstallForAstParser.dependsOn(generateInterfaceNamesList)
102109
runAstParser.dependsOn(runNpmInstallForAstParser)
103-
generateBindings.dependsOn(runAstParser)
110+
generateBindings.dependsOn(runAstParser)
111+

0 commit comments

Comments
 (0)