Skip to content

Instantly share code, notes, and snippets.

View xinthink's full-sized avatar

Yingxin Wu xinthink

View GitHub Profile
extra.deps {
"support" {
"appCompat"("com.android.support:appcompat-v7:26.0.2")
"design"("com.android.support:design:26.0.2")
}
"picasso"("com.squareup.picasso:picasso:2.5.2")
}
dependencies {
compile(deps["support.appCompat"])
compile(deps["support"]["design"])
compile(deps["picasso"])
}
@xinthink
xinthink / root-build.gradle
Last active November 14, 2017 13:52
Reusable dependencies definition in Groovy
// global definition in root project
ext.versions = [
compileSdk: 26,
targetSdk: 25,
]
ext.deps = [
support: [
appCompat: “com.android.support:appcompat-v7:${versions.supportLibrary}”,
design: “com.android.support:design:${versions.supportLibrary}”,
@xinthink
xinthink / ext-access.build.kts
Created November 15, 2017 01:17
Accessing extra properties in Kotlin DSL
// Declarations
ext["deps"] = mapOf(
"support" to mapOf(
"appCompat" to "com.android.support:appcompat-v7:26.0.2",
"design" to "com.android.support:design:26.0.2"
),
"picasso" to "com.squareup.picasso:picasso:2.5.2"
)
// References
@xinthink
xinthink / dep-models.kt
Created November 15, 2017 01:23
Dependency modeling
interface DependencyItem
data class DependencyNotation(val notation: String) : DependencyItem
class DependencyGroup : DependencyItem {
val dependencies: Map<String, DependencyItem>
}
@xinthink
xinthink / dep-operators.kt
Created November 15, 2017 01:26
Dependency group operators definition
class DependencyGroup {
// provides the `.``[]` operators
operator fun get(key: String): DependencyItem
// provides the `<key>(<notation>)` syntax
operator fun String.invoke(notation: String)
// provides the `<key> {<group>}` syntax
operator fun String.invoke(init: DependencyGroup.() -> Unit)
}
@xinthink
xinthink / deps-ext.kt
Created November 15, 2017 01:42
Hook dependencies extension to ExtraProperties
val ExtraPropertiesExtension.deps: DependencyGroup
get() =
if (has("deps")) this["deps"] as DependencyGroup
else DependencyGroup().apply {
this@deps["deps"] = this
}
@xinthink
xinthink / build.gradle
Created September 5, 2018 10:16 — forked from gpeal/build.gradle
Airbnb Gradle Flavors
...
apply from: './flavors.gradle'
...
android {
buildTypes {
productFlavors {
project.flavors.each { flavor, config ->
"$flavor" {
dimension 'scope'
if (flavor != 'full') {
@xinthink
xinthink / phases.csv
Last active November 7, 2019 04:54
medium-custom-github-actions
Branch/Tag Desc Development Distribution
master where we commit changes
releases/v{version} release candidates e.g. releases/v1.0
v{version} tags referred from workflows e.g. v1.0
@xinthink
xinthink / main.ts
Last active November 6, 2019 13:47
medium-custom-github-actions main.ts
import * as core from '@actions/core';
import { context } from '@actions/github';
import * as request from 'request-promise-native';
(async function run() {
try {
const botToken = core.getInput('botToken');
const chatId = core.getInput('chatId');
const jobStatus = core.getInput('jobStatus');
const skipSuccess = (core.getInput('skipSuccess') || 'true') === 'true';