Last active
December 14, 2021 10:42
-
-
Save PaoloMilano/e35a9609ed503d90d3e2178fbcfa2801 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun Project.android(): BaseExtension { | |
val android = project.extensions.findByType(BaseExtension::class.java) | |
if (android != null) { | |
return android | |
} else { | |
throw GradleException("Project $name is not an Android project") | |
} | |
} | |
fun BaseExtension.variants(): DomainObjectSet<out BaseVariant> { | |
return when (this) { | |
is AppExtension -> { | |
applicationVariants | |
} | |
is FeatureExtension ->{ | |
featureVariants | |
} | |
is LibraryExtension -> { | |
libraryVariants | |
} | |
else -> throw GradleException("Unsupported BaseExtension type!") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment