Skip to content

Commit 6155ff7

Browse files
authored
feat: include-settings.gradle plugin (#5693)
1 parent aa3de73 commit 6155ff7

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,8 @@ export class AndroidPluginBuildService implements IAndroidPluginBuildService {
408408
);
409409
const allGradleTemplateFiles = path.join(gradleTemplatePath, "*");
410410
const buildGradlePath = path.join(pluginTempDir, "build.gradle");
411-
411+
const settingsGradlePath = path.join(pluginTempDir, "settings.gradle");
412+
412413
this.$fs.copyFile(allGradleTemplateFiles, pluginTempDir);
413414
this.addCompileDependencies(platformsAndroidDirPath, buildGradlePath);
414415
const runtimeGradleVersions = await this.getRuntimeGradleVersions(
@@ -423,6 +424,7 @@ export class AndroidPluginBuildService implements IAndroidPluginBuildService {
423424
runtimeGradleVersions.gradleAndroidPluginVersion
424425
);
425426
this.replaceFileContent(buildGradlePath, "{{pluginName}}", pluginName);
427+
this.replaceFileContent(settingsGradlePath, "{{pluginName}}", pluginName);
426428
}
427429

428430
private async getRuntimeGradleVersions(

vendor/gradle-plugin/settings.gradle

+24
Original file line numberDiff line numberDiff line change
@@ -1 +1,25 @@
1+
import groovy.json.JsonSlurper
12

3+
def USER_PROJECT_ROOT = "$rootDir/../../../"
4+
def PLATFORMS_ANDROID = "platforms/android"
5+
def PLUGIN_NAME = "{{pluginName}}"
6+
7+
def dependenciesJson = file("${USER_PROJECT_ROOT}/${PLATFORMS_ANDROID}/dependencies.json")
8+
def appDependencies = new JsonSlurper().parseText(dependenciesJson.text)
9+
def pluginData = appDependencies.find { it.name == PLUGIN_NAME }
10+
def nativescriptDependencies = appDependencies.findAll{pluginData.name == it.name}
11+
12+
def getDepPlatformDir = { dep ->
13+
file("$USER_PROJECT_ROOT/$PLATFORMS_ANDROID/${dep.directory}/$PLATFORMS_ANDROID")
14+
}
15+
16+
def applyIncludeSettingsGradlePlugin = {
17+
nativescriptDependencies.each { dep ->
18+
def includeSettingsGradlePath = "${getDepPlatformDir(dep)}/include-settings.gradle"
19+
if (file(includeSettingsGradlePath).exists()) {
20+
apply from: includeSettingsGradlePath
21+
}
22+
}
23+
}
24+
25+
applyIncludeSettingsGradlePlugin()

0 commit comments

Comments
 (0)