@@ -140,7 +140,7 @@ class AndroidProjectService implements IPlatformProjectService {
140140 return assetsDirectory ;
141141
142142 } ) . future < string > ( ) ( ) ;
143- }
143+ }
144144
145145 public getDebugOnDeviceSetup ( ) : Mobile . IDebugOnDeviceSetup {
146146 return { } ;
@@ -156,112 +156,112 @@ class AndroidProjectService implements IPlatformProjectService {
156156 return ( ( ) => { } ) . future < void > ( ) ( ) ;
157157 }
158158
159- private updateMetadata ( projectRoot : string ) : void {
160- var projMetadataDir = path . join ( projectRoot , "assets" , "metadata" ) ;
161- var libsmetadataDir = path . join ( projectRoot , "../../lib" , this . platformData . normalizedPlatformName , AndroidProjectService . METADATA_DIRNAME ) ;
162- shell . cp ( "-f" , path . join ( libsmetadataDir , "*.dat" ) , projMetadataDir ) ;
163- }
159+ private updateMetadata ( projectRoot : string ) : void {
160+ var projMetadataDir = path . join ( projectRoot , "assets" , "metadata" ) ;
161+ var libsmetadataDir = path . join ( projectRoot , "../../lib" , this . platformData . normalizedPlatformName , AndroidProjectService . METADATA_DIRNAME ) ;
162+ shell . cp ( "-f" , path . join ( libsmetadataDir , "*.dat" ) , projMetadataDir ) ;
163+ }
164164
165- private generateMetadata ( projectRoot : string ) : void {
166- var metadataGeneratorPath = path . join ( __dirname , "../../resources/tools/metadata-generator.jar" ) ;
167- var libsFolder = path . join ( projectRoot , "../../lib" , this . platformData . normalizedPlatformName ) ;
165+ private generateMetadata ( projectRoot : string ) : void {
166+ var metadataGeneratorPath = path . join ( __dirname , "../../resources/tools/metadata-generator.jar" ) ;
167+ var libsFolder = path . join ( projectRoot , "../../lib" , this . platformData . normalizedPlatformName ) ;
168168 var metadataDirName = AndroidProjectService . METADATA_DIRNAME ;
169- var outDir = path . join ( libsFolder , metadataDirName ) ;
170- this . $fs . ensureDirectoryExists ( outDir ) . wait ( ) ;
169+ var outDir = path . join ( libsFolder , metadataDirName ) ;
170+ this . $fs . ensureDirectoryExists ( outDir ) . wait ( ) ;
171171
172172 shell . cp ( "-f" , path . join ( __dirname , "../../resources/tools/android.jar" ) , libsFolder ) ;
173173 shell . cp ( "-f" , path . join ( __dirname , "../../resources/tools/android-support-v4.jar" ) , libsFolder ) ;
174174 shell . cp ( "-f" , path . join ( projectRoot , "libs/*.jar" ) , libsFolder ) ;
175175
176176 this . spawn ( 'java' , [ '-jar' , metadataGeneratorPath , libsFolder , outDir ] ) . wait ( ) ;
177- }
177+ }
178178
179179 public buildProject ( projectRoot : string ) : IFuture < void > {
180180 return ( ( ) => {
181181 var buildConfiguration = options . release ? "release" : "debug" ;
182- var args = this . getAntArgs ( buildConfiguration , projectRoot ) ;
182+ var args = this . getAntArgs ( buildConfiguration , projectRoot ) ;
183183 var argsSaved = this . getAntArgs ( buildConfiguration , projectRoot ) ;
184- this . spawn ( 'ant' , args ) . wait ( ) ;
185- this . generateMetadata ( projectRoot ) ;
186- this . updateMetadata ( projectRoot ) ;
187- // build the project again in order to include the newly generated metadata
184+ this . spawn ( 'ant' , args ) . wait ( ) ;
185+ this . generateMetadata ( projectRoot ) ;
186+ this . updateMetadata ( projectRoot ) ;
187+ // build the project again in order to include the newly generated metadata
188188 this . spawn ( 'ant' , argsSaved ) . wait ( ) ;
189189 } ) . future < void > ( ) ( ) ;
190190 }
191191
192192 public isPlatformPrepared ( projectRoot : string ) : IFuture < boolean > {
193193 return this . $fs . exists ( path . join ( projectRoot , "assets" , constants . APP_FOLDER_NAME ) ) ;
194- }
194+ }
195195
196- private generateBuildFile ( projDir : string , targetSdk : string ) : void {
197- this . $logger . info ( "Generate build.xml for %s" , projDir ) ;
198- var cmd = util . format ( "android update project -p %s --target %s --subprojects" , projDir , targetSdk ) ;
199- this . $childProcess . exec ( cmd ) . wait ( ) ;
200- }
196+ private generateBuildFile ( projDir : string , targetSdk : string ) : void {
197+ this . $logger . info ( "Generate build.xml for %s" , projDir ) ;
198+ var cmd = util . format ( "android update project -p %s --target %s --subprojects" , projDir , targetSdk ) ;
199+ this . $childProcess . exec ( cmd ) . wait ( ) ;
200+ }
201201
202- private parseProjectProperties ( projDir : string , destDir : string ) : void {
203- var projProp = path . join ( projDir , "project.properties" ) ;
202+ private parseProjectProperties ( projDir : string , destDir : string ) : void {
203+ var projProp = path . join ( projDir , "project.properties" ) ;
204204
205- if ( ! this . $fs . exists ( projProp ) . wait ( ) ) {
206- this . $logger . warn ( "Warning: File %s does not exist" , projProp ) ;
207- return ;
208- }
205+ if ( ! this . $fs . exists ( projProp ) . wait ( ) ) {
206+ this . $logger . warn ( "Warning: File %s does not exist" , projProp ) ;
207+ return ;
208+ }
209209
210210 var lines = this . $fs . readText ( projProp , "utf-8" ) . wait ( ) . split ( os . EOL ) ;
211211
212212 var regEx = / a n d r o i d \. l i b r a r y \. r e f e r e n c e \. ( \d + ) = ( .* ) / ;
213- lines . forEach ( elem => {
214- var match = elem . match ( regEx ) ;
215- if ( match ) {
216- var libRef : ILibRef = { idx : parseInt ( match [ 1 ] ) , path : match [ 2 ] . trim ( ) } ;
217- libRef . adjustedPath = this . $fs . isRelativePath ( libRef . path ) ? path . join ( projDir , libRef . path ) : libRef . path ;
218- this . parseProjectProperties ( libRef . adjustedPath , destDir ) ;
219- }
220- } ) ;
221-
222- this . $logger . info ( "Copying %s" , projDir ) ;
223- shell . cp ( "-Rf" , projDir , destDir ) ;
224-
225- var targetDir = path . join ( destDir , path . basename ( projDir ) ) ;
226- // TODO: parametrize targetSdk
227- var targetSdk = "android-17" ;
228- this . generateBuildFile ( targetDir , targetSdk ) ;
229- }
230-
231- private getProjectReferences ( projDir : string ) : ILibRef [ ] {
232- var projProp = path . join ( projDir , "project.properties" ) ;
213+ lines . forEach ( elem => {
214+ var match = elem . match ( regEx ) ;
215+ if ( match ) {
216+ var libRef : ILibRef = { idx : parseInt ( match [ 1 ] ) , path : match [ 2 ] . trim ( ) } ;
217+ libRef . adjustedPath = this . $fs . isRelativePath ( libRef . path ) ? path . join ( projDir , libRef . path ) : libRef . path ;
218+ this . parseProjectProperties ( libRef . adjustedPath , destDir ) ;
219+ }
220+ } ) ;
221+
222+ this . $logger . info ( "Copying %s" , projDir ) ;
223+ shell . cp ( "-Rf" , projDir , destDir ) ;
224+
225+ var targetDir = path . join ( destDir , path . basename ( projDir ) ) ;
226+ // TODO: parametrize targetSdk
227+ var targetSdk = "android-17" ;
228+ this . generateBuildFile ( targetDir , targetSdk ) ;
229+ }
230+
231+ private getProjectReferences ( projDir : string ) : ILibRef [ ] {
232+ var projProp = path . join ( projDir , "project.properties" ) ;
233233
234234 var lines = this . $fs . readText ( projProp , "utf-8" ) . wait ( ) . split ( os . EOL ) ;
235235
236- var refs : ILibRef [ ] = [ ] ;
236+ var refs : ILibRef [ ] = [ ] ;
237237
238238 var regEx = / a n d r o i d \. l i b r a r y \. r e f e r e n c e \. ( \d + ) = ( .* ) / ;
239- lines . forEach ( elem => {
240- var match = elem . match ( regEx ) ;
241- if ( match ) {
242- var libRef : ILibRef = { idx : parseInt ( match [ 1 ] ) , path : match [ 2 ] } ;
243- libRef . adjustedPath = path . join ( projDir , libRef . path ) ;
244- refs . push ( libRef ) ;
245- }
246- } ) ;
247-
248- return refs ;
249- }
250-
251- private updateProjectReferences ( projDir : string , libraryPath : string ) : void {
252- var refs = this . getProjectReferences ( projDir ) ;
239+ lines . forEach ( elem => {
240+ var match = elem . match ( regEx ) ;
241+ if ( match ) {
242+ var libRef : ILibRef = { idx : parseInt ( match [ 1 ] ) , path : match [ 2 ] } ;
243+ libRef . adjustedPath = path . join ( projDir , libRef . path ) ;
244+ refs . push ( libRef ) ;
245+ }
246+ } ) ;
247+
248+ return refs ;
249+ }
250+
251+ private updateProjectReferences ( projDir : string , libraryPath : string ) : void {
252+ var refs = this . getProjectReferences ( projDir ) ;
253253 var maxIdx = refs . length > 0 ? _ . max ( refs , r => r . idx ) . idx : 0 ;
254254
255- var relLibDir = path . relative ( projDir , libraryPath ) . split ( "\\" ) . join ( "/" ) ;
255+ var relLibDir = path . relative ( projDir , libraryPath ) . split ( "\\" ) . join ( "/" ) ;
256256
257- var libRefExists = _ . any ( refs , r => path . normalize ( r . path ) === path . normalize ( relLibDir ) ) ;
257+ var libRefExists = _ . any ( refs , r => path . normalize ( r . path ) === path . normalize ( relLibDir ) ) ;
258258
259- if ( ! libRefExists ) {
260- var projRef = util . format ( "%sandroid.library.reference.%d=%s" , os . EOL , maxIdx + 1 , relLibDir ) ;
261- var projProp = path . join ( projDir , "project.properties" ) ;
262- fs . appendFileSync ( projProp , projRef , { encoding : "utf-8" } ) ;
263- }
264- }
259+ if ( ! libRefExists ) {
260+ var projRef = util . format ( "%sandroid.library.reference.%d=%s" , os . EOL , maxIdx + 1 , relLibDir ) ;
261+ var projProp = path . join ( projDir , "project.properties" ) ;
262+ fs . appendFileSync ( projProp , projRef , { encoding : "utf-8" } ) ;
263+ }
264+ }
265265
266266 public addLibrary ( platformData : IPlatformData , libraryPath : string ) : IFuture < void > {
267267 return ( ( ) => {
@@ -279,12 +279,12 @@ class AndroidProjectService implements IPlatformProjectService {
279279
280280 var targetLibPath = path . join ( targetPath , path . basename ( libraryPath ) ) ;
281281
282- var libProjProp = path . join ( libraryPath , "project.properties" ) ;
283- if ( this . $fs . exists ( libProjProp ) . wait ( ) ) {
284- this . updateProjectReferences ( platformData . projectRoot , targetLibPath ) ;
285- }
282+ var libProjProp = path . join ( libraryPath , "project.properties" ) ;
283+ if ( this . $fs . exists ( libProjProp ) . wait ( ) ) {
284+ this . updateProjectReferences ( platformData . projectRoot , targetLibPath ) ;
285+ }
286286 } ) . future < void > ( ) ( ) ;
287- }
287+ }
288288
289289 public getFrameworkFilesExtensions ( ) : string [ ] {
290290 return [ ".jar" , ".dat" ] ;
0 commit comments