Skip to content

Commit 4f066c1

Browse files
committed
create product flavor in plugin supplied include.gradle if none is present
1 parent c50f9e1 commit 4f066c1

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

build/project-template-gradle/build.gradle

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -206,21 +206,25 @@ task pluginStructureCheck {
206206
}
207207
}
208208

209-
def createIncludeFile (filePath, fileName, dimensionName) {
210-
println "\t+creating include.gradle file for: " + filePath
211-
def defaultIncludeFile = new File(filePath, "include.gradle")
212-
defaultIncludeFile.write ""
213-
209+
def createProductFlavorsContent(flavor, dimensionName)
210+
{
214211
def content = """android {
215212
productFlavors {
216-
${fileName} {
213+
${flavor} {
217214
dimension ${dimensionName}
218215
}
219216
}
220217
}"""
218+
return content;
219+
}
220+
221+
222+
def createIncludeFile (filePath, flavor, dimensionName) {
223+
println "\t + creating include.gradle file for ${filePath}"
221224

222-
223-
defaultIncludeFile << content
225+
def defaultIncludeFile = new File(filePath, "include.gradle")
226+
227+
defaultIncludeFiletext.text = createProductFlavorsContent(flavor, dimensionName);
224228
}
225229

226230
def sanatizeDimensionName(str) {
@@ -273,7 +277,8 @@ def replaceProductFlavorInContent(content, dimension, flavor)
273277
}
274278
else
275279
{
276-
return ''
280+
def newProductFlavorsContent = createProductFlavorsContent(flavor, dimension);
281+
return content.replace("android {", "android {\t ${newProductFlavorsContent}");
277282
}
278283
}
279284

0 commit comments

Comments
 (0)