Skip to content

Instantly share code, notes, and snippets.

View Galaxer's full-sized avatar

Chris Cook Galaxer

View GitHub Profile
@Galaxer
Galaxer / TestTag.kt
Created November 20, 2022 16:15
Android compose hierarchical test tags
// Test tag interface
interface TestTag {
val name: String
val pathBuilder: Builder
fun updatePathBuilder(builder: Builder? = null): Builder {
return builder?.append(name) ?: Builder().append(name)
}
@Galaxer
Galaxer / gradle-s3-maven-repo.gradle
Last active October 3, 2018 14:39
Use maven publishing gradle plugin to publish an aar to an s3 bucket.
publishing {
repositories {
maven {
url "s3://bucket_name"
credentials(AwsCredentials) {
accessKey ""
secretKey ""
}
}
@Galaxer
Galaxer / set-res-dirs.gradle
Created April 1, 2018 03:07
Use Gradle to dynamically set Android resource directories based on folders named "res" inside a given directory.
/**
* Get an array of directory paths that should be used as resource directories
* @return Array of directory paths
*/
ext.getResourceDirectories = { String rootDirectory ->
def resourceDirectories = []
def resourceDirectoryName = "res"
new File(rootDirectory).eachDirRecurse { directory ->
if (directory.getName() == resourceDirectoryName) {
@Galaxer
Galaxer / project-iterator.gradle
Created March 30, 2018 14:07
Iterate through all android project modules using gradle
def projectQueue = [rootProject] as Queue
while (!projectQueue.isEmpty()) {
def queueProject = projectQueue.poll()
println queueProject.projectDir
queueProject.childProjects.each { name, childProject ->
projectQueue.add(childProject)
}
}
@Galaxer
Galaxer / ImportIfExists.kt
Last active March 16, 2018 13:45
Kotlin extension to import a Kodein module only if it exists
/**
* Import a Kodein module if it exists. We're not catching any exceptions in this method so it will
* fail fast. If a Kodein module doesn't import, the app will probably crash soon after this method
* executes anyway. If the app crashes here, it will be easier to debug.
*/
fun Kodein.Builder.importIfExists(qualifiedClassName: String, fieldName: String) {
val moduleClass = Class.forName(qualifiedClassName)
val moduleField = moduleClass.declaredFields.find { field ->
field.name == fieldName
}