Skip to content

Commit

Permalink
Fix bug not allowing flavor named 'play'
Browse files Browse the repository at this point in the history
  • Loading branch information
SUPERCILEX committed Mar 25, 2020
1 parent edab9b6 commit 4331aa6
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ internal abstract class GenerateResources : DefaultTask() {
if (validateChanges.isNotEmpty()) {
work.submit(Validator::class) {
files.set(validateChanges)
inputDirs.set(resSrcDirs)
}
}
if (generateChanges.isNotEmpty()) {
Expand All @@ -95,11 +96,15 @@ internal abstract class GenerateResources : DefaultTask() {
isChildOf(RELEASE_NAMES_PATH) ||
isChildOf(PRODUCTS_PATH)
check(areRootsValid) { "Unknown Play resource file: $this" }
check(extension != INDEX_MARKER) { "Resources cannot use the 'index' extension: $this" }
check(name != PLAY_PATH || !isChildOf(PLAY_PATH)) {

val isPlayKeywordReserved = name != PLAY_PATH || parameters.inputDirs.get().any {
it.asFile == this
}
check(isPlayKeywordReserved) {
"The file name 'play' is illegal: $this"
}

check(extension != INDEX_MARKER) { "Resources cannot use the 'index' extension: $this" }
validateListings()
validateReleaseNotes()
validateReleaseNames()
Expand Down Expand Up @@ -156,6 +161,7 @@ internal abstract class GenerateResources : DefaultTask() {

interface Params : WorkParameters {
val files: ListProperty<File>
val inputDirs: ListProperty<Directory>
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
play english
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,39 @@ class GenerateResourcesIntegrationTest : IntegrationTestBase() {
.isEqualTo(TaskOutcome.SUCCESS)
}

@Test
fun `Flavor named 'play' is allowed`() {
// language=gradle
val config = """
flavorDimensions 'pricing'
productFlavors {
play { dimension 'pricing' }
}
"""

val result = execute(config, "generatePlayReleasePlayResources")

assertThat(result.task(":generatePlayReleasePlayResources")!!.outcome)
.isEqualTo(TaskOutcome.SUCCESS)
}

@Test
fun `'play' file name is not allowed`() {
// language=gradle
val config = """
flavorDimensions 'pricing'
productFlavors {
illegalPlay { dimension 'pricing' }
}
"""

val result = executeExpectingFailure(
config, "generateIllegalPlayReleasePlayResources")

assertThat(result.task(":generateIllegalPlayReleasePlayResources")!!.outcome)
.isEqualTo(TaskOutcome.FAILED)
}

@Test
fun `Non-existent locale throws`() {
// language=gradle
Expand Down

0 comments on commit 4331aa6

Please sign in to comment.