Skip to content

Commit 64f4cd2

Browse files
Fatme Havaluovateobugslayer
Fatme Havaluova
authored andcommitted
Process manifest from App_Resources directory
1 parent 69e70c0 commit 64f4cd2

File tree

4 files changed

+25
-6
lines changed

4 files changed

+25
-6
lines changed

lib/definitions/project.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ interface IProjectData {
1010
projectFilePath: string;
1111
projectId?: string;
1212
dependencies: any;
13+
appDirectoryPath: string;
14+
appResourcesDirectoryPath: string;
1315
}
1416

1517
interface IProjectDataService {

lib/project-data.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
///<reference path=".d.ts"/>
22
"use strict";
33

4+
import constants = require("./constants");
45
import * as path from "path";
56
import * as os from "os";
67

@@ -12,6 +13,8 @@ export class ProjectData implements IProjectData {
1213
public projectFilePath: string;
1314
public projectId: string;
1415
public projectName: string;
16+
public appDirectoryPath: string;
17+
public appResourcesDirectoryPath: string;
1518
public dependencies: any;
1619

1720
constructor(private $fs: IFileSystem,
@@ -101,6 +104,8 @@ export class ProjectData implements IProjectData {
101104
this.projectName = this.$projectHelper.sanitizeName(path.basename(projectDir));
102105
this.platformsDir = path.join(projectDir, "platforms");
103106
this.projectFilePath = path.join(projectDir, this.$staticConfig.PROJECT_FILE_NAME);
107+
this.appDirectoryPath = path.join(projectDir, constants.APP_FOLDER_NAME);
108+
this.appResourcesDirectoryPath = path.join(projectDir, constants.APP_FOLDER_NAME, constants.APP_RESOURCES_FOLDER_NAME);
104109
}
105110
}
106111
$injector.register("projectData", ProjectData);

lib/services/android-project-service.ts

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject
1212
private static VALUES_DIRNAME = "values";
1313
private static VALUES_VERSION_DIRNAME_PREFIX = AndroidProjectService.VALUES_DIRNAME + "-v";
1414
private static ANDROID_PLATFORM_NAME = "android";
15-
private static LIBS_FOLDER_NAME = "libs";
1615
private static MIN_RUNTIME_VERSION_WITH_GRADLE = "1.3.0";
1716

1817
private _androidProjectPropertiesManagers: IDictionary<IAndroidProjectPropertiesManager>;
@@ -278,21 +277,32 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject
278277
return (() => {
279278
let pluginPlatformsFolderPath = this.getPluginPlatformsFolderPath(pluginData, AndroidProjectService.ANDROID_PLATFORM_NAME);
280279

280+
this.processResourcesFromPlugin(pluginData.name, pluginPlatformsFolderPath).wait();
281+
282+
// Process androidManifest.xml from App_Resources
283+
let manifestFilePath = path.join(this.$projectData.appResourcesDirectoryPath, this.platformData.configurationFileName);
284+
if (this.$fs.exists(manifestFilePath).wait()) {
285+
this.processResourcesFromPlugin("NativescriptAppResources", this.$projectData.appResourcesDirectoryPath).wait();
286+
}
287+
}).future<void>()();
288+
}
289+
290+
private processResourcesFromPlugin(pluginName: string, pluginPlatformsFolderPath: string): IFuture<void> {
291+
return (() => {
281292
let configurationsDirectoryPath = path.join(this.platformData.projectRoot, "configurations");
282293
this.$fs.ensureDirectoryExists(configurationsDirectoryPath).wait();
283294

284-
let pluginConfigurationDirectoryPath = path.join(configurationsDirectoryPath, pluginData.name);
295+
let pluginConfigurationDirectoryPath = path.join(configurationsDirectoryPath, pluginName);
285296
this.$fs.ensureDirectoryExists(pluginConfigurationDirectoryPath).wait();
286297

287-
// Copy include include.gradle file
298+
// Copy include.gradle file
288299
let includeGradleFilePath = path.join(pluginPlatformsFolderPath, "include.gradle");
289300
if(this.$fs.exists(includeGradleFilePath).wait()) {
290-
// TODO: Validate the existing include.gradle
291301
shell.cp("-f", includeGradleFilePath, pluginConfigurationDirectoryPath);
292-
} // TODO: SHOULD generate default include.gradle
302+
}
293303

294304
// Copy all resources from plugin
295-
let resourcesDestinationDirectoryPath = path.join(this.platformData.projectRoot, "src", pluginData.name);
305+
let resourcesDestinationDirectoryPath = path.join(this.platformData.projectRoot, "src", pluginName);
296306
this.$fs.ensureDirectoryExists(resourcesDestinationDirectoryPath).wait();
297307
shell.cp("-Rf", path.join(pluginPlatformsFolderPath, "*"), resourcesDestinationDirectoryPath);
298308
}).future<void>()();

test/stubs.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,8 @@ export class ProjectDataStub implements IProjectData {
249249
projectFilePath: string;
250250
projectId: string;
251251
dependencies: any;
252+
appDirectoryPath: string;
253+
appResourcesDirectoryPath: string;
252254
}
253255

254256
export class PlatformsDataStub implements IPlatformsData {

0 commit comments

Comments
 (0)