Skip to content

feat: include-settings.gradle plugin #5693

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/services/android-plugin-build-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,8 @@ export class AndroidPluginBuildService implements IAndroidPluginBuildService {
);
const allGradleTemplateFiles = path.join(gradleTemplatePath, "*");
const buildGradlePath = path.join(pluginTempDir, "build.gradle");

const settingsGradlePath = path.join(pluginTempDir, "settings.gradle");

this.$fs.copyFile(allGradleTemplateFiles, pluginTempDir);
this.addCompileDependencies(platformsAndroidDirPath, buildGradlePath);
const runtimeGradleVersions = await this.getRuntimeGradleVersions(
Expand All @@ -423,6 +424,7 @@ export class AndroidPluginBuildService implements IAndroidPluginBuildService {
runtimeGradleVersions.gradleAndroidPluginVersion
);
this.replaceFileContent(buildGradlePath, "{{pluginName}}", pluginName);
this.replaceFileContent(settingsGradlePath, "{{pluginName}}", pluginName);
}

private async getRuntimeGradleVersions(
Expand Down
24 changes: 24 additions & 0 deletions vendor/gradle-plugin/settings.gradle
Original file line number Diff line number Diff line change
@@ -1 +1,25 @@
import groovy.json.JsonSlurper

def USER_PROJECT_ROOT = "$rootDir/../../../"
def PLATFORMS_ANDROID = "platforms/android"
def PLUGIN_NAME = "{{pluginName}}"

def dependenciesJson = file("${USER_PROJECT_ROOT}/${PLATFORMS_ANDROID}/dependencies.json")
def appDependencies = new JsonSlurper().parseText(dependenciesJson.text)
def pluginData = appDependencies.find { it.name == PLUGIN_NAME }
def nativescriptDependencies = appDependencies.findAll{pluginData.name == it.name}

def getDepPlatformDir = { dep ->
file("$USER_PROJECT_ROOT/$PLATFORMS_ANDROID/${dep.directory}/$PLATFORMS_ANDROID")
}

def applyIncludeSettingsGradlePlugin = {
nativescriptDependencies.each { dep ->
def includeSettingsGradlePath = "${getDepPlatformDir(dep)}/include-settings.gradle"
if (file(includeSettingsGradlePath).exists()) {
apply from: includeSettingsGradlePath
}
}
}

applyIncludeSettingsGradlePlugin()