Skip to content

Commit 2db2fdf

Browse files
committed
refactor asbg gradle project variable names
remove redundant runtime gradle project script throw exception if build script is used with a CLI that doesn't produce 'dependencies.json'
1 parent efb85b7 commit 2db2fdf

File tree

3 files changed

+132
-126
lines changed

3 files changed

+132
-126
lines changed

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

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44

55
import groovy.json.JsonSlurper
66
import groovy.io.FileType
7+
import java.nio.charset.StandardCharsets
8+
import java.nio.file.Files
9+
import java.nio.file.Paths
710

8-
def isWinOs = System.properties['os.name'].toLowerCase().contains('windows')
9-
10-
def astParserDir = "$projectDir/parser"
1111
def interfaceNamesFileP = "$projectDir/interfaces-names.txt"
1212
def bindingsFileP = "$projectDir/bindings.txt"
1313
def cachedJarsFilePath = "$projectDir/cached.txt"
@@ -30,13 +30,12 @@ if (workersExcludeFile.exists()) {
3030
def absoluteOutDir;
3131
if (project.hasProperty("outDir")) {
3232
absoluteOutDir = project.outDir;
33-
33+
3434
if (!absoluteOutDir.exists()) {
3535
absoluteOutDir.mkdirs()
3636
}
3737
}
3838

39-
4039
// def absoluteJsCodeDir = new File("./jsCodeDir").getAbsolutePath()//project.jsCodeDir
4140
def absoluteJsCodeDir;
4241
def jsCodeAbsolutePath;
@@ -45,31 +44,30 @@ if (!project.hasProperty("test")) {
4544
jsCodeAbsolutePath = absoluteJsCodeDir.getAbsolutePath()
4645
}
4746

48-
def utf8 = java.nio.charset.StandardCharsets.UTF_8
49-
def current = ""
47+
def utf8 = StandardCharsets.UTF_8
48+
def jarsList = ""
5049

5150
def shouldRun = true
5251
def rootTraversed = false;
5352
def inputJsFiles = new LinkedList <String> ();
5453

5554
// depends on passed jars and generated interface-names
56-
task generateInterfaceNamesList() {
57-
55+
task generateInterfaceNamesList {
5856
doFirst {
5957
if(!project.hasProperty("test")) {
60-
current = project.jarFiles
58+
jarsList = project.jarFiles
6159
def cache = new File(cachedJarsFilePath)
62-
60+
6361
if (cache.exists()) {
6462
def contents = new String(java.nio.file.Files.readAllBytes(java.nio.file.Paths.get(cachedJarsFilePath)), utf8).trim()
65-
shouldRun = !contents.equals(current.toString())
63+
shouldRun = !contents.equals(jarsList.toString())
6664
}
6765

6866
if (shouldRun) {
6967
javaexec {
7068
main "-jar"
7169

72-
def jarsAsStr = current.toString();
70+
def jarsAsStr = jarsList.toString();
7371
def jarsArr = jarsAsStr.replaceAll(/[\[\]]/, "").split(", ")
7472

7573
def str = new LinkedList <String> ();
@@ -80,7 +78,7 @@ task generateInterfaceNamesList() {
8078

8179
args str.toArray()
8280
}
83-
java.nio.file.Files.write(java.nio.file.Paths.get(cachedJarsFilePath), [current.toString()], utf8)
81+
Files.write(Paths.get(cachedJarsFilePath), [jarsList.toString()], utf8)
8482
}
8583
}
8684
}
@@ -95,9 +93,7 @@ def isWorkerScript = { fileName ->
9593
}
9694

9795
def traverseDirectory
98-
9996
traverseDirectory = { dir, traverseExplicitly ->
100-
10197
def currentDir = new File(dir)
10298
def pJsonFile = false;
10399

@@ -141,14 +137,23 @@ traverseDirectory = { dir, traverseExplicitly ->
141137
}
142138
}
143139

144-
task traverseJsFilesArgs << { //(jsCodeDir, bindingsFilePath, interfaceNamesFilePath, jsParserPath, jsFilesParameter) {
145-
jsCodeAbsolutePath = jsCodeDir;
146-
inputJsFiles = new LinkedList<String>();
147-
traverseDirectory(jsCodeDir, false);
140+
task traverseJsFilesArgs { //(jsCodeDir, bindingsFilePath, interfaceNamesFilePath, jsParserPath, jsFilesParameter) {
141+
doLast {
142+
jsCodeAbsolutePath = jsCodeDir;
143+
inputJsFiles = new LinkedList<String>();
144+
traverseDirectory(jsCodeDir, false);
148145

149-
new File(jsFilesParameter).withWriter { out ->
150-
inputJsFiles.each {out.println it}
151-
}
146+
new File(jsFilesParameter).withWriter { out ->
147+
inputJsFiles.each {out.println it}
148+
}
149+
150+
def list = new ArrayList<String>();
151+
list.add("node")
152+
list.add(jsParserPath)
153+
list.add(jsCodeDir)
154+
list.add(bindingsFilePath)
155+
list.add(interfaceNamesFilePath)
156+
list.add(jsFilesParameter)
152157

153158
def list = new ArrayList<String>();
154159
list.add("node")
@@ -187,7 +192,7 @@ task runAstParser(type: RunAstParserTask) {
187192
// traverses the javascript code input directory
188193
// 1. traverses all root directory files
189194
// 2. all subdirectories that do not have a package.json containing a "nativescript" key are skipped
190-
task traverseJsFiles () {
195+
task traverseJsFiles {
191196
doFirst {
192197
// invalidate previously generated bindings.txt file
193198
// todo: remove when removing previously generated bindings is implemented
@@ -285,7 +290,7 @@ task generateBindings() {
285290
str.add(bindingsFileP)
286291
str.add(absoluteOutDir)
287292

288-
def jarsAsStr = current.toString();
293+
def jarsAsStr = jarsList.toString();
289294
def jarsArr = jarsAsStr.replaceAll(/[\[\]]/, "").split(", ")
290295
str.addAll(jarsArr)
291296

build-artifacts/project-template-gradle/build-tools/runtime-modules/runtime/build.gradle

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)