Skip to content

Instantly share code, notes, and snippets.

View xinthink's full-sized avatar

Yingxin Wu xinthink

View GitHub Profile
@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 / 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 / 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 / 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}”,
dependencies {
compile(deps["support.appCompat"])
compile(deps["support"]["design"])
compile(deps["picasso"])
}
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")
}
@xinthink
xinthink / README-kotlin-dsl-deps-ext-intro.md
Last active January 21, 2020 06:04
Defining Dependencies in Gradle Kotlin DSL

This's for the article Defining Dependencies in Gradle Kotlin DSL.

If you're using [kotlin-dsl] in a multi-project manner, you may want to define all the dependencies in one place. You can put the files into buildSrc, define dependencies in a compat way like this:

extra.deps {
    "kt"("stdlib-jre7")
    "auto" {
        "common"("com.google.auto:auto-common:0.8")
        "service"("com.google.auto.service:auto-service:1.0-rc3")
@xinthink
xinthink / codeship_android_build.sh
Created October 8, 2015 02:34 — forked from PuKoren/codeship_android_build.sh
Codeship Android build script
cd /tmp
pwd
#Download Android SDK from Google and unzip it
wget http://dl.google.com/android/android-sdk_r24.1.2-linux.tgz
tar zxvf android-sdk_r24.1.2-linux.tgz
rm android-sdk_r24.1.2-linux.tgz
#Set extracted SDK location to $PATH so we can use commands
export ANDROID_HOME="/tmp/android-sdk-linux"
export PATH="$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools:$PATH"
@xinthink
xinthink / slack-on-repo-starred.js
Last active August 29, 2015 14:26
A LeanEngine function that sends a Slack notification when the given GitHub repo got starred.
// parameters of the function
var repo = request.params.repo; // 'user_or_org/repo_name'
var slackWebhook = request.params.slackWebhook; // e.g. 'https://hooks.slack.com/services/XXX'
var repoUrl = 'https://api.github.com/repos/' + repo;
// Set the following names to match your own scheme
var className = 'RepoStars'; // LeanCloud class for storing repo stars
var fieldRepo = 'repo'; // LeanCloud field to store the repo name
var fieldStars = 'count'; // LeanCloud field to store the count of stars
@xinthink
xinthink / gradle-script-using-ig-json-parser.gradle
Last active July 4, 2016 19:47
Using ig-json-parser in android studio gradle build script.
apply plugin: 'com.android.library'
ext {
generatedSourcesDir = file 'gen/main/java'
}
android {
compileSdkVersion XX
buildToolsVersion "XX"