Last active
September 22, 2020 13:15
-
-
Save jmfayard/448cc931bbb2700b99878370728c5251 to your computer and use it in GitHub Desktop.
Gists Gradle-Kotlin-DSL
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
plugins { | |
id("com.android.application") | |
id("kotlin-android") | |
id("kotlin-android-extensions") | |
} | |
android { | |
compileSdkVersion(Config.SdkVersions.compile) | |
defaultConfig { | |
minSdkVersion(Config.SdkVersions.min) | |
targetSdkVersion(Config.SdkVersions.target) | |
testInstrumentationRunner = "android.support.test.runner.AndroidJUnitRunner" | |
multiDexEnabled = true | |
proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") | |
signingConfigs { | |
named("debug").configure { | |
storeFile = file("debug.keystore") | |
} | |
register("release") { | |
storeFile = file("debug.keystore") | |
} | |
} | |
buildTypes { | |
named("debug").configure { | |
applicationIdSuffix = ".debug" | |
isMinifyEnabled = false | |
} | |
named("release").configure { | |
isMinifyEnabled = tue | |
signingConfig = if (mautinoa.enableSigning()) | |
signingConfigs.getByName("release") else | |
signingConfigs.getByName("debug") | |
} | |
} | |
lintOptions { | |
isAbortOnError = false | |
} | |
} | |
} |
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
// root build.gradle.kts | |
buildscript { | |
repositories { | |
google() | |
mavenLocal() | |
mavenCentral() | |
jcenter() | |
maven("https://maven.fabric.io/public") | |
} | |
dependencies { | |
classpath(Config.Plugins.kotlin) | |
classpath(Config.Plugins.android) | |
classpath(Config.Plugins.dexcount) | |
classpath(Config.Plugins.googleplay_publisher) | |
classpath(Config.Plugins.git) | |
classpath(Config.Plugins.fabric) | |
} | |
} | |
plugins { | |
id("com.gradle.build-scan") version "1.15.1" | |
id("com.github.ben-manes.versions") version "0.20.0" | |
id("jmfayard.github.io.gradle-kotlin-dsl-libs") version "0.2.3" // $ gw syncLibs | |
id("com.jfrog.artifactory") version "4.7.5" | |
} |
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
plugins { | |
id("com.gradle.build-scan") version "1.15.1" | |
} | |
buildScan { | |
setTermsOfServiceUrl("https://gradle.com/terms-of-service") | |
setTermsOfServiceAgree("yes") | |
publishAlways() | |
} |
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
plugins { | |
`kotlin-dsl` | |
} | |
repositories { | |
mavenCentral() | |
jcenter() | |
google() | |
} | |
dependencies { | |
implementation("com.android.tools.build:gradle:3.2.0") | |
} | |
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
// buildSrc/src/main/kotlin/Config.kt | |
object Config { | |
const val ACTIVITY = "com.mautinoa.cardapp.MainActivity" | |
const val PACKAGE = "com.mautinoa.cardapp" | |
const val kotlinVersion = "1.2.71" | |
object SdkVersions { | |
val versionCode = 1 | |
val compile = 28 | |
val target = 26 | |
val min = 19 | |
} | |
object Plugins { | |
const val android = "com.android.tools.build:gradle:3.2.0" | |
const val kotlin = "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion" | |
const val firebase = "com.google.firebase:firebase-plugins:1.1.5" | |
const val fabric = "io.fabric.tools:gradle:1.25.4" | |
const val ktlint = "com.github.shyiko:ktlint:0.28.0" | |
const val git = "org.ajoberstar:gradle-git:0.2.3" | |
const val dexcount = "com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.8.3" | |
const val googleplay_publisher = "com.github.triplet.gradle:play-publisher:1.2.2" | |
} | |
} |
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
plugins { | |
id("jmfayard.github.io.gradle-kotlin-dsl-libs") version "0.2.3" // $ gw syncLibs | |
} |
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
java { | |
sourceCompatibility = JavaVersion.VERSION_1_7 | |
targetCompatibility = JavaVersion.VERSION_1_7 | |
} |
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
// buildSrc/src/main/kotlin | |
fun RepositoryHandler.maven( | |
url: String, | |
name: String? = null, | |
username: String? = null, | |
password: String? = null, | |
configure: RepositoryHandler.() -> Unit = {} | |
) { | |
this.maven { | |
setUrl(url) | |
if (name != null) setName(name) | |
if (username != null && password != null) { | |
credentials { | |
setUsername(username) | |
setPassword(password) | |
} | |
} | |
configure() | |
} | |
} |
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
// buildsrc/src/main/kotlin/Projects.kt | |
import com.android.build.gradle.BaseExtension | |
import com.android.build.gradle.internal.dsl.DefaultConfig | |
import org.gradle.api.artifacts.dsl.RepositoryHandler | |
fun DefaultConfig.addResValues( | |
vararg entries: Pair<String, String> | |
) { | |
for ((key, value) in entries) { | |
resValue("string", key, value) | |
} | |
} | |
fun RepositoryHandler.maven( | |
url: String, | |
name: String? = null, | |
username: String? = null, | |
password: String? = null, | |
configure: RepositoryHandler.() -> Unit = {} | |
) { | |
this.maven { | |
setUrl(url) | |
if (name != null) setName(name) | |
if (username != null && password != null) { | |
credentials { | |
setUsername(username) | |
setPassword(password) | |
} | |
} | |
configure() | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment