@@ -16,6 +16,18 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject
16
16
private static VALUES_VERSION_DIRNAME_PREFIX = AndroidProjectService . VALUES_DIRNAME + "-v" ;
17
17
private static ANDROID_PLATFORM_NAME = "android" ;
18
18
private static MIN_RUNTIME_VERSION_WITH_GRADLE = "1.3.0" ;
19
+ private static MIN_REQUIRED_NODEJS_VERSION_FOR_STATIC_BINDINGS = "4.2.1" ;
20
+ private static REQUIRED_DEV_DEPENDENCIES = [
21
+ { name : "babel-traverse" , version : "^6.4.5" } ,
22
+ { name : "babel-types" , version : "^6.4.5" } ,
23
+ { name : "babylon" , version : "^6.4.5" } ,
24
+ { name : "filewalker" , version : "^0.1.2" } ,
25
+ { name : "lazy" , version : "^1.0.11" }
26
+ ] ;
27
+
28
+ private get sysInfoData ( ) : ISysInfoData {
29
+ return this . $sysInfo . getSysInfo ( path . join ( __dirname , ".." , ".." , "package.json" ) ) . wait ( ) ;
30
+ }
19
31
20
32
private _androidProjectPropertiesManagers : IDictionary < IAndroidProjectPropertiesManager > ;
21
33
@@ -36,7 +48,8 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject
36
48
private $deviceAppDataFactory : Mobile . IDeviceAppDataFactory ,
37
49
private $devicePlatformsConstants : Mobile . IDevicePlatformsConstants ,
38
50
private $projectTemplatesService : IProjectTemplatesService ,
39
- private $xmlValidator : IXmlValidator ) {
51
+ private $xmlValidator : IXmlValidator ,
52
+ private $npm : INodePackageManager ) {
40
53
super ( $fs , $projectData , $projectDataService ) ;
41
54
this . _androidProjectPropertiesManagers = Object . create ( null ) ;
42
55
}
@@ -88,7 +101,7 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject
88
101
89
102
// this call will fail in case `android` is not set correctly.
90
103
this . $androidToolsInfo . getPathToAndroidExecutable ( { showWarningsAsErrors : true } ) . wait ( ) ;
91
- this . $androidToolsInfo . validateJavacVersion ( this . $sysInfo . getSysInfo ( path . join ( __dirname , ".." , ".." , "package.json" ) ) . wait ( ) . javacVersion , { showWarningsAsErrors : true } ) . wait ( ) ;
104
+ this . $androidToolsInfo . validateJavacVersion ( this . sysInfoData . javacVersion , { showWarningsAsErrors : true } ) . wait ( ) ;
92
105
} ) . future < void > ( ) ( ) ;
93
106
}
94
107
@@ -126,10 +139,28 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject
126
139
}
127
140
128
141
this . cleanResValues ( targetSdkVersion , frameworkVersion ) . wait ( ) ;
129
-
142
+ if ( this . canUseStaticBindingGenerator ( ) ) {
143
+ let npmConfig = {
144
+ "save" : true ,
145
+ "save-dev" : true ,
146
+ "save-exact" : true ,
147
+ "silent" : true
148
+ } ;
149
+
150
+ _ . each ( AndroidProjectService . REQUIRED_DEV_DEPENDENCIES , ( dependency : any ) =>
151
+ this . $npm . install ( `${ dependency . name } @${ dependency . version } ` , this . $projectData . projectDir , npmConfig ) . wait ( )
152
+ ) ;
153
+ } else {
154
+ this . $logger . printMarkdown ( ` As you are using Node.js \`${ this . sysInfoData . nodeVer } \` Static Binding Generator will be turned off.` +
155
+ `Upgrade your Node.js to ${ AndroidProjectService . MIN_REQUIRED_NODEJS_VERSION_FOR_STATIC_BINDINGS } or later, so you can use this feature.` ) ;
156
+ }
130
157
} ) . future < any > ( ) ( ) ;
131
158
}
132
159
160
+ private canUseStaticBindingGenerator ( ) : boolean {
161
+ return semver . gte ( this . sysInfoData . nodeVer , AndroidProjectService . MIN_REQUIRED_NODEJS_VERSION_FOR_STATIC_BINDINGS ) ;
162
+ }
163
+
133
164
private useGradleWrapper ( frameworkDir : string ) : boolean {
134
165
let gradlew = path . join ( frameworkDir , "gradlew" ) ;
135
166
return this . $fs . exists ( gradlew ) . wait ( ) ;
@@ -231,8 +262,8 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject
231
262
buildOptions . push ( `-PksPassword=${ this . $options . keyStorePassword } ` ) ;
232
263
}
233
264
234
- if ( buildConfig && buildConfig . runSbGenerator ) {
235
- buildOptions . push ( "-PrunSBGenerator " ) ;
265
+ if ( ! this . canUseStaticBindingGenerator ( ) ) {
266
+ buildOptions . push ( "-PdontRunSbg " ) ;
236
267
}
237
268
238
269
let gradleBin = this . useGradleWrapper ( projectRoot ) ? path . join ( projectRoot , "gradlew" ) : "gradle" ;
0 commit comments