Skip to content

Commit 40b6725

Browse files
authored
chore: Don't copy generator .jar files to build-tools/ (#1789)
Gradle complains that when multiple tasks have the same output path, it cannot decide accurately whether they need to run or not. The copyJarToBuildTools task of all three generators (android-dts-generator, android-metadata-generator, and static-binding-generator) shared the same output path, so they were always getting run. Instead, we can leave the .jar files in the location where they are built, and reference them from there in tasks that subsequently require them. This fix was submitted separately to android-dts-generator, which is a git submodule, in NativeScript/android-dts-generator#77 This commit pulls in a newer version of android-dts-generator which includes that fix.
1 parent 633c193 commit 40b6725

File tree

7 files changed

+8
-41
lines changed

7 files changed

+8
-41
lines changed

build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -261,19 +261,19 @@ task copyFilesToProjectTemeplate {
261261
into "$DIST_FRAMEWORK_PATH/app/src/main/java/com/tns/internal"
262262
}
263263
copy {
264-
from "$BUILD_TOOLS_PATH/static-binding-generator.jar"
264+
from "$BUILD_TOOLS_PATH/static-binding-generator/build/libs/static-binding-generator.jar"
265265
into "$DIST_FRAMEWORK_PATH/build-tools"
266266
}
267267
copy {
268-
from "$BUILD_TOOLS_PATH/dts-generator.jar"
268+
from "$BUILD_TOOLS_PATH/android-dts-generator/build/libs/dts-generator.jar"
269269
into "$DIST_FRAMEWORK_PATH/build-tools"
270270
}
271271
copy {
272272
from "$BUILD_TOOLS_PATH/jsparser/build/js_parser.js"
273273
into "$DIST_FRAMEWORK_PATH/build-tools/jsparser"
274274
}
275275
copy {
276-
from "$BUILD_TOOLS_PATH/android-metadata-generator.jar"
276+
from "$BUILD_TOOLS_PATH/android-metadata-generator/build/libs/android-metadata-generator.jar"
277277
into "$DIST_FRAMEWORK_PATH/build-tools"
278278
}
279279
copy {

test-app/app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ task runSbg(type: BuildToolTask) {
504504
mainClass = "-jar"
505505

506506
def paramz = new ArrayList<String>()
507-
paramz.add("static-binding-generator.jar")
507+
paramz.add("static-binding-generator/build/libs/static-binding-generator.jar")
508508

509509
if (failOnCompilationWarningsEnabled()) {
510510
paramz.add("-show-deprecation-warnings")
@@ -841,7 +841,7 @@ task buildMetadata(type: BuildToolTask) {
841841
setOutputs outLogger
842842

843843
def paramz = new ArrayList<String>()
844-
paramz.add("android-metadata-generator.jar")
844+
paramz.add("android-metadata-generator/build/libs/android-metadata-generator.jar")
845845

846846
if(enableAnalytics){
847847
paramz.add("analyticsFilePath=$analyticsFilePath")

test-app/build-tools/.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
1-
static-binding-generator.jar
21
sbg-bindings.txt
32
sbg-interface-names.txt
43
sbg-js-parsed-files.txt
54
sbg-input-file.txt
65
sbg-output-file.txt
76
sbg-java-dependencies.txt
8-
android-metadata-generator.jar
97
mdg-output-dir.txt
108
mdg-java-dependencies.txt
11-
dts-generator.jar
129
sbg-input-output-dirs.txt
1310
mdg-java-out.txt

test-app/build-tools/android-metadata-generator/build.gradle

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,3 @@ jar {
9393

9494
duplicatesStrategy = 'include'
9595
}
96-
97-
task copyJarToBuildTools (type: Copy) {
98-
from "$projectDir/build/libs/android-metadata-generator.jar"
99-
into "$projectDir/../"
100-
}
101-
102-
jar.finalizedBy(copyJarToBuildTools)
103-
104-
105-

test-app/build-tools/static-binding-generator/build.gradle

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,9 @@ dependencies {
3333
}
3434

3535
compileJava {
36-
if (!findProject(':dts-generator').is(null)) {
37-
dependsOn ':dts-generator:copyJarToBuildTools'
38-
}
3936
options.compilerArgs << "-Xlint:all" << "-Xlint:-options" << "-Werror"
4037
}
4138

42-
task copyJarToBuildTools (type: Copy) {
43-
inputs.file("$projectDir/build/libs/static-binding-generator.jar")
44-
from "$projectDir/build/libs/static-binding-generator.jar"
45-
into "$projectDir/../"
46-
}
47-
4839
jar {
4940

5041
configurations.implementation.setCanBeResolved(true)
@@ -72,5 +63,3 @@ jar {
7263

7364
duplicatesStrategy = 'include'
7465
}
75-
76-
jar.finalizedBy(copyJarToBuildTools)

test-app/build-tools/static-binding-generator/runtests.gradle

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,7 @@ jar {
5858
duplicatesStrategy = 'include'
5959
}
6060

61-
task copyJar(dependsOn: 'jar') {
62-
doFirst {
63-
def source = file("$projectDir/build/libs/static-binding-generator.jar").toPath()
64-
print source.toFile().exists()
65-
def dest = file("$projectDir/../static-binding-generator.jar").toPath()
66-
Files.copy(source, dest, StandardCopyOption.REPLACE_EXISTING)
67-
}
68-
}
69-
70-
task prepareInputFiles(dependsOn: 'copyJar') {
61+
task prepareInputFiles {
7162
doFirst {
7263
inputFile.write(appRoot)
7364
outputFile.write(generatedJavaClassesRoot.toString())
@@ -77,7 +68,7 @@ task prepareInputFiles(dependsOn: 'copyJar') {
7768
}
7869

7970
task runSbg(type: JavaExec, dependsOn: 'prepareInputFiles') {
80-
classpath = files('../static-binding-generator.jar', '../')
71+
classpath = files('build/libs/static-binding-generator.jar', '../')
8172
workingDir = "../"
8273
main = "org.nativescript.staticbindinggenerator.Main"
8374
}

0 commit comments

Comments
 (0)