Skip to content

Commit 69f3a8e

Browse files
Mihail Slavchevfealebenpae
authored andcommitted
copy library project and its subprojects
1 parent 4e172cf commit 69f3a8e

File tree

1 file changed

+33
-2
lines changed

1 file changed

+33
-2
lines changed

lib/services/android-project-service.ts

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import options = require("../common/options");
88
import constants = require("../constants");
99
import hostInfo = require("../common/host-info");
1010
import helpers = require("../common/helpers");
11+
import fs = require("fs");
1112

1213
class AndroidProjectService implements IPlatformProjectService {
1314
private SUPPORTED_TARGETS = ["android-17", "android-18", "android-19", "android-21"];
@@ -130,9 +131,39 @@ class AndroidProjectService implements IPlatformProjectService {
130131

131132
public isPlatformPrepared(projectRoot: string): IFuture<boolean> {
132133
return this.$fs.exists(path.join(projectRoot, "assets", constants.APP_FOLDER_NAME));
133-
}
134+
}
135+
136+
private parseProjectProrperies(projDir: string, destDir: string): void {
137+
138+
var projProp = path.join(projDir, "project.properties");
139+
140+
if (!this.$fs.exists(projProp).wait()) {
141+
this.$errors.fail("File %s does not exist", projProp);
142+
}
143+
144+
var lines = fs.readFileSync(projProp, { encoding: "utf-8" }).split("\n");
145+
var thiz = this;
146+
147+
lines.forEach(function (elem, idx, arr) {
148+
var match = elem.match(/android\.library\.reference\.(\d+)=(.*)/);
149+
if (match) {
150+
var libRef: ILibRef = { idx: parseInt(match[1]), path: match[2] };
151+
libRef.adjustedPath = path.join(projDir, libRef.path);
152+
thiz.parseProjectProrperies(libRef.adjustedPath, destDir);
153+
}
154+
});
155+
156+
this.$logger.info("Copying %s", projDir);
157+
shell.cp("-Rf", projDir, destDir);
158+
}
134159

135160
public addLibrary(platformData: IPlatformData, libraryPath: string): IFuture<void> {
161+
var name = path.basename(libraryPath);
162+
var targetPath = path.join(this.$projectData.projectDir, "lib", platformData.normalizedPlatformName);
163+
this.$fs.ensureDirectoryExists(targetPath).wait();
164+
165+
this.parseProjectProrperies(libraryPath, targetPath);
166+
136167
this.$errors.fail("Implement me!");
137168
return Future.fromResult();
138169
}
@@ -330,4 +361,4 @@ class AndroidProjectService implements IPlatformProjectService {
330361
}).future<void>()();
331362
}
332363
}
333-
$injector.register("androidProjectService", AndroidProjectService);
364+
$injector.register("androidProjectService", AndroidProjectService);

0 commit comments

Comments
 (0)