@@ -22,6 +22,7 @@ describe('androidPluginBuildService', () => {
2222 addManifest ?: boolean ,
2323 addResFolder ?: boolean ,
2424 addAssetsFolder ?: boolean ,
25+ addIncludeGradle ?: boolean ,
2526 addLegacyIncludeGradle ?: boolean ,
2627 addProjectDir ?: boolean ,
2728 addProjectRuntime ?: boolean ,
@@ -111,6 +112,7 @@ describe('androidPluginBuildService', () => {
111112 addManifest ?: boolean ,
112113 addResFolder ?: boolean ,
113114 addAssetsFolder ?: boolean ,
115+ addIncludeGradle ?: boolean ,
114116 addLegacyIncludeGradle ?: boolean
115117 } ) {
116118 const validAndroidManifestContent = `<?xml version="1.0" encoding="UTF-8"?>
@@ -122,21 +124,23 @@ describe('androidPluginBuildService', () => {
122124 name="string_name"
123125 >text_string</string>
124126</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"
131133 }
134+ }` : `` ) + `
135+ }
132136
133- def supportVersion = project.hasProperty("supportVersion") ? project.supportVersion : "23.3.0"
137+ def supportVersion = project.hasProperty("supportVersion") ? project.supportVersion : "23.3.0"
134138
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+ }` ;
140144
141145 if ( options . addManifest ) {
142146 fs . writeFile ( path . join ( pluginFolder , "AndroidManifest.xml" ) , validAndroidManifestContent ) ;
@@ -154,7 +158,7 @@ describe('androidPluginBuildService', () => {
154158 fs . writeFile ( path . join ( imagesFolder , "myicon.png" ) , "123" ) ;
155159 }
156160
157- if ( options . addLegacyIncludeGradle ) {
161+ if ( options . addLegacyIncludeGradle || options . addIncludeGradle ) {
158162 fs . writeFile ( path . join ( pluginFolder , INCLUDE_GRADLE_NAME ) , validIncludeGradleContent ) ;
159163 }
160164 }
@@ -291,12 +295,23 @@ describe('androidPluginBuildService', () => {
291295 addLegacyIncludeGradle : true
292296 } ) ;
293297
294- await androidBuildPluginService . migrateIncludeGradle ( config ) ;
295-
298+ const isMigrated = await androidBuildPluginService . migrateIncludeGradle ( config ) ;
296299 const includeGradleContent = fs . readText ( path . join ( pluginFolder , INCLUDE_GRADLE_NAME ) . toString ( ) ) ;
297300 const areProductFlavorsRemoved = includeGradleContent . indexOf ( "productFlavors" ) === - 1 ;
301+
302+ assert . isTrue ( isMigrated ) ;
298303 assert . isTrue ( areProductFlavorsRemoved ) ;
299304 } ) ;
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+ } ) ;
300315 } ) ;
301316
302317 function getGradleAndroidPluginVersion ( ) {
0 commit comments