Skip to content

Commit d1cd491

Browse files
author
Dimitar Tachev
authored
Merge pull request #4111 from NativeScript/release
Merge Release into Master
2 parents dc2e614 + 5ac9442 commit d1cd491

File tree

3 files changed

+50
-4
lines changed

3 files changed

+50
-4
lines changed

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

+5-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import * as path from "path";
22
import { MANIFEST_FILE_NAME, INCLUDE_GRADLE_NAME, ASSETS_DIR, RESOURCES_DIR, TNS_ANDROID_RUNTIME_NAME, AndroidBuildDefaults, PLUGIN_BUILD_DATA_FILENAME } from "../constants";
33
import { getShortPluginName, hook } from "../common/helpers";
44
import { Builder, parseString } from "xml2js";
5-
import { ILogger } from "log4js";
65

76
export class AndroidPluginBuildService implements IAndroidPluginBuildService {
87
/**
@@ -428,8 +427,12 @@ export class AndroidPluginBuildService implements IAndroidPluginBuildService {
428427
`-PbuildToolsVersion=${pluginBuildSettings.androidToolsInfo.buildToolsVersion}`
429428
];
430429

430+
if (this.$logger.getLevel() === "INFO") {
431+
localArgs.push("--quiet");
432+
}
433+
431434
try {
432-
await this.$childProcess.spawnFromEvent(gradlew, localArgs, "close", { cwd: pluginBuildSettings.pluginDir });
435+
await this.$childProcess.spawnFromEvent(gradlew, localArgs, "close", { cwd: pluginBuildSettings.pluginDir, stdio: "inherit" });
433436
} catch (err) {
434437
this.$errors.failWithoutHelp(`Failed to build plugin ${pluginBuildSettings.pluginName} : \n${err}`);
435438
}

lib/services/project-service.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export class ProjectService implements IProjectService {
2121
private $staticConfig: IStaticConfig,
2222
private $packageInstallationManager: IPackageInstallationManager) { }
2323

24-
public async validateProjectName(opts: { projectName: string, force: boolean, pathToProject: string }) : Promise<string> {
24+
public async validateProjectName(opts: { projectName: string, force: boolean, pathToProject: string }): Promise<string> {
2525
let projectName = opts.projectName;
2626
if (!projectName) {
2727
this.$errors.fail("You must specify <App name> when creating a new project.");
@@ -133,7 +133,8 @@ export class ProjectService implements IProjectService {
133133
shelljs.cp('-R', path.join(templateData.templatePath, "*"), destinationDirectory);
134134
break;
135135
case constants.TemplateVersions.v2:
136-
await this.$pacoteService.extractPackage(templateData.templateName, projectDir);
136+
const fullTemplateName = templateData.version ? `${templateData.templateName}@${templateData.version}` : templateData.templateName;
137+
await this.$pacoteService.extractPackage(fullTemplateName, projectDir);
137138
break;
138139
default:
139140
this.$errors.failWithoutHelp(format(constants.ProjectTemplateErrors.InvalidTemplateVersionStringFormat, templateData.templateName, templateData.templateVersion));

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)