@@ -22,6 +22,7 @@ describe('androidPluginBuildService', () => {
22
22
addManifest ?: boolean ,
23
23
addResFolder ?: boolean ,
24
24
addAssetsFolder ?: boolean ,
25
+ addIncludeGradle ?: boolean ,
25
26
addLegacyIncludeGradle ?: boolean ,
26
27
addProjectDir ?: boolean ,
27
28
addProjectRuntime ?: boolean ,
@@ -111,6 +112,7 @@ describe('androidPluginBuildService', () => {
111
112
addManifest ?: boolean ,
112
113
addResFolder ?: boolean ,
113
114
addAssetsFolder ?: boolean ,
115
+ addIncludeGradle ?: boolean ,
114
116
addLegacyIncludeGradle ?: boolean
115
117
} ) {
116
118
const validAndroidManifestContent = `<?xml version="1.0" encoding="UTF-8"?>
@@ -122,21 +124,23 @@ describe('androidPluginBuildService', () => {
122
124
name="string_name"
123
125
>text_string</string>
124
126
</resources>` ;
125
- const validIncludeGradleContent = `android {
126
- productFlavors {
127
- "nativescript-pro-ui" {
128
- dimension "nativescript-pro-ui"
129
- }
130
- }
127
+ const validIncludeGradleContent =
128
+ `android {` +
129
+ ( options . addLegacyIncludeGradle ? `
130
+ productFlavors {
131
+ "nativescript-pro-ui" {
132
+ dimension "nativescript-pro-ui"
131
133
}
134
+ }` : `` ) + `
135
+ }
132
136
133
- def supportVersion = project.hasProperty("supportVersion") ? project.supportVersion : "23.3.0"
137
+ def supportVersion = project.hasProperty("supportVersion") ? project.supportVersion : "23.3.0"
134
138
135
- dependencies {
136
- compile "com.android.support:appcompat-v7:$supportVersion"
137
- compile "com.android.support:recyclerview-v7:$supportVersion"
138
- compile "com.android.support:design:$supportVersion"
139
- }`;
139
+ dependencies {
140
+ compile "com.android.support:appcompat-v7:$supportVersion"
141
+ compile "com.android.support:recyclerview-v7:$supportVersion"
142
+ compile "com.android.support:design:$supportVersion"
143
+ }` ;
140
144
141
145
if ( options . addManifest ) {
142
146
fs . writeFile ( path . join ( pluginFolder , "AndroidManifest.xml" ) , validAndroidManifestContent ) ;
@@ -154,7 +158,7 @@ describe('androidPluginBuildService', () => {
154
158
fs . writeFile ( path . join ( imagesFolder , "myicon.png" ) , "123" ) ;
155
159
}
156
160
157
- if ( options . addLegacyIncludeGradle ) {
161
+ if ( options . addLegacyIncludeGradle || options . addIncludeGradle ) {
158
162
fs . writeFile ( path . join ( pluginFolder , INCLUDE_GRADLE_NAME ) , validIncludeGradleContent ) ;
159
163
}
160
164
}
@@ -291,12 +295,23 @@ describe('androidPluginBuildService', () => {
291
295
addLegacyIncludeGradle : true
292
296
} ) ;
293
297
294
- await androidBuildPluginService . migrateIncludeGradle ( config ) ;
295
-
298
+ const isMigrated = await androidBuildPluginService . migrateIncludeGradle ( config ) ;
296
299
const includeGradleContent = fs . readText ( path . join ( pluginFolder , INCLUDE_GRADLE_NAME ) . toString ( ) ) ;
297
300
const areProductFlavorsRemoved = includeGradleContent . indexOf ( "productFlavors" ) === - 1 ;
301
+
302
+ assert . isTrue ( isMigrated ) ;
298
303
assert . isTrue ( areProductFlavorsRemoved ) ;
299
304
} ) ;
305
+
306
+ it ( 'if there is an already migrated include.gradle file' , async ( ) => {
307
+ const config : IBuildOptions = setup ( {
308
+ addIncludeGradle : true
309
+ } ) ;
310
+
311
+ const isMigrated = await androidBuildPluginService . migrateIncludeGradle ( config ) ;
312
+
313
+ assert . isFalse ( isMigrated ) ;
314
+ } ) ;
300
315
} ) ;
301
316
302
317
function getGradleAndroidPluginVersion ( ) {
0 commit comments