Skip to content

Commit cc60a08

Browse files
committed
Build generators in separate builds
1 parent b08e65f commit cc60a08

3 files changed

Lines changed: 34 additions & 24 deletions

File tree

test-app/app/build.gradle

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,14 @@ version of the {N} CLI install a previous version of the runtime package - 'tns
9595
nsConfig = new JsonSlurper().parseText(nsConfigFile.getText("UTF-8"))
9696
}
9797

98-
if(nsConfig != null && nsConfig.appPath != null){
98+
if (nsConfig != null && nsConfig.appPath != null) {
9999
relativePathToApp = nsConfig.appPath
100100
}
101101

102-
if(nsConfig != null && nsConfig.appResourcesPath != null ) {
102+
if (nsConfig != null && nsConfig.appResourcesPath != null) {
103103
relativePathToAppResources = nsConfig.appResourcesPath
104104
} else {
105-
relativePathToAppResources = "$relativePathToApp/App_Resources"
105+
relativePathToAppResources = "$relativePathToApp/App_Resources"
106106
}
107107

108108
absolutePathToAppResources = java.nio.file.Paths.get(USER_PROJECT_ROOT).resolve(relativePathToAppResources).toAbsolutePath()
@@ -121,10 +121,10 @@ version of the {N} CLI install a previous version of the runtime package - 'tns
121121
apply from: pathToBuildScriptGradle, to: buildscript
122122
}
123123

124-
nativescriptDependencies.each {dep ->
124+
nativescriptDependencies.each { dep ->
125125
def pathToPluginBuildScriptGradle = "$rootDir/${dep.directory}/$PLATFORMS_ANDROID/buildscript.gradle"
126126
def pluginBuildScriptGradle = file(pathToPluginBuildScriptGradle)
127-
if(pluginBuildScriptGradle.exists()) {
127+
if (pluginBuildScriptGradle.exists()) {
128128
println "\t + applying user-defined buildscript from dependency ${pluginBuildScriptGradle}"
129129
apply from: pathToPluginBuildScriptGradle, to: buildscript
130130
}
@@ -161,9 +161,9 @@ def applyAppGradleConfiguration = { ->
161161
}
162162

163163
def applyPluginGradleConfigurations = { ->
164-
nativescriptDependencies.each {dep ->
164+
nativescriptDependencies.each { dep ->
165165
def includeGradlePath = "$rootDir/${dep.directory}/$PLATFORMS_ANDROID/include.gradle"
166-
if(file(includeGradlePath).exists()) {
166+
if (file(includeGradlePath).exists()) {
167167
apply from: includeGradlePath
168168
}
169169
}
@@ -290,7 +290,6 @@ dependencies {
290290
if (project.hasProperty("supportVersion")) {
291291
supportVer = supportVersion
292292
}
293-
294293
if (project.hasProperty("useAndroidX") && (useAndroidX || useAndroidX.toBoolean())) {
295294
def androidXLegacyVersion = "1.0.0"
296295
if (project.hasProperty("androidXLegacy")) {
@@ -321,20 +320,6 @@ dependencies {
321320
implementation "com.android.support:appcompat-v7:$supportVer"
322321
implementation "com.android.support:design:$supportVer"
323322
}
324-
325-
def sbgProjectExists = !findProject(':static-binding-generator').is(null)
326-
if (sbgProjectExists) {
327-
compileOnly project(':static-binding-generator')
328-
}
329-
def mdgProjectExists = !findProject(':android-metadata-generator').is(null)
330-
if (mdgProjectExists) {
331-
compileOnly project(':android-metadata-generator')
332-
}
333-
def dtsgProjectExists = !findProject(':dts-generator').is(null)
334-
if (dtsgProjectExists) {
335-
compileOnly project(':dts-generator')
336-
}
337-
338323
def useV8Symbols = nativescriptDependencies.any {
339324
def packageJsonPath = file("$rootDir/${it.directory}/$PACKAGE_JSON")
340325
def packageJson = new JsonSlurper().parseText(packageJsonPath.text)
@@ -356,6 +341,7 @@ dependencies {
356341
} else {
357342
implementation project(path: ':runtime', configuration: 'default')
358343
}
344+
359345
}
360346

361347
////////////////////////////////////////////////////////////////////////////////////
@@ -430,6 +416,10 @@ tasks.whenTaskAdded({ org.gradle.api.DefaultTask currentTask ->
430416
////////////////////////////////////////////////////////////////////////////////////
431417

432418
task runSbg(type: JavaExec) {
419+
if (!findProject(':static-binding-generator').is(null)) {
420+
dependsOn ':static-binding-generator:jar'
421+
}
422+
433423
inputs.dir(INPUT_JS_DIR)
434424

435425
workingDir "$BUILD_TOOLS_PATH"
@@ -485,7 +475,7 @@ task extractAllJars {
485475
def buildType = project.selectedBuildType == "release" ? "Release" : "Debug"
486476
def iter = []
487477
Pattern pattern = Pattern.compile("^(.+)${buildType}CompileClasspath\$")
488-
configurations.all{ config ->
478+
configurations.all { config ->
489479
Matcher matcher = pattern.matcher(config.name)
490480
if (matcher.find() || config.name == "${buildType.toLowerCase()}CompileClasspath") {
491481
config.resolve().each {
@@ -544,6 +534,10 @@ task collectAllJars {
544534
}
545535

546536
task buildMetadata(type: JavaExec) {
537+
if (!findProject(':android-metadata-generator').is(null)) {
538+
dependsOn ':android-metadata-generator:jar'
539+
}
540+
547541
description "builds metadata with provided jar dependencies"
548542

549543
inputs.files("$MDG_JAVA_DEPENDENCIES")
@@ -621,6 +615,10 @@ task makeAndroidXChanges {
621615
}
622616

623617
task generateTypescriptDefinitions(type: JavaExec) {
618+
if (!findProject(':dts-generator').is(null)) {
619+
dependsOn ':dts-generator:jar'
620+
}
621+
624622
def paramz = new ArrayList<String>()
625623
def includeDirs = ["com.android.support", "/platforms/" + android.compileSdkVersion]
626624

@@ -687,7 +685,7 @@ task validateAppIdMatch {
687685
def lineSeparator = System.getProperty("line.separator")
688686

689687
if (project.hasProperty("nsApplicationIdentifier") && !project.hasProperty("release")) {
690-
if(project.nsApplicationIdentifier != android.defaultConfig.applicationId) {
688+
if (project.nsApplicationIdentifier != android.defaultConfig.applicationId) {
691689
def errorMessage = "${lineSeparator}WARNING: The Application identifier is different from the one inside \"package.json\" file.$lineSeparator" +
692690
"NativeScript CLI might not work properly.$lineSeparator" +
693691
"Remove applicationId from app.gradle and update the \"nativescript.id\" in package.json.$lineSeparator" +

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ compileJava {
3535

3636
compileJava.outputs.dir("$rootDir/dist/classes")
3737

38+
repositories {
39+
google()
40+
mavenCentral()
41+
jcenter()
42+
}
43+
3844
dependencies {
3945
compile 'org.apache.bcel:bcel:6.2'
4046
compile files("./src/libs/dx.jar")

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ apply plugin: 'java-library'
33
sourceCompatibility = JavaVersion.VERSION_1_8
44
targetCompatibility = JavaVersion.VERSION_1_8
55

6+
repositories {
7+
google()
8+
mavenCentral()
9+
jcenter()
10+
}
11+
612
dependencies {
713
compile 'org.apache.bcel:bcel:6.0'
814
compile group: 'org.json', name: 'json', version: '20090211'

0 commit comments

Comments
 (0)