@@ -61,9 +61,9 @@ class AndroidProjectService extends projectServiceBaseLib.PlatformProjectService
61
61
return this . _platformData ;
62
62
}
63
63
64
- public getAppResourcesDestinationDirectoryPath ( ) : IFuture < string > {
64
+ public getAppResourcesDestinationDirectoryPath ( frameworkVersion ?: string ) : IFuture < string > {
65
65
return ( ( ) => {
66
- if ( this . canUseGradle ( ) . wait ( ) ) {
66
+ if ( this . canUseGradle ( frameworkVersion ) . wait ( ) ) {
67
67
return path . join ( this . platformData . projectRoot , "src" , "main" , "res" ) ;
68
68
}
69
69
@@ -81,7 +81,7 @@ class AndroidProjectService extends projectServiceBaseLib.PlatformProjectService
81
81
} ) . future < void > ( ) ( ) ;
82
82
}
83
83
84
- public createProject ( projectRoot : string , frameworkDir : string ) : IFuture < void > {
84
+ public createProject ( frameworkDir : string , frameworkVersion : string ) : IFuture < void > {
85
85
return ( ( ) => {
86
86
let frameworkVersion = this . $fs . readJson ( path . join ( frameworkDir , "../" , "package.json" ) ) . wait ( ) . version ;
87
87
if ( semver . lt ( frameworkVersion , AndroidProjectService . MIN_RUNTIME_VERSION_WITH_GRADLE ) ) {
@@ -91,30 +91,30 @@ class AndroidProjectService extends projectServiceBaseLib.PlatformProjectService
91
91
// TODO: Move these check to validate method once we do not support ant.
92
92
this . checkGradle ( ) . wait ( ) ;
93
93
94
- this . $fs . ensureDirectoryExists ( projectRoot ) . wait ( ) ;
94
+ this . $fs . ensureDirectoryExists ( this . platformData . projectRoot ) . wait ( ) ;
95
95
let androidToolsInfo = this . $androidToolsInfo . getToolsInfo ( ) . wait ( ) ;
96
- let newTarget = androidToolsInfo . targetSdkVersion ;
97
- this . $logger . trace ( `Using Android SDK '${ newTarget } '.` ) ;
96
+ let targetSdkVersion = androidToolsInfo . targetSdkVersion ;
97
+ this . $logger . trace ( `Using Android SDK '${ targetSdkVersion } '.` ) ;
98
98
if ( this . $options . symlink ) {
99
- this . symlinkDirectory ( "build-tools" , projectRoot , frameworkDir ) . wait ( ) ;
100
- this . symlinkDirectory ( "libs" , projectRoot , frameworkDir ) . wait ( ) ;
101
- this . symlinkDirectory ( "src" , projectRoot , frameworkDir ) . wait ( ) ;
99
+ this . symlinkDirectory ( "build-tools" , this . platformData . projectRoot , frameworkDir ) . wait ( ) ;
100
+ this . symlinkDirectory ( "libs" , this . platformData . projectRoot , frameworkDir ) . wait ( ) ;
101
+ this . symlinkDirectory ( "src" , this . platformData . projectRoot , frameworkDir ) . wait ( ) ;
102
102
103
- this . $fs . symlink ( path . join ( frameworkDir , "build.gradle" ) , path . join ( projectRoot , "build.gradle" ) ) . wait ( ) ;
104
- this . $fs . symlink ( path . join ( frameworkDir , "settings.gradle" ) , path . join ( projectRoot , "settings.gradle" ) ) . wait ( ) ;
103
+ this . $fs . symlink ( path . join ( frameworkDir , "build.gradle" ) , path . join ( this . platformData . projectRoot , "build.gradle" ) ) . wait ( ) ;
104
+ this . $fs . symlink ( path . join ( frameworkDir , "settings.gradle" ) , path . join ( this . platformData . projectRoot , "settings.gradle" ) ) . wait ( ) ;
105
105
} else {
106
- this . copy ( projectRoot , frameworkDir , "build-tools libs src" , "-R" ) ;
107
- this . copy ( projectRoot , frameworkDir , "build.gradle settings.gradle" , "-f" ) ;
106
+ this . copy ( this . platformData . projectRoot , frameworkDir , "build-tools libs src" , "-R" ) ;
107
+ this . copy ( this . platformData . projectRoot , frameworkDir , "build.gradle settings.gradle" , "-f" ) ;
108
108
}
109
109
110
- this . cleanResValues ( newTarget ) . wait ( ) ;
110
+ this . cleanResValues ( targetSdkVersion , frameworkVersion ) . wait ( ) ;
111
111
112
112
} ) . future < any > ( ) ( ) ;
113
113
}
114
114
115
- private cleanResValues ( versionNumber : number ) : IFuture < void > {
115
+ private cleanResValues ( targetSdkVersion : number , frameworkVersion : string ) : IFuture < void > {
116
116
return ( ( ) => {
117
- let resDestinationDir = this . getAppResourcesDestinationDirectoryPath ( ) . wait ( ) ;
117
+ let resDestinationDir = this . getAppResourcesDestinationDirectoryPath ( frameworkVersion ) . wait ( ) ;
118
118
let directoriesInResFolder = this . $fs . readDirectory ( resDestinationDir ) . wait ( ) ;
119
119
let directoriesToClean = directoriesInResFolder
120
120
. map ( dir => { return {
@@ -124,7 +124,7 @@ class AndroidProjectService extends projectServiceBaseLib.PlatformProjectService
124
124
} )
125
125
. filter ( dir => dir . dirName . match ( AndroidProjectService . VALUES_VERSION_DIRNAME_PREFIX )
126
126
&& dir . sdkNum
127
- && ( ! versionNumber || ( versionNumber < dir . sdkNum ) ) )
127
+ && ( ! targetSdkVersion || ( targetSdkVersion < dir . sdkNum ) ) )
128
128
. map ( dir => path . join ( resDestinationDir , dir . dirName ) ) ;
129
129
this . $logger . trace ( "Directories to clean:" ) ;
130
130
this . $logger . trace ( directoriesToClean ) ;
@@ -270,11 +270,19 @@ class AndroidProjectService extends projectServiceBaseLib.PlatformProjectService
270
270
return Future . fromResult ( ) ;
271
271
}
272
272
273
- private canUseGradle ( ) : IFuture < boolean > {
273
+ private _canUseGradle : boolean ;
274
+ private canUseGradle ( frameworkVersion ?: string ) : IFuture < boolean > {
274
275
return ( ( ) => {
275
- this . $projectDataService . initialize ( this . $projectData . projectDir ) ;
276
- let frameworkVersion = this . $projectDataService . getValue ( this . platformData . frameworkPackageName ) . wait ( ) . version ;
277
- return semver . gte ( frameworkVersion , AndroidProjectService . MIN_RUNTIME_VERSION_WITH_GRADLE ) ;
276
+ if ( ! this . _canUseGradle ) {
277
+ if ( ! frameworkVersion ) {
278
+ this . $projectDataService . initialize ( this . $projectData . projectDir ) ;
279
+ frameworkVersion = this . $projectDataService . getValue ( this . platformData . frameworkPackageName ) . wait ( ) . version ;
280
+ }
281
+
282
+ this . _canUseGradle = semver . gte ( frameworkVersion , AndroidProjectService . MIN_RUNTIME_VERSION_WITH_GRADLE ) ;
283
+ }
284
+
285
+ return this . _canUseGradle ;
278
286
} ) . future < boolean > ( ) ( ) ;
279
287
}
280
288
0 commit comments