I am a Mobile Full Stack Developer with 2 years of experience with expertise in Native Android and Spring Boot.
5abhisheksaxena / print-me-android Goto Github PK
View Code? Open in Web Editor NEWLicense: Apache License 2.0
License: Apache License 2.0
I am a Mobile Full Stack Developer with 2 years of experience with expertise in Native Android and Spring Boot.
Steps to integrate Detekt
build.gradle
.plugins {
...
id 'io.gitlab.arturbosch.detekt' version "$detektVersion" // 1.19.0-RC2
}
buildscripts/detekt.gradle
and enter the configuraton for deket plugin.apply plugin: "io.gitlab.arturbosch.detekt"
detekt {
config = files("${rootProject.projectDir}/config/detekt/detekt.yml")
reports {
html.enabled = true
xml.enabled = true
txt.enabled = true
}
}
build.gradle
file.subprojects {
...
apply from: "../buildscripts/detekt.gradle"
}
<ProjectName>Tasks>verification>detektGenerateConfig
./gradlew detektGenerateConfig
to generate the default detekt configuration.config/detekt/detekkt.yml
)Add additional configurations
style:
UnusedPrivateMember:
... // other properties
ignoreAnnotated: ['Preview']
MagicNumber:
... // other properties
ignoreAnnotated: ['Preview']
naming:
FunctionNaming:
... // other properties
ignoreAnnotated: ['Composable'] // new
In Color.kt
add @file:Suppress("MagicNumber")
on the top the file.
For Hilt,
style:
UnnecessaryAbstractClass:
... // other properties
ignoreAnnotated: ['Module'] // new
Optional
@Suppress("UnusedPrivateMember", "MagicNumber")
to Composae Previews.Use the Github website to create/edit Github Actions, it comes with a great UI and even better autocomplete.
Steps to add github actions.
.github/workflows/
..github/workflows/android_build.yml
name: Android Build
on: push
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Set Up JDK
uses: actions/setup-java@v1
with:
java-version: 1.11
- name: Change wrapper permissions
run: chmod +x ./gradlew
- name: Build Project
run: ./gradlew assemble
- name: Run Tests
run: ./gradlew test
.github/workflows/android_ui_test.yml
name: Android UI Tests
on: pull_request
jobs:
android-test:
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set Up JDK
uses: actions/setup-java@v1
with:
java-version: 1.11
- name: Change wrapper persmissions
run: chmod +x ./gradlew
- name: Run Tests
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 29
script: ./gradlew app:connectedCheck
The danger check Github Action is failing because of the deprecated Ruby Action which is used in the process.
Possible Fix
Update the Ruby sub-action version.
Integrate Compose Destination library
HTTP FAILED: java.net.SocketTimeoutException
- thrown when the app is unable to connect to the server. One of the reasons could be that the server is down.
HTTP FAILED: java.net.ConnectException
- thrown when the app is unable to connect to the server. One of the reasons could be that there is no internet available on the device.
Steps to add Danger.
.github/workflows/danger_checks.yml
)name: Danger Checks
on: pull_request
jobs:
danger:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Set Up JDK
uses: actions/setup-java@v1
with:
java-version: 1.11
- name: Set Up Ruby
uses: actions/setup-ruby@v1
with:
ruby-version: 2.6
- name: Danger Checks
run: |
gem install bundler
bundle install
bundle exec danger
env:
DANGER_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Dangerfile
in the root directory.message "Thanks @#{github.pr_author}!"
if github.pr_body.length == 0
fail "Please provide a summary in the Pull Request description."
end
if git.lines_of_code > 500
warn "Please consider breaking up this pull request."
end
if github.pr_labels.empty?
warn "Please add labels to this PR."
end
if git.deletions > git.insertions
message "๐ Code Cleanup!"
end
Gemfile
in the root directory.source "https://rubygems.org"
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
gem "danger"
Optional
You can also print out the list of outdated dependencies on the PR with the help of danger.
Steps to add dependency version check plugin by Ben Manes: https://github.com/ben-manes/gradle-versions-plugin
build.gradle
plugins {
id "com.github.ben-manes.versions" version "$versionsPluginVersion" // 0.29.0
}
buildscripts/versionsplugin.gradle
and enter the configuration for versions plugin.apply plugin: "com.github.ben-manes.versions"
def isNonStable = { String version ->
def stableKeyword = ['RELEASE', 'FINAL', 'GA'].any { it -> version.toUpperCase().contains(it) }
def regex = /^[0-9,.v-]+(-r)?$/
return !stableKeyword && !(version ==~ regex)
}
tasks.named("dependencyUpdates").configure {
rejectVersionIf {
isNonStable(it.candidate.version)
}
gradleReleaseChannel = "current"
}
subprojects {
.... // other gradle scripts
apply from: "../buildscripts/versionsplugin.gradle"
}
./gradlew dependencyUpdates
.Dangerfile
to print the output of ./gradlew dependencyUpdates
# Notify of outdated dependencies
dependencyReportsFile = "app/build/dependencyUpdates/report.txt"
dependencyUpdatesHeader = "The following dependencies have later milestone versions:"
hasDependencyUpdatesHeader = File.readlines(dependencyReportsFile).grep(/#{dependencyUpdatesHeader}/).any?
if hasDependencyUpdatesHeader
file = File.open(dependencyReportsFile, "rb").read
index = file.index(dependencyUpdatesHeader)
message file.slice(index..-1)
end
ii. Execute the task in the github actions - Danger Checks
name: Danger Checks
on: pull_request
jobs:
danger:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Set Up JDK
uses: actions/setup-java@v1
with:
java-version: 1.11
- name: Set Up Ruby
uses: actions/setup-ruby@v1
with:
ruby-version: 2.6
- name: Change wrapper permissions // new
run: chmod +x ./gradlew
- name: Danger Checks
run: |
./gradlew dependencyUpdates // new
gem install bundler
bundle install
bundle exec danger
env:
DANGER_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Move all the dependency versions to a centralized location.
Steps to centralize dependency versions.
buildsripts/versions.gradle
file for module dependencies(example: app/build.gradle)ext { // don't forget this ext otherwise it won't work
versions = [
// implementation
// https://developer.android.com/jetpack/androidx/releases/core
ktxCore : "1.7.0",
// https://developer.android.com/jetpack/androidx/releases/lifecycle
lifeycle : "2.4.1",
// testing
// https://developer.android.com/jetpack/androidx/releases/test
androidxTestJunit : "1.1.3",
// https://developer.android.com/jetpack/androidx/releases/test
espresso : "3.4.0",
// https://github.com/junit-team/junit4/releases
junit : "4.13.2",
]
}
dependencies {
implementation "androidx.core:core-ktx:$rootProject.ext.versions.ktxCore"
implementation "androidx.lifecycle:lifecycle-runtime-ktx:$rootProject.ext.versions.lifeycle"
testImplementation "junit:junit:$rootProject.ext.versions.junit"
androidTestImplementation "androidx.test.ext:junit:$rootProject.ext.versions.androidxTestJunit"
androidTestImplementation "androidx.test.espresso:espresso-core:$rootProject.ext.versions.espresso"
}
build.gradle
file together.buildscript {
ext {
// URL for the github releases
kotlinVersion = '1.6.10'
.... // other versions
}
}// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '7.2.1' apply false
id 'com.android.library' version '7.2.1' apply false
id 'org.jetbrains.kotlin.android' version "$kotlinVersion" apply false
.... // other plugins
}
versions.gradle
to the project level build.gradle
file.buildscript {
ext {
.... // project level gradle file dependency versions.
}
}// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
.... // plugins
}
apply from: "buildscripts/versions.gradle" // added here
subprojects {
.... // subproject gradle scripts
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Steps to integrate ktlint
build.gradle
.plugins {
...
// https://github.com/JLLeitschuh/ktlint-gradle/releases
id "org.jlleitschuh.gradle.ktlint" version "$ktlintPluginVersion" // 10.2.0
}
buildscripts/ktlint.gradle
and enter the configuraton for deket plugin.apply plugin: "org.jlleitschuh.gradle.ktlint"
ktlint {
// https://github.com/pinterest/ktlint/releases
version = "0.45.2"
reporters {
reporter "plain"
reporter "checkstyle"
reporter "html"
}
outputColorName = "RED"
}
build.gradle
file.subprojects {
...
apply from: "../buildscripts/ktlint.gradle"
}
<ProjectName>Tasks>formatting>ktlintFormat
or ./gradlew ktlintFormat
to format the whole project.<ProjectName>Tasks>verification>ktlintCheck
or ./gradlew ktlintCheck
to check for lint issues in the whole project.Tip: Run them together as ./gradlew clean build ktlintFormat ktlintCheck
.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.