@@ -29,32 +29,37 @@ class AndroidProjectService implements IPlatformProjectService {
29
29
private $propertiesParser : IPropertiesParser ) {
30
30
}
31
31
32
+ private _platformData : IPlatformData = null ;
32
33
public get platformData ( ) : IPlatformData {
33
- var projectRoot = path . join ( this . $projectData . platformsDir , "android" ) ;
34
-
35
- return {
36
- frameworkPackageName : "tns-android" ,
37
- normalizedPlatformName : "Android" ,
38
- appDestinationDirectoryPath : path . join ( projectRoot , "assets" ) ,
39
- appResourcesDestinationDirectoryPath : path . join ( projectRoot , "res" ) ,
40
- platformProjectService : this ,
41
- emulatorServices : this . $androidEmulatorServices ,
42
- projectRoot : projectRoot ,
43
- deviceBuildOutputPath : path . join ( this . $projectData . platformsDir , "android" , "bin" ) ,
44
- validPackageNamesForDevice : [
45
- util . format ( "%s-%s.%s" , this . $projectData . projectName , "debug" , "apk" ) ,
46
- util . format ( "%s-%s.%s" , this . $projectData . projectName , "release" , "apk" )
47
- ] ,
48
- frameworkFilesExtensions : [ ".jar" , ".dat" , ".so" ]
49
- } ;
34
+ if ( ! this . _platformData ) {
35
+ var projectRoot = path . join ( this . $projectData . platformsDir , "android" ) ;
36
+
37
+ this . _platformData = {
38
+ frameworkPackageName : "tns-android" ,
39
+ normalizedPlatformName : "Android" ,
40
+ appDestinationDirectoryPath : path . join ( projectRoot , "assets" ) ,
41
+ appResourcesDestinationDirectoryPath : path . join ( projectRoot , "res" ) ,
42
+ platformProjectService : this ,
43
+ emulatorServices : this . $androidEmulatorServices ,
44
+ projectRoot : projectRoot ,
45
+ deviceBuildOutputPath : path . join ( this . $projectData . platformsDir , "android" , "bin" ) ,
46
+ validPackageNamesForDevice : [
47
+ util . format ( "%s-%s.%s" , this . $projectData . projectName , "debug" , "apk" ) ,
48
+ util . format ( "%s-%s.%s" , this . $projectData . projectName , "release" , "apk" )
49
+ ] ,
50
+ frameworkFilesExtensions : [ ".jar" , ".dat" , ".so" ]
51
+ } ;
52
+ }
53
+
54
+ return this . _platformData ;
50
55
}
51
56
52
57
public validate ( ) : IFuture < void > {
53
58
return ( ( ) => {
54
59
this . validatePackageName ( this . $projectData . projectId ) ;
55
60
this . validateProjectName ( this . $projectData . projectName ) ;
56
61
57
- this . checkAnt ( ) . wait ( ) && this . checkAndroid ( ) . wait ( ) && this . checkJava ( ) . wait ( ) ;
62
+ this . checkAnt ( ) . wait ( ) && this . checkAndroid ( ) . wait ( ) ;
58
63
} ) . future < void > ( ) ( ) ;
59
64
}
60
65
@@ -65,14 +70,14 @@ class AndroidProjectService implements IPlatformProjectService {
65
70
var versionNumber = _ . last ( newTarget . split ( "-" ) ) ;
66
71
if ( options . symlink ) {
67
72
this . copyResValues ( projectRoot , frameworkDir , versionNumber ) . wait ( ) ;
68
- this . copy ( projectRoot , frameworkDir , ".project AndroidManifest.xml project.properties" , "-f" ) . wait ( ) ;
73
+ this . copy ( projectRoot , frameworkDir , ".project AndroidManifest.xml project.properties custom_rules.xml " , "-f" ) . wait ( ) ;
69
74
70
75
this . symlinkDirectory ( "assets" , projectRoot , frameworkDir ) . wait ( ) ;
71
76
this . symlinkDirectory ( "libs" , projectRoot , frameworkDir ) . wait ( ) ;
72
77
} else {
73
78
this . copyResValues ( projectRoot , frameworkDir , versionNumber ) . wait ( ) ;
74
79
this . copy ( projectRoot , frameworkDir , "assets libs" , "-R" ) . wait ( ) ;
75
- this . copy ( projectRoot , frameworkDir , ".project AndroidManifest.xml project.properties" , "-f" ) . wait ( ) ;
80
+ this . copy ( projectRoot , frameworkDir , ".project AndroidManifest.xml project.properties custom_rules.xml " , "-f" ) . wait ( ) ;
76
81
}
77
82
78
83
if ( newTarget ) {
@@ -132,45 +137,18 @@ class AndroidProjectService implements IPlatformProjectService {
132
137
}
133
138
134
139
public canUpdatePlatform ( currentVersion : string , newVersion : string ) : IFuture < boolean > {
135
- return ( ( ) => {
136
- return true ;
137
- } ) . future < boolean > ( ) ( ) ;
140
+ return Future . fromResult < boolean > ( true ) ;
138
141
}
139
142
140
143
public updatePlatform ( currentVersion : string , newVersion : string ) : IFuture < void > {
141
144
return ( ( ) => { } ) . future < void > ( ) ( ) ;
142
145
}
143
146
144
- private updateMetadata ( projectRoot : string ) : void {
145
- var projMetadataDir = path . join ( projectRoot , "assets" , "metadata" ) ;
146
- var libsmetadataDir = path . join ( projectRoot , "../../lib" , this . platformData . normalizedPlatformName , AndroidProjectService . METADATA_DIRNAME ) ;
147
- shell . cp ( "-f" , path . join ( libsmetadataDir , "*.dat" ) , projMetadataDir ) ;
148
- }
149
-
150
- private generateMetadata ( projectRoot : string ) : void {
151
- var metadataGeneratorPath = path . join ( __dirname , "../../resources/tools/metadata-generator.jar" ) ;
152
- var libsFolder = path . join ( projectRoot , "../../lib" , this . platformData . normalizedPlatformName ) ;
153
- var metadataDirName = AndroidProjectService . METADATA_DIRNAME ;
154
- var outDir = path . join ( libsFolder , metadataDirName ) ;
155
- this . $fs . ensureDirectoryExists ( outDir ) . wait ( ) ;
156
-
157
- shell . cp ( "-f" , path . join ( __dirname , "../../resources/tools/android.jar" ) , libsFolder ) ;
158
- shell . cp ( "-f" , path . join ( __dirname , "../../resources/tools/android-support-v4.jar" ) , libsFolder ) ;
159
- shell . cp ( "-f" , path . join ( projectRoot , "libs/*.jar" ) , libsFolder ) ;
160
-
161
- this . spawn ( 'java' , [ '-jar' , metadataGeneratorPath , libsFolder , outDir ] ) . wait ( ) ;
162
- }
163
-
164
147
public buildProject ( projectRoot : string ) : IFuture < void > {
165
148
return ( ( ) => {
166
149
var buildConfiguration = options . release ? "release" : "debug" ;
167
150
var args = this . getAntArgs ( buildConfiguration , projectRoot ) ;
168
- var argsSaved = this . getAntArgs ( buildConfiguration , projectRoot ) ;
169
151
this . spawn ( 'ant' , args ) . wait ( ) ;
170
- this . generateMetadata ( projectRoot ) ;
171
- this . updateMetadata ( projectRoot ) ;
172
- // build the project again in order to include the newly generated metadata
173
- this . spawn ( 'ant' , argsSaved ) . wait ( ) ;
174
152
} ) . future < void > ( ) ( ) ;
175
153
}
176
154
@@ -285,7 +263,7 @@ class AndroidProjectService implements IPlatformProjectService {
285
263
private spawn ( command : string , args : string [ ] ) : IFuture < void > {
286
264
if ( hostInfo . isWindows ( ) ) {
287
265
args . unshift ( '/s' , '/c' , command ) ;
288
- command = 'cmd' ;
266
+ command = process . env . COMSPEC || 'cmd.exe ' ;
289
267
}
290
268
291
269
return this . $childProcess . spawnFromEvent ( command , args , "close" , { stdio : "inherit" } ) ;
@@ -311,6 +289,9 @@ class AndroidProjectService implements IPlatformProjectService {
311
289
}
312
290
}
313
291
292
+ // metadata generation support
293
+ args = args . concat ( [ "-Dns.resources" , path . join ( __dirname , "../../resources/tools" ) ] ) ;
294
+
314
295
return args ;
315
296
}
316
297
@@ -422,16 +403,6 @@ class AndroidProjectService implements IPlatformProjectService {
422
403
} ) . future < void > ( ) ( ) ;
423
404
}
424
405
425
- private checkJava ( ) : IFuture < void > {
426
- return ( ( ) => {
427
- try {
428
- this . $childProcess . exec ( "java -version" ) . wait ( ) ;
429
- } catch ( error ) {
430
- this . $errors . fail ( "%s\n Failed to run 'java', make sure your java environment is set up.\n Including JDK and JRE.\n Your JAVA_HOME variable is %s" , error , process . env . JAVA_HOME ) ;
431
- }
432
- } ) . future < void > ( ) ( ) ;
433
- }
434
-
435
406
private checkAndroid ( ) : IFuture < void > {
436
407
return ( ( ) => {
437
408
try {
0 commit comments