Skip to content

Instantly share code, notes, and snippets.

@LizzieStudeneer
Created September 9, 2019 08:33
Show Gist options
  • Save LizzieStudeneer/f61e2867a9f5b962df473c622429c675 to your computer and use it in GitHub Desktop.
Save LizzieStudeneer/f61e2867a9f5b962df473c622429c675 to your computer and use it in GitHub Desktop.
// BluesquarePlugin.kt
open class BluesquarePlugin : Plugin<Project> {
override fun apply(project: Project) {
project.configureAndroid()
}
}
// Android.kt
internal fun Project.configureAndroid() = this.extensions.getByType<AndroidBaseExtension>().run {
compileSdkVersion(28)
defaultConfig {
minSdkVersion(21)
targetSdkVersion(28)
versionCode = 2
versionName = "1.0.1"
testInstrumentationRunner = "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
getByName("release") {
isMinifyEnabled = false
proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro")
}
getByName("debug") {
isTestCoverageEnabled = true
}
}
packagingOptions {
exclude("META-INF/NOTICE.txt")
// ...
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
}
@petitJAM
Copy link

petitJAM commented Oct 3, 2019

Where does AndroidBaseExtension come from? What's the import statement there?

@Flywith24
Copy link

Where does AndroidBaseExtension come from? What's the import statement there?

add

private typealias AndroidBaseExtension = BaseExtension

@Coronel-B
Copy link

How can I add kotlinOptions{ } in the scope of this.extensions.getByType<AndroidBaseExtension>().run { } ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment