@@ -8,6 +8,7 @@ import options = require("../common/options");
88import constants = require( "../constants" ) ;
99import hostInfo = require( "../common/host-info" ) ;
1010import helpers = require( "../common/helpers" ) ;
11+ import fs = require( "fs" ) ;
1112
1213class 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 ( / a n d r o i d \. l i b r a r y \. r e f e r e n c e \. ( \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