Skip to content

Instantly share code, notes, and snippets.

@laithnurie
laithnurie / gradle
Last active October 20, 2023 09:23
One Jacoco task for one single report for multiple gradle sub modules
apply plugin: 'jacoco'
jacoco {
toolVersion = "0.8.8"
}
task jacocoTestReport(type: JacocoReport, dependsOn: ['testDebugUnitTest', 'createDebugCoverageReport']) {
group "Reporting"
description "Generate Jacoco coverage reports."
@laithnurie
laithnurie / jacoco.gradle
Created November 5, 2022 12:53
Jacoco Mini
apply plugin: 'jacoco'
task jacocoUnitTestReport(type: JacocoReport, dependsOn: ['testAppDebugUnitTest']) {
reports {
xml.enabled true
html.enabled true
}
def fileFilter = ['**/R.class', '**/R$*.class', '**/BuildConfig.*', '**/Manifest*.*', '**/*Test*.*', 'android/**/*.*']
@laithnurie
laithnurie / LocalServer.kt
Created November 4, 2022 07:45
Local ktor server
object LocalServer {
private var server: CIOApplicationEngine? = null
fun start() {
val assets = InstrumentationRegistry.getInstrumentation().context.assets
server?.stop()
server = embeddedServer(CIO, port = 8080) {
routing {
get("api/path/here") {
@laithnurie
laithnurie / library-proguard.pro
Created September 19, 2022 15:27
library proguard
#
# This ProGuard configuration file illustrates how to process a program
# library, such that it remains usable as a library.
# Usage:
# java -jar proguard.jar @library.pro
#
# Specify the input jars, output jars, and library jars.
# In this case, the input jar is the program library that we want to process.
apply plugin: 'maven-publish'
// SDK version is passed in as a parameter when you run the script assemble_and_deploy_lib.sh or you can uncomment the below and use the version from gradle.properties
// version SDK_ARTIFACT_VERSION // version picked up from gradle.properties
String sdkVersion = System.getenv('SDK_VERSION') != null ? System.getenv('SDK_VERSION') : SDK_ARTIFACT_VERSION
publishing {
publications {
sdk(MavenPublication) {
@laithnurie
laithnurie / dependency-upgrade
Created September 16, 2022 15:59
Version catalog android
def isNonStable = { String version ->
def stableKeyword = ['RELEASE', 'FINAL', 'GA'].any { it -> version.toUpperCase().contains(it) }
def regex = /^[0-9,.v-]+$/
return !stableKeyword && !(version ==~ regex)
}
dependencyUpdates {
resolutionStrategy {
componentSelection {
all {
@laithnurie
laithnurie / detekt.gradle
Created August 18, 2022 15:07
Detekt gradle methods
tasks.register('detektFix', io.gitlab.arturbosch.detekt.Detekt) {
description = "Runs over whole code base without the starting overhead for each module."
autoCorrect = true
parallel = true
setSource(files(projectDir))
include("**/*.kt")
include("**/*.kts")
exclude("**/resources/**")
exclude("**/build/**")
exclude("**/test/**/*.kt")
#!/bin/sh
filesToFormat="$(
git --no-pager diff --cached --diff-filter=d --name-only
)"
echo '[git hook] executing gradle detekt and lint before push'
SHOULD_RESET=0
if [[ -n $(git status -s) ]]; then
@laithnurie
laithnurie / detekt.yml
Created August 17, 2022 14:02
Detekt rules
build:
maxIssues: 0
excludeCorrectable: false
weights:
# complexity: 2
# LongParameterList: 1
# style: 1
# comments: 1
config:
@laithnurie
laithnurie / emulator-install-using-avdmanager.md
Created August 11, 2022 16:42 — forked from mrk-han/emulator-install-using-avdmanager.md
Installing and creating Emulators with AVDMANAGER (For Continuous Integration Server or Local Use)

Install and Create Emulators using AVDMANAGER and SDKMANAGER

TL;DR

For generic skin emulator with default apis (without google apis):

  1. List All System Images Available for Download: sdkmanager --list | grep system-images

  2. Download Image: sdkmanager --install "system-images;android-29;default;x86"