Skip to content

Commit 825bdf4

Browse files
Fatme HavaluovaFatme Havaluova
Fatme Havaluova
authored and
Fatme Havaluova
committed
Process manifest from App_Resources directory
1 parent a1c8a76 commit 825bdf4

File tree

4 files changed

+25
-6
lines changed

4 files changed

+25
-6
lines changed

lib/definitions/project.d.ts

+2
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

+5
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

+16-6
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_JAVA_VERSION = "1.7.0";
1716
private static MIN_RUNTIME_VERSION_WITH_GRADLE = "1.3.0";
1817

@@ -269,21 +268,32 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject
269268
return (() => {
270269
let pluginPlatformsFolderPath = this.getPluginPlatformsFolderPath(pluginData, AndroidProjectService.ANDROID_PLATFORM_NAME);
271270

271+
this.processResourcesFromPlugin(pluginData.name, pluginPlatformsFolderPath).wait();
272+
273+
// Process androidManifest.xml from App_Resources
274+
let manifestFilePath = path.join(this.$projectData.appResourcesDirectoryPath, this.platformData.configurationFileName);
275+
if (this.$fs.exists(manifestFilePath).wait()) {
276+
this.processResourcesFromPlugin("NativescriptAppResources", this.$projectData.appResourcesDirectoryPath).wait();
277+
}
278+
}).future<void>()();
279+
}
280+
281+
private processResourcesFromPlugin(pluginName: string, pluginPlatformsFolderPath: string): IFuture<void> {
282+
return (() => {
272283
let configurationsDirectoryPath = path.join(this.platformData.projectRoot, "configurations");
273284
this.$fs.ensureDirectoryExists(configurationsDirectoryPath).wait();
274285

275-
let pluginConfigurationDirectoryPath = path.join(configurationsDirectoryPath, pluginData.name);
286+
let pluginConfigurationDirectoryPath = path.join(configurationsDirectoryPath, pluginName);
276287
this.$fs.ensureDirectoryExists(pluginConfigurationDirectoryPath).wait();
277288

278-
// Copy include include.gradle file
289+
// Copy include.gradle file
279290
let includeGradleFilePath = path.join(pluginPlatformsFolderPath, "include.gradle");
280291
if(this.$fs.exists(includeGradleFilePath).wait()) {
281-
// TODO: Validate the existing include.gradle
282292
shell.cp("-f", includeGradleFilePath, pluginConfigurationDirectoryPath);
283-
} // TODO: SHOULD generate default include.gradle
293+
}
284294

285295
// Copy all resources from plugin
286-
let resourcesDestinationDirectoryPath = path.join(this.platformData.projectRoot, "src", pluginData.name);
296+
let resourcesDestinationDirectoryPath = path.join(this.platformData.projectRoot, "src", pluginName);
287297
this.$fs.ensureDirectoryExists(resourcesDestinationDirectoryPath).wait();
288298
shell.cp("-Rf", path.join(pluginPlatformsFolderPath, "*"), resourcesDestinationDirectoryPath);
289299
}).future<void>()();

test/stubs.ts

+2
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)