Skip to content

Commit e601de0

Browse files
authored
Merge pull request #4099 from NativeScript/trifonov/before-include-gradle
Apply before-plugins.gradle file in the plugin build.gradle
2 parents ad5d357 + 560a5d1 commit e601de0

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
lines changed

lib/services/android-plugin-build-service.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ export class AndroidPluginBuildService implements IAndroidPluginBuildService {
429429
];
430430

431431
try {
432-
await this.$childProcess.spawnFromEvent(gradlew, localArgs, "close", { cwd: pluginBuildSettings.pluginDir });
432+
await this.$childProcess.spawnFromEvent(gradlew, localArgs, "close", { cwd: pluginBuildSettings.pluginDir, stdio: "inherit" });
433433
} catch (err) {
434434
this.$errors.failWithoutHelp(`Failed to build plugin ${pluginBuildSettings.pluginName} : \n${err}`);
435435
}

vendor/gradle-plugin/build.gradle

+42
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import groovy.json.JsonSlurper
12

23
buildscript {
34
repositories {
@@ -32,6 +33,8 @@ def computeBuildToolsVersion = { ->
3233
}
3334

3435
android {
36+
applyBeforePluginGradleConfiguration()
37+
3538
compileSdkVersion computeCompileSdkVersion()
3639
buildToolsVersion computeBuildToolsVersion()
3740

@@ -50,3 +53,42 @@ dependencies {
5053
compileOnly "com.android.support:support-v4:$supportVer"
5154
compileOnly "com.android.support:appcompat-v7:$supportVer"
5255
}
56+
57+
def getAppResourcesPath() {
58+
def relativePathToApp = "app"
59+
def relativePathToAppResources
60+
def absolutePathToAppResources
61+
def projectRoot = "$rootDir/../../.."
62+
def nsConfigFile = file("$projectRoot/nsconfig.json")
63+
def nsConfig
64+
65+
if (nsConfigFile.exists()) {
66+
nsConfig = new JsonSlurper().parseText(nsConfigFile.getText("UTF-8"))
67+
}
68+
69+
if(nsConfig != null && nsConfig.appPath != null){
70+
relativePathToApp = nsConfig.appPath
71+
}
72+
73+
if(nsConfig != null && nsConfig.appResourcesPath != null ) {
74+
relativePathToAppResources = nsConfig.appResourcesPath
75+
} else {
76+
relativePathToAppResources = "$relativePathToApp/App_Resources"
77+
}
78+
79+
absolutePathToAppResources = java.nio.file.Paths.get(projectRoot).resolve(relativePathToAppResources).toAbsolutePath()
80+
81+
project.ext.appResourcesPath = absolutePathToAppResources
82+
83+
return absolutePathToAppResources
84+
}
85+
86+
def applyBeforePluginGradleConfiguration() {
87+
def appResourcesPath = getAppResourcesPath()
88+
def pathToBeforePluginGradle = "$appResourcesPath/Android/before-plugins.gradle"
89+
def beforePluginGradle = file(pathToBeforePluginGradle)
90+
if (beforePluginGradle.exists()) {
91+
println "\t + applying user-defined configuration from ${beforePluginGradle}"
92+
apply from: pathToBeforePluginGradle
93+
}
94+
}

0 commit comments

Comments
 (0)