Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make generation task failed if there is duplicated feature flag name #36

Merged
merged 1 commit into from
Feb 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import org.gradle.api.tasks.PathSensitivity
import org.gradle.api.tasks.TaskAction
import com.github.zafarkhaja.semver.Version
import com.linecorp.android.featureflag.model.FeatureFlagEntry
import org.gradle.api.GradleException
import org.gradle.api.provider.Property

/**
Expand Down Expand Up @@ -99,6 +100,16 @@ abstract class FeatureFlagTask : DefaultTask() {
val entries = sourceFiles
.map { it.useLines(block = FeatureFlagFileTokenizer::parse) }
.flatten()
val duplicatedFeatureFlagNameList = entries.groupingBy { it.name }
.eachCount()
.filter { it.value > 1 }
.map { it.key }
if (duplicatedFeatureFlagNameList.isNotEmpty()) {
val errorMessage = duplicatedFeatureFlagNameList.joinToString(
prefix = "Duplicated feature flag definition found: "
)
throw GradleException(errorMessage)
}
val featureFlags = entries.map {
convertToFeatureFlagData(
it,
Expand Down
Loading