From 560a5d1eb2fd30c790488dc5953d4defc6d63c4d Mon Sep 17 00:00:00 2001 From: Vasil Trifonov Date: Mon, 5 Nov 2018 18:57:36 +0200 Subject: [PATCH 1/3] Apply before-plugins.gradle file in the plugin build.gradle --- lib/services/android-plugin-build-service.ts | 2 +- vendor/gradle-plugin/build.gradle | 42 ++++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/lib/services/android-plugin-build-service.ts b/lib/services/android-plugin-build-service.ts index 91639a46c2..7a5630130f 100644 --- a/lib/services/android-plugin-build-service.ts +++ b/lib/services/android-plugin-build-service.ts @@ -429,7 +429,7 @@ export class AndroidPluginBuildService implements IAndroidPluginBuildService { ]; try { - await this.$childProcess.spawnFromEvent(gradlew, localArgs, "close", { cwd: pluginBuildSettings.pluginDir }); + await this.$childProcess.spawnFromEvent(gradlew, localArgs, "close", { cwd: pluginBuildSettings.pluginDir, stdio: "inherit" }); } catch (err) { this.$errors.failWithoutHelp(`Failed to build plugin ${pluginBuildSettings.pluginName} : \n${err}`); } diff --git a/vendor/gradle-plugin/build.gradle b/vendor/gradle-plugin/build.gradle index f0d27dd163..3078f644c8 100644 --- a/vendor/gradle-plugin/build.gradle +++ b/vendor/gradle-plugin/build.gradle @@ -1,3 +1,4 @@ +import groovy.json.JsonSlurper buildscript { repositories { @@ -32,6 +33,8 @@ def computeBuildToolsVersion = { -> } android { + applyBeforePluginGradleConfiguration() + compileSdkVersion computeCompileSdkVersion() buildToolsVersion computeBuildToolsVersion() @@ -50,3 +53,42 @@ dependencies { compileOnly "com.android.support:support-v4:$supportVer" compileOnly "com.android.support:appcompat-v7:$supportVer" } + +def getAppResourcesPath() { + def relativePathToApp = "app" + def relativePathToAppResources + def absolutePathToAppResources + def projectRoot = "$rootDir/../../.." + def nsConfigFile = file("$projectRoot/nsconfig.json") + def nsConfig + + if (nsConfigFile.exists()) { + nsConfig = new JsonSlurper().parseText(nsConfigFile.getText("UTF-8")) + } + + if(nsConfig != null && nsConfig.appPath != null){ + relativePathToApp = nsConfig.appPath + } + + if(nsConfig != null && nsConfig.appResourcesPath != null ) { + relativePathToAppResources = nsConfig.appResourcesPath + } else { + relativePathToAppResources = "$relativePathToApp/App_Resources" + } + + absolutePathToAppResources = java.nio.file.Paths.get(projectRoot).resolve(relativePathToAppResources).toAbsolutePath() + + project.ext.appResourcesPath = absolutePathToAppResources + + return absolutePathToAppResources +} + +def applyBeforePluginGradleConfiguration() { + def appResourcesPath = getAppResourcesPath() + def pathToBeforePluginGradle = "$appResourcesPath/Android/before-plugins.gradle" + def beforePluginGradle = file(pathToBeforePluginGradle) + if (beforePluginGradle.exists()) { + println "\t + applying user-defined configuration from ${beforePluginGradle}" + apply from: pathToBeforePluginGradle + } +} \ No newline at end of file From a1c9dc8a4becb180a429e4a0e953980d48375ed9 Mon Sep 17 00:00:00 2001 From: DimitarTachev Date: Tue, 6 Nov 2018 14:23:17 +0200 Subject: [PATCH 2/3] fix: use the specified template version while extracting its package --- lib/services/project-service.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/services/project-service.ts b/lib/services/project-service.ts index dad691ebf2..900e034ea7 100644 --- a/lib/services/project-service.ts +++ b/lib/services/project-service.ts @@ -21,7 +21,7 @@ export class ProjectService implements IProjectService { private $staticConfig: IStaticConfig, private $npmInstallationManager: INpmInstallationManager) { } - public async validateProjectName(opts: { projectName: string, force: boolean, pathToProject: string }) : Promise { + public async validateProjectName(opts: { projectName: string, force: boolean, pathToProject: string }): Promise { let projectName = opts.projectName; if (!projectName) { this.$errors.fail("You must specify when creating a new project."); @@ -133,7 +133,8 @@ export class ProjectService implements IProjectService { shelljs.cp('-R', path.join(templateData.templatePath, "*"), destinationDirectory); break; case constants.TemplateVersions.v2: - await this.$pacoteService.extractPackage(templateData.templateName, projectDir); + const fullTemplateName = templateData.version ? `${templateData.templateName}@${templateData.version}` : templateData.templateName; + await this.$pacoteService.extractPackage(fullTemplateName, projectDir); break; default: this.$errors.failWithoutHelp(format(constants.ProjectTemplateErrors.InvalidTemplateVersionStringFormat, templateData.templateName, templateData.templateVersion)); From 81d1c9f6a583412b0ec56461479863d4b2ee8b74 Mon Sep 17 00:00:00 2001 From: DimitarTachev Date: Thu, 8 Nov 2018 11:52:37 +0200 Subject: [PATCH 3/3] fix: show the build plugin gradle logs only with log trace --- lib/services/android-plugin-build-service.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/services/android-plugin-build-service.ts b/lib/services/android-plugin-build-service.ts index 7a5630130f..8d6e928df3 100644 --- a/lib/services/android-plugin-build-service.ts +++ b/lib/services/android-plugin-build-service.ts @@ -2,7 +2,6 @@ import * as path from "path"; import { MANIFEST_FILE_NAME, INCLUDE_GRADLE_NAME, ASSETS_DIR, RESOURCES_DIR, TNS_ANDROID_RUNTIME_NAME, AndroidBuildDefaults, PLUGIN_BUILD_DATA_FILENAME } from "../constants"; import { getShortPluginName, hook } from "../common/helpers"; import { Builder, parseString } from "xml2js"; -import { ILogger } from "log4js"; export class AndroidPluginBuildService implements IAndroidPluginBuildService { /** @@ -428,6 +427,10 @@ export class AndroidPluginBuildService implements IAndroidPluginBuildService { `-PbuildToolsVersion=${pluginBuildSettings.androidToolsInfo.buildToolsVersion}` ]; + if (this.$logger.getLevel() === "INFO") { + localArgs.push("--quiet"); + } + try { await this.$childProcess.spawnFromEvent(gradlew, localArgs, "close", { cwd: pluginBuildSettings.pluginDir, stdio: "inherit" }); } catch (err) {