@@ -140,7 +140,7 @@ class AndroidProjectService implements IPlatformProjectService {
140
140
return assetsDirectory ;
141
141
142
142
} ) . future < string > ( ) ( ) ;
143
- }
143
+ }
144
144
145
145
public getDebugOnDeviceSetup ( ) : Mobile . IDebugOnDeviceSetup {
146
146
return { } ;
@@ -156,112 +156,112 @@ class AndroidProjectService implements IPlatformProjectService {
156
156
return ( ( ) => { } ) . future < void > ( ) ( ) ;
157
157
}
158
158
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
+ }
164
164
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 ) ;
168
168
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 ( ) ;
171
171
172
172
shell . cp ( "-f" , path . join ( __dirname , "../../resources/tools/android.jar" ) , libsFolder ) ;
173
173
shell . cp ( "-f" , path . join ( __dirname , "../../resources/tools/android-support-v4.jar" ) , libsFolder ) ;
174
174
shell . cp ( "-f" , path . join ( projectRoot , "libs/*.jar" ) , libsFolder ) ;
175
175
176
176
this . spawn ( 'java' , [ '-jar' , metadataGeneratorPath , libsFolder , outDir ] ) . wait ( ) ;
177
- }
177
+ }
178
178
179
179
public buildProject ( projectRoot : string ) : IFuture < void > {
180
180
return ( ( ) => {
181
181
var buildConfiguration = options . release ? "release" : "debug" ;
182
- var args = this . getAntArgs ( buildConfiguration , projectRoot ) ;
182
+ var args = this . getAntArgs ( buildConfiguration , projectRoot ) ;
183
183
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
188
188
this . spawn ( 'ant' , argsSaved ) . wait ( ) ;
189
189
} ) . future < void > ( ) ( ) ;
190
190
}
191
191
192
192
public isPlatformPrepared ( projectRoot : string ) : IFuture < boolean > {
193
193
return this . $fs . exists ( path . join ( projectRoot , "assets" , constants . APP_FOLDER_NAME ) ) ;
194
- }
194
+ }
195
195
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
+ }
201
201
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" ) ;
204
204
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
+ }
209
209
210
210
var lines = this . $fs . readText ( projProp , "utf-8" ) . wait ( ) . split ( os . EOL ) ;
211
211
212
212
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" ) ;
233
233
234
234
var lines = this . $fs . readText ( projProp , "utf-8" ) . wait ( ) . split ( os . EOL ) ;
235
235
236
- var refs : ILibRef [ ] = [ ] ;
236
+ var refs : ILibRef [ ] = [ ] ;
237
237
238
238
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 ) ;
253
253
var maxIdx = refs . length > 0 ? _ . max ( refs , r => r . idx ) . idx : 0 ;
254
254
255
- var relLibDir = path . relative ( projDir , libraryPath ) . split ( "\\" ) . join ( "/" ) ;
255
+ var relLibDir = path . relative ( projDir , libraryPath ) . split ( "\\" ) . join ( "/" ) ;
256
256
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 ) ) ;
258
258
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
+ }
265
265
266
266
public addLibrary ( platformData : IPlatformData , libraryPath : string ) : IFuture < void > {
267
267
return ( ( ) => {
@@ -279,12 +279,12 @@ class AndroidProjectService implements IPlatformProjectService {
279
279
280
280
var targetLibPath = path . join ( targetPath , path . basename ( libraryPath ) ) ;
281
281
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
+ }
286
286
} ) . future < void > ( ) ( ) ;
287
- }
287
+ }
288
288
289
289
public getFrameworkFilesExtensions ( ) : string [ ] {
290
290
return [ ".jar" , ".dat" ] ;
0 commit comments