├── .editorconfig
├── .github
├── .java-version
├── actions
│ └── workflow_setup
│ │ └── action.yml
├── pull_request_template.md
└── workflows
│ ├── android_build.yml
│ ├── android_ui_tests.yml
│ ├── danger_checks.yml
│ ├── install_git_hooks_macos.yml
│ ├── install_git_hooks_windows.yml
│ └── template_change_test.yml
├── .gitignore
├── Dangerfile.df.kts
├── README.md
├── app
├── .gitignore
├── build.gradle.kts
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── template
│ │ ├── MainActivity.kt
│ │ ├── TemplateApp.kt
│ │ └── theme
│ │ ├── Color.kt
│ │ ├── Shape.kt
│ │ ├── Theme.kt
│ │ └── Type.kt
│ └── res
│ ├── drawable-v24
│ └── ic_launcher_foreground.xml
│ ├── drawable
│ └── ic_launcher_background.xml
│ ├── mipmap-anydpi-v26
│ ├── ic_launcher.xml
│ └── ic_launcher_round.xml
│ ├── mipmap-hdpi
│ ├── ic_launcher.webp
│ └── ic_launcher_round.webp
│ ├── mipmap-mdpi
│ ├── ic_launcher.webp
│ └── ic_launcher_round.webp
│ ├── mipmap-xhdpi
│ ├── ic_launcher.webp
│ └── ic_launcher_round.webp
│ ├── mipmap-xxhdpi
│ ├── ic_launcher.webp
│ └── ic_launcher_round.webp
│ ├── mipmap-xxxhdpi
│ ├── ic_launcher.webp
│ └── ic_launcher_round.webp
│ ├── values-night
│ └── themes.xml
│ └── values
│ ├── colors.xml
│ ├── strings.xml
│ └── themes.xml
├── build.gradle.kts
├── buildscripts
├── githooks.gradle
├── setup.gradle
└── versionsplugin.gradle
├── config
└── detekt
│ └── detekt.yml
├── documentation
├── GitHooks.md
├── GitHubActions.md
├── StaticAnalysis.md
└── VersionsPlugin.md
├── git-hooks
├── pre-commit-macos.sh
├── pre-commit-windows.sh
├── pre-push-macos.sh
└── pre-push-windows.sh
├── gradle.properties
├── gradle
├── libs.versions.toml
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── renovate.json5
└── settings.gradle.kts
/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*.{kt,kts}]
4 | max_line_length = 140
5 | indent_size = 4
6 | insert_final_newline = true
7 | ij_kotlin_allow_trailing_comma = true
8 | ij_kotlin_allow_trailing_comma_on_call_site = true
9 | ktlint_function_naming_ignore_when_annotated_with = Composable
10 | # 2 is the default, but setting it to 1 forces all params on a multiline no matter what.
11 | ktlint_function_signature_rule_force_multiline_when_parameter_count_greater_or_equal_than = 2
12 | ktlint_standard_multiline-expression-wrapping = disabled
13 | ktlint_standard_string-template-indent = disabled
14 |
--------------------------------------------------------------------------------
/.github/.java-version:
--------------------------------------------------------------------------------
1 | 23
2 |
--------------------------------------------------------------------------------
/.github/actions/workflow_setup/action.yml:
--------------------------------------------------------------------------------
1 | name: "Workflow Setup"
2 |
3 | description: "Common setup across multiple workflows."
4 |
5 | runs:
6 | using: "composite"
7 |
8 | steps:
9 | - name: Set Up JDK
10 | uses: actions/setup-java@v4
11 | with:
12 | distribution: 'zulu'
13 | java-version-file: .github/.java-version
14 |
15 | - name: Setup Gradle
16 | uses: gradle/gradle-build-action@v3
17 | with:
18 | # Only write to the cache for builds on the 'development' branch
19 | cache-read-only: ${{ github.ref != 'refs/heads/development' }}
--------------------------------------------------------------------------------
/.github/pull_request_template.md:
--------------------------------------------------------------------------------
1 | ## Summary
2 |
3 |
4 |
5 | ## How It Was Tested
6 |
7 |
8 |
9 | ## Screenshot/Gif
10 |
11 |
12 |
13 |
14 |
15 | Screenshot Name
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/.github/workflows/android_build.yml:
--------------------------------------------------------------------------------
1 | name: Android Build
2 |
3 | # This will cancel any in progress workflows for the same PR, if
4 | # multiple pushes happen in quick succession.
5 | concurrency:
6 | group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
7 | cancel-in-progress: true
8 |
9 | on:
10 | push:
11 | branches:
12 | - development
13 | pull_request:
14 |
15 | jobs:
16 | build:
17 | runs-on: macos-14
18 | steps:
19 | - uses: actions/checkout@v4
20 |
21 | - name: Setup
22 | uses: ./.github/actions/workflow_setup
23 |
24 | - name: Build Project
25 | run: ./gradlew assemble
26 |
27 | - name: Run Tests
28 | run: ./gradlew test
29 |
30 | - name: Lint Checks
31 | run: ./gradlew detektAll lintKotlin lint
32 |
33 | - name: Dependency Sort Checks
34 | run: ./gradlew checkSortDependencies
--------------------------------------------------------------------------------
/.github/workflows/android_ui_tests.yml:
--------------------------------------------------------------------------------
1 | name: Android UI Tests
2 |
3 | # This will cancel any in progress workflows for the same PR, if
4 | # multiple pushes happen in quick succession.
5 | concurrency:
6 | group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
7 | cancel-in-progress: true
8 |
9 | on:
10 | pull_request:
11 |
12 | jobs:
13 | android-test:
14 | # At this moment in time, the emulator runner
15 | # does not work on macos-14: https://github.com/ReactiveCircus/android-emulator-runner/issues/392#issuecomment-2106167725
16 | runs-on: macos-13
17 | steps:
18 | - name: Checkout
19 | uses: actions/checkout@v4
20 |
21 | - name: Setup
22 | uses: ./.github/actions/workflow_setup
23 |
24 | - name: Run Tests
25 | uses: reactivecircus/android-emulator-runner@v2
26 | with:
27 | api-level: 29
28 | script: ./gradlew app:connectedCheck
--------------------------------------------------------------------------------
/.github/workflows/danger_checks.yml:
--------------------------------------------------------------------------------
1 | name: Danger Checks
2 |
3 | # This will cancel any in progress workflows for the same PR, if
4 | # multiple pushes happen in quick succession.
5 | concurrency:
6 | group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
7 | cancel-in-progress: true
8 |
9 | on: pull_request
10 |
11 | jobs:
12 | danger:
13 | runs-on: ubuntu-latest
14 | steps:
15 | - name: Checkout
16 | uses: actions/checkout@v4
17 |
18 | - name: Setup
19 | uses: ./.github/actions/workflow_setup
20 |
21 | - name: Dependency Updates
22 | run: ./gradlew dependencyUpdates
23 |
24 | - name: Danger Checks
25 | uses: danger/kotlin@1.3.3
26 | env:
27 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
28 |
--------------------------------------------------------------------------------
/.github/workflows/install_git_hooks_macos.yml:
--------------------------------------------------------------------------------
1 | # THIS ACTION IS FOR VALIDATION WITHIN TEMPLATE REPO, AND WILL BE
2 | # REMOVED UPON RUNNING RENAMETEMPLATE GRADLE TASK.
3 |
4 | name: Install MacOS Hooks
5 |
6 | # This will cancel any in progress workflows for the same PR, if
7 | # multiple pushes happen in quick succession.
8 | concurrency:
9 | group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
10 | cancel-in-progress: true
11 |
12 | on: pull_request
13 |
14 | jobs:
15 | install-macos-hooks:
16 | runs-on: macos-14
17 | steps:
18 | - uses: actions/checkout@v4
19 |
20 | - name: Setup
21 | uses: ./.github/actions/workflow_setup
22 |
23 | - name: Install
24 | run: ./gradlew installGitHooks
25 |
26 | - name: Check Pre-Commit File
27 | uses: GuillaumeFalourd/assert-command-line-output@v2.4
28 | with:
29 | command_line: cat .git/hooks/pre-commit
30 | assert_file_path: git-hooks/pre-commit-macos.sh
31 | expected_result: PASSED
32 |
33 | - name: Check Pre-Push File
34 | uses: GuillaumeFalourd/assert-command-line-output@v2.4
35 | with:
36 | command_line: cat .git/hooks/pre-push
37 | assert_file_path: git-hooks/pre-push-macos.sh
38 | expected_result: PASSED
39 |
--------------------------------------------------------------------------------
/.github/workflows/install_git_hooks_windows.yml:
--------------------------------------------------------------------------------
1 | # THIS ACTION IS FOR VALIDATION WITHIN TEMPLATE REPO, AND WILL BE
2 | # REMOVED UPON RUNNING RENAMETEMPLATE GRADLE TASK.
3 |
4 | name: Install Windows Hooks
5 |
6 | # This will cancel any in progress workflows for the same PR, if
7 | # multiple pushes happen in quick succession.
8 | concurrency:
9 | group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
10 | cancel-in-progress: true
11 |
12 | on: pull_request
13 |
14 | jobs:
15 | install-windows-hooks:
16 | runs-on: windows-latest
17 | steps:
18 | - uses: actions/checkout@v4
19 |
20 | - name: Setup
21 | uses: ./.github/actions/workflow_setup
22 |
23 | - name: Install
24 | run: ./gradlew installGitHooks
25 |
26 | - name: Check Pre-Commit File
27 | uses: GuillaumeFalourd/assert-command-line-output@v2.4
28 | with:
29 | command_line: cat .git/hooks/pre-commit
30 | assert_file_path: git-hooks/pre-commit-windows.sh
31 | expected_result: PASSED
32 |
33 | - name: Check Pre-Push File
34 | uses: GuillaumeFalourd/assert-command-line-output@v2.4
35 | with:
36 | command_line: cat .git/hooks/pre-push
37 | assert_file_path: git-hooks/pre-push-windows.sh
38 | expected_result: PASSED
39 |
--------------------------------------------------------------------------------
/.github/workflows/template_change_test.yml:
--------------------------------------------------------------------------------
1 | # THIS ACTION IS FOR VALIDATION WITHIN TEMPLATE REPO, AND WILL BE
2 | # REMOVED UPON RUNNING RENAMETEMPLATE GRADLE TASK.
3 |
4 | name: Rename Template
5 |
6 | # This will cancel any in progress workflows for the same PR, if
7 | # multiple pushes happen in quick succession.
8 | concurrency:
9 | group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
10 | cancel-in-progress: true
11 |
12 | on: pull_request
13 |
14 | jobs:
15 | rename-template:
16 | strategy:
17 | matrix:
18 | keepCustomizableDependencies: [true, false]
19 | fail-fast: false
20 |
21 | runs-on: macos-14
22 | steps:
23 | - uses: actions/checkout@v4
24 |
25 | - name: Setup
26 | uses: ./.github/actions/workflow_setup
27 |
28 | - name: Set useHiltDependencies
29 | run: |
30 | sed -i '' 's/useHiltDependencies.* : true/useHiltDependencies : ${{ matrix.keepCustomizableDependencies }}/g' buildscripts/setup.gradle
31 |
32 | - name: Set useRoomDependencies
33 | run: |
34 | sed -i '' 's/useRoomDependencies.* : true/useRoomDependencies : ${{ matrix.keepCustomizableDependencies }}/g' buildscripts/setup.gradle
35 |
36 | - name: Set useRetrofitDependencies
37 | run: |
38 | sed -i '' 's/useRetrofitDependencies.* : true/useRetrofitDependencies : ${{ matrix.keepCustomizableDependencies }}/g' buildscripts/setup.gradle
39 |
40 | - name: Set usePaparazziDependencies
41 | run: |
42 | sed -i '' 's/usePaparazziDependencies.* : true/usePaparazziDependencies : ${{ matrix.keepCustomizableDependencies }}/g' buildscripts/setup.gradle
43 |
44 | - name: Set useRenovateDependencies
45 | run: |
46 | sed -i '' 's/useRenovateDependencies.* : true/useRenovateDependencies : ${{ matrix.keepCustomizableDependencies }}/g' buildscripts/setup.gradle
47 |
48 | - name: Set useAndroidXR
49 | run: |
50 | sed -i '' 's/useAndroidXR.* : false/useAndroidXR : ${{ matrix.keepCustomizableDependencies }}/g' buildscripts/setup.gradle
51 |
52 | - name: Rename
53 | run: ./gradlew renameTemplate
54 |
55 | - name: Lint Checks
56 | run: ./gradlew detektAll lintKotlin lint
57 |
58 | - name: Build
59 | run: ./gradlew assembleDebug
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/
5 | .DS_Store
6 | /build
7 | /captures
8 | .externalNativeBuild
9 | .cxx
10 | local.properties
11 | .kotlin/
12 |
--------------------------------------------------------------------------------
/Dangerfile.df.kts:
--------------------------------------------------------------------------------
1 | @file:Suppress("MagicNumber", "WildcardImport", "ForbiddenComment")
2 |
3 | // Editing this file: https://github.com/danger/kotlin?tab=readme-ov-file#autocomplete-and-syntax-highlighting-in-intellij-idea-or-android-studio
4 | import systems.danger.kotlin.*
5 | import java.io.File
6 |
7 | danger(args) {
8 |
9 | onGitHub {
10 | val additions = pullRequest.additions ?: 0
11 | val deletions = pullRequest.deletions ?: 0
12 |
13 | message("Thanks @${pullRequest.user.login}!")
14 |
15 | if (pullRequest.body.isNullOrBlank()) {
16 | fail("Please provide a summary in the Pull Request description.")
17 | }
18 |
19 | if (additions > 500) {
20 | warn("Please consider breaking up this pull request.")
21 | }
22 |
23 | if (issue.labels.isEmpty()) {
24 | warn("Please add labels to this PR.")
25 | }
26 |
27 | if (deletions > additions) {
28 | message("🎉 Code Cleanup!")
29 | }
30 |
31 | val updatesFile = File("build/dependencyUpdates/report.txt")
32 | val lines = updatesFile.readLines()
33 |
34 | val headerIndex = lines.indexOfFirst { line ->
35 | line.contains("The following dependencies have later milestone versions:")
36 | }
37 |
38 | if (headerIndex >= 0) {
39 | val message = lines.subList(headerIndex, lines.size).joinToString("\n")
40 | message(message)
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Android App Template
2 |
3 | This is a GitHub template repository intended to kickstart development on an Android application. This project comes set with a handful of tools that [Adam](https://github.com/AdamMc331) finds important and relevant to every project. If you think something is missing, or feel strongly that a setup should be changed, please submit an [Issue](https://github.com/AdamMc331/AndroidAppTemplate/issues/new).
4 |
5 | ## Why This Template?
6 |
7 | The purpose of this template is to avoid any opinions on writing code. The developers should have the freedom to choose their own architecture, third party dependencies, package structure, and more.
8 |
9 | This template _is_ opinionated about developer tooling. Dependency management is configured, git hooks are defined, code formatting and static analysis are all there, and it even has pull request templates. The purpose of this repo is to help you get started building your next project with confidence in your code, and not telling you how to write it.
10 |
11 | ## Walkthrough
12 |
13 | If you'd like a video walk through of this template and all it has to offer, you can find that on YouTube.
14 |
15 | https://youtu.be/E0iMUWJn76E
16 |
17 | ## Using This Template
18 |
19 | To use this template in your own project, click the "Use this template" button at the top right of the repository. Once you do, a repository will be created for your account that you can clone and use on your device.
20 |
21 | To setup this repository to your needs, open the [setup.gradle](buildscripts/setup.gradle) file
22 | and tweak the `renameConfig` block to your needs. After that, you can run the `renameTemplate`
23 | gradle task to have the app module's package name and relevant strings replaced.
24 |
25 | ### Cleanup
26 |
27 | After [this PR](https://github.com/AdamMc331/AndroidAppTemplate/pull/44), running the renameTemplate
28 | task should do all the necessary cleanup like deleting the setup file and test workflow so you can
29 | go ahead and commit the renamed files and be on your way. If you encounter any problems with the setup
30 | workflow, please report a new [issue](https://github.com/AdamMc331/AndroidAppTemplate/issues).
31 |
32 | ## What's Included
33 |
34 | A number of third party dependencies are included in this template. They are also documented inside the [documentation folder](/documentation). The files inside this documentation folder are written in such a way that you can keep them in your real project, to let team members read up on why dependencies are included and how they work.
35 |
36 | The dependencies in the template include:
37 |
38 | * [Ktlint](/documentation/StaticAnalysis.md) for formatting.
39 | * [Detekt](/documentation/StaticAnalysis.md) for code smells.
40 | * [Git Hooks](/documentation/GitHooks.md) for automatically perform static analysis checks.
41 | * [Gradle Versions Plugin](/documentation/VersionsPlugin.md) for checking all dependencies for new versions.
42 | * [GitHub Actions](/documentation/GitHubActions.md) for running continuous integration and ensuring code quality with every PR.
43 | * [LeakCanary](https://square.github.io/leakcanary/) for detecting memory leaks.
44 | * [Hilt](https://developer.android.com/training/dependency-injection/hilt-android) dependencies, which can be removed via setup.gradle if necessary.
45 | * [Room](https://developer.android.com/training/data-storage/room) dependencies, which can be removed via setup.gradle if necessary.
46 | * [Paparazzi](https://github.com/cashapp/paparazzi) dependncy, which can be removed via setup.gradle if necessary.
47 |
48 | ### Danger
49 |
50 | This template uses [Danger](https://danger.systems) which will perform some checks against our
51 | pull requests. You can find the list of checks in the [Dangerfile](Dangerfile.df.kts). In addition, we
52 | have a GitHub Actions workflow for Danger checks. In order for that to work properly, you'll
53 | need to give Danger permission to comment on your repository.
54 |
55 | You can do so by navigating to Repository Settings -> Actions -> General, scroll down to `Workflow Permissions`
56 | and set the permissions to read and write.
57 |
58 | ### Templates
59 |
60 | There are also templates within this template. This repo comes shipped with a [Pull Request Template](/.github/pull_request_template.md) that will help you and your team write organized and detailed pull request descriptions.
61 |
62 | ## Dependency Setup
63 |
64 | You may notice that dependencies are set up in a very specific way. Each of the tools has its own Gradle file in the [buildscripts folder](/buildscripts). This is by design so that if you chose to have a multi module project, these dependencies can easily be shared between them. This is already configured inside our root `build.gradle.kts` file, by applying to each sub project:
65 |
66 | ```groovy
67 | subprojects {
68 | apply from: "../buildscripts/detekt.gradle"
69 | apply from: "../buildscripts/versionsplugin.gradle"
70 | }
71 | ```
72 |
73 | In addition, all of the app module dependencies are defined using a gradle version catalog, found in this [toml](gradle/libs.versions.toml) file.
74 |
75 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/app/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | alias(libs.plugins.android.application)
3 | alias(libs.plugins.cash.paparazzi)
4 | alias(libs.plugins.compose.compiler)
5 | alias(libs.plugins.google.dagger.hilt)
6 | alias(libs.plugins.google.ksp)
7 | alias(libs.plugins.kotlin.android)
8 | alias(libs.plugins.kotlin.parcelize)
9 | }
10 |
11 | android {
12 | compileSdk = libs.versions.compileSdk.get().toInt()
13 |
14 | defaultConfig {
15 | applicationId = "template.app.id"
16 | minSdk = libs.versions.minSdk.get().toInt()
17 | targetSdk = libs.versions.compileSdk.get().toInt()
18 | versionCode = 1
19 | versionName = "1.0"
20 |
21 | testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
22 | vectorDrawables {
23 | useSupportLibrary = true
24 | }
25 | }
26 |
27 | buildTypes {
28 | release {
29 | isMinifyEnabled = false
30 | proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
31 | }
32 | }
33 |
34 | compileOptions {
35 | sourceCompatibility = JavaVersion.VERSION_17
36 | targetCompatibility = JavaVersion.VERSION_17
37 | }
38 |
39 | kotlinOptions {
40 | jvmTarget = "17"
41 | }
42 |
43 | buildFeatures {
44 | compose = true
45 | }
46 |
47 | packaging {
48 | resources {
49 | excludes += "/META-INF/{AL2.0,LGPL2.1}"
50 | }
51 | }
52 |
53 | namespace = "template"
54 | }
55 |
56 | dependencies {
57 | implementation(platform(libs.compose.bom))
58 | implementation(libs.android.material)
59 | implementation(libs.androidx.activity.compose)
60 | implementation(libs.androidx.appcompat)
61 | implementation(libs.androidx.core.ktx)
62 | implementation(libs.androidx.lifecycle.runtime.ktx)
63 | implementation(libs.androidx.room.runtime)
64 | implementation(libs.bundles.androidx.xr)
65 | implementation(libs.coil.compose)
66 | implementation(libs.coil.okhttp)
67 | implementation(libs.compose.material)
68 | implementation(libs.compose.material.icons.extended)
69 | implementation(libs.compose.navigation)
70 | implementation(libs.compose.ui)
71 | implementation(libs.compose.ui.tooling)
72 | implementation(libs.hilt.android)
73 | implementation(libs.hilt.navigation.compose)
74 | implementation(libs.square.moshi.kotlin)
75 | implementation(libs.square.okhttp.logging.interceptor)
76 | implementation(libs.square.retrofit)
77 | implementation(libs.square.retrofit.converter.moshi)
78 |
79 | debugImplementation(platform(libs.compose.bom))
80 | debugImplementation(libs.compose.ui.test.manifest)
81 | debugImplementation(libs.compose.ui.tooling)
82 | debugImplementation(libs.square.leakcanary)
83 |
84 | annotationProcessor(libs.androidx.room.compiler)
85 |
86 | testImplementation(libs.junit)
87 |
88 | androidTestImplementation(platform(libs.compose.bom))
89 | androidTestImplementation(libs.androidx.test.espresso.core)
90 | androidTestImplementation(libs.androidx.test.junit)
91 | androidTestImplementation(libs.compose.ui.test.junit)
92 | androidTestImplementation(libs.hilt.android.testing)
93 |
94 | ksp(libs.androidx.room.compiler)
95 | ksp(libs.hilt.compiler)
96 | ksp(libs.square.moshi.kotlin.codegen)
97 |
98 | kspAndroidTest(libs.hilt.android.compiler)
99 | }
100 |
101 | tasks.formatKotlinMain {
102 | exclude { it.file.path.contains("build/")}
103 | }
104 |
105 | tasks.lintKotlinMain {
106 | exclude { it.file.path.contains("build/")}
107 | }
108 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.kts.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
17 |
18 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/app/src/main/java/template/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package template
2 |
3 | import android.os.Bundle
4 | import androidx.activity.ComponentActivity
5 | import androidx.activity.compose.setContent
6 | import androidx.activity.enableEdgeToEdge
7 | import androidx.compose.material3.MaterialTheme
8 | import androidx.compose.material3.Surface
9 | import androidx.compose.material3.Text
10 | import androidx.compose.runtime.Composable
11 | import dagger.hilt.android.AndroidEntryPoint
12 | import template.theme.TemplateTheme
13 |
14 | @AndroidEntryPoint
15 | class MainActivity : ComponentActivity() {
16 | override fun onCreate(savedInstanceState: Bundle?) {
17 | super.onCreate(savedInstanceState)
18 |
19 | setContent {
20 | enableEdgeToEdge()
21 |
22 | TemplateTheme {
23 | Surface(
24 | color = MaterialTheme.colorScheme.background,
25 | ) {
26 | Greeting("Android")
27 | }
28 | }
29 | }
30 | }
31 | }
32 |
33 | @Composable
34 | fun Greeting(name: String) {
35 | Text(text = "Hello $name!")
36 | }
37 |
--------------------------------------------------------------------------------
/app/src/main/java/template/TemplateApp.kt:
--------------------------------------------------------------------------------
1 | package template
2 |
3 | import android.app.Application
4 | import dagger.hilt.android.HiltAndroidApp
5 |
6 | @HiltAndroidApp
7 | class TemplateApp : Application()
8 |
--------------------------------------------------------------------------------
/app/src/main/java/template/theme/Color.kt:
--------------------------------------------------------------------------------
1 | @file:Suppress("MagicNumber")
2 |
3 | package template.theme
4 |
5 | import androidx.compose.ui.graphics.Color
6 |
7 | val Purple200 = Color(0xFFBB86FC)
8 | val Purple500 = Color(0xFF6200EE)
9 | val Teal200 = Color(0xFF03DAC5)
10 |
--------------------------------------------------------------------------------
/app/src/main/java/template/theme/Shape.kt:
--------------------------------------------------------------------------------
1 | package template.theme
2 |
3 | import androidx.compose.foundation.shape.RoundedCornerShape
4 | import androidx.compose.material3.Shapes
5 | import androidx.compose.ui.unit.dp
6 |
7 | val Shapes = Shapes(
8 | small = RoundedCornerShape(4.dp),
9 | medium = RoundedCornerShape(4.dp),
10 | large = RoundedCornerShape(0.dp),
11 | )
12 |
--------------------------------------------------------------------------------
/app/src/main/java/template/theme/Theme.kt:
--------------------------------------------------------------------------------
1 | package template.theme
2 |
3 | import android.annotation.TargetApi
4 | import android.os.Build
5 | import androidx.compose.foundation.isSystemInDarkTheme
6 | import androidx.compose.material3.MaterialTheme
7 | import androidx.compose.material3.darkColorScheme
8 | import androidx.compose.material3.dynamicDarkColorScheme
9 | import androidx.compose.material3.dynamicLightColorScheme
10 | import androidx.compose.material3.lightColorScheme
11 | import androidx.compose.runtime.Composable
12 | import androidx.compose.ui.platform.LocalContext
13 |
14 | private val darkColorScheme = darkColorScheme(
15 | primary = Purple200,
16 | secondary = Teal200,
17 | )
18 |
19 | private val lightColorScheme = lightColorScheme(
20 | primary = Purple500,
21 | secondary = Teal200,
22 | )
23 |
24 | @Composable
25 | @TargetApi(Build.VERSION_CODES.S)
26 | fun TemplateTheme(
27 | darkTheme: Boolean = isSystemInDarkTheme(),
28 | dynamicTheme: Boolean = Build.VERSION.SDK_INT >= Build.VERSION_CODES.S,
29 | content: @Composable () -> Unit,
30 | ) {
31 | val colorScheme = when {
32 | dynamicTheme && darkTheme -> dynamicDarkColorScheme(LocalContext.current)
33 | dynamicTheme && !darkTheme -> dynamicLightColorScheme(LocalContext.current)
34 | darkTheme -> darkColorScheme
35 | else -> lightColorScheme
36 | }
37 |
38 | MaterialTheme(
39 | colorScheme = colorScheme,
40 | typography = Typography,
41 | shapes = Shapes,
42 | content = content,
43 | )
44 | }
45 |
--------------------------------------------------------------------------------
/app/src/main/java/template/theme/Type.kt:
--------------------------------------------------------------------------------
1 | package template.theme
2 |
3 | import androidx.compose.material3.Typography
4 | import androidx.compose.ui.text.TextStyle
5 | import androidx.compose.ui.text.font.FontFamily
6 | import androidx.compose.ui.text.font.FontWeight
7 | import androidx.compose.ui.unit.sp
8 |
9 | // Set of Material typography styles to start with
10 | val Typography = Typography(
11 | bodyMedium = TextStyle(
12 | fontFamily = FontFamily.Default,
13 | fontWeight = FontWeight.Normal,
14 | fontSize = 16.sp,
15 | ),
16 | )
17 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
15 |
18 |
21 |
22 |
23 |
24 |
30 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
15 |
20 |
25 |
30 |
35 |
40 |
45 |
50 |
55 |
60 |
65 |
70 |
75 |
80 |
85 |
90 |
95 |
100 |
105 |
110 |
115 |
120 |
125 |
130 |
135 |
140 |
145 |
150 |
155 |
160 |
165 |
170 |
171 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AdamMc331/AndroidAppTemplate/4381309db8f736a56863d8bc657949e83d69e27b/app/src/main/res/mipmap-hdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AdamMc331/AndroidAppTemplate/4381309db8f736a56863d8bc657949e83d69e27b/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AdamMc331/AndroidAppTemplate/4381309db8f736a56863d8bc657949e83d69e27b/app/src/main/res/mipmap-mdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AdamMc331/AndroidAppTemplate/4381309db8f736a56863d8bc657949e83d69e27b/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AdamMc331/AndroidAppTemplate/4381309db8f736a56863d8bc657949e83d69e27b/app/src/main/res/mipmap-xhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AdamMc331/AndroidAppTemplate/4381309db8f736a56863d8bc657949e83d69e27b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AdamMc331/AndroidAppTemplate/4381309db8f736a56863d8bc657949e83d69e27b/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AdamMc331/AndroidAppTemplate/4381309db8f736a56863d8bc657949e83d69e27b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AdamMc331/AndroidAppTemplate/4381309db8f736a56863d8bc657949e83d69e27b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AdamMc331/AndroidAppTemplate/4381309db8f736a56863d8bc657949e83d69e27b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/values-night/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
16 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #FFBB86FC
4 | #FF6200EE
5 | #FF3700B3
6 | #FF03DAC5
7 | #FF018786
8 | #FF000000
9 | #FFFFFFFF
10 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | template
3 |
--------------------------------------------------------------------------------
/app/src/main/res/values/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
16 |
17 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/build.gradle.kts:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | plugins {
4 | alias(libs.plugins.android.application).apply(false)
5 | alias(libs.plugins.benmanes.versions).apply(false)
6 | alias(libs.plugins.cash.paparazzi).apply(false)
7 | alias(libs.plugins.compose.compiler).apply(false)
8 | alias(libs.plugins.detekt).apply(true) // Needs to be applied at the root, unlike others.
9 | alias(libs.plugins.google.dagger.hilt).apply(false)
10 | alias(libs.plugins.google.ksp).apply(false)
11 | alias(libs.plugins.kotlin.android).apply(false)
12 | alias(libs.plugins.kotlin.parcelize).apply(false)
13 | alias(libs.plugins.kotlinter).apply(false)
14 | alias(libs.plugins.square.sort.dependencies).apply(false)
15 | }
16 |
17 | apply(from = "buildscripts/githooks.gradle")
18 | apply(from = "buildscripts/setup.gradle")
19 | apply(from = "buildscripts/versionsplugin.gradle")
20 |
21 | subprojects {
22 | apply(plugin = "io.gitlab.arturbosch.detekt")
23 | apply(plugin = "com.squareup.sort-dependencies")
24 | apply(plugin = "org.jmailen.kotlinter")
25 | }
26 |
27 | tasks.register("clean", Delete::class) {
28 | delete(rootProject.layout.buildDirectory)
29 | }
30 |
31 | afterEvaluate {
32 | // We install the hook at the first occasion
33 | tasks.named("clean") {
34 | dependsOn(":installGitHooks")
35 | }
36 | }
37 |
38 | tasks {
39 | /**
40 | * The detektAll tasks enables parallel usage for detekt so if this project
41 | * expands to multi module support, detekt can continue to run quickly.
42 | *
43 | * https://proandroiddev.com/how-to-use-detekt-in-a-multi-module-android-project-6781937fbef2
44 | */
45 | @Suppress("UnusedPrivateMember")
46 | val detektAll by registering(io.gitlab.arturbosch.detekt.Detekt::class) {
47 | parallel = true
48 | setSource(files(projectDir))
49 | include("**/*.kt")
50 | include("**/*.kts")
51 | exclude("**/resources/**")
52 | exclude("**/build/**")
53 | config.setFrom(files("$rootDir/config/detekt/detekt.yml"))
54 | buildUponDefaultConfig = true
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/buildscripts/githooks.gradle:
--------------------------------------------------------------------------------
1 | // https://emmanuelkehinde.io/setting-up-git-pre-commit-pre-push-hook-for-ktlint-check/
2 |
3 | import org.apache.tools.ant.taskdefs.condition.Os
4 |
5 | static def osSuffix() {
6 | def suffix = "macos"
7 | if (Os.isFamily(Os.FAMILY_WINDOWS)) {
8 | suffix = "windows"
9 | }
10 | return suffix
11 | }
12 |
13 | task copyPreCommitHook(type: Copy) {
14 | group 'git hooks'
15 |
16 | def suffix = osSuffix()
17 |
18 | from new File(rootProject.rootDir, "git-hooks/pre-commit-${suffix}.sh")
19 | into { new File(rootProject.rootDir, '.git/hooks') }
20 | rename("pre-commit-${suffix}.sh", 'pre-commit')
21 | fileMode 0775
22 | }
23 |
24 | task copyPrePushHook(type: Copy) {
25 | group 'git hooks'
26 |
27 | def suffix = osSuffix()
28 |
29 | from new File(rootProject.rootDir, "git-hooks/pre-push-${suffix}.sh")
30 | into { new File(rootProject.rootDir, '.git/hooks') }
31 | rename("pre-push-${suffix}.sh", 'pre-push')
32 | fileMode 0775
33 | }
34 |
35 | task copyGitHooks(type: Copy) {
36 | description 'Copies the git hooks from /git-hooks to the .git folder.'
37 | group 'git hooks'
38 |
39 | dependsOn copyPreCommitHook
40 | dependsOn copyPrePushHook
41 | }
42 |
43 | task installGitHooks(type: Exec) {
44 | description 'Installs the pre-commit git hooks from /git-hooks.'
45 | group 'git hooks'
46 | workingDir rootDir
47 | commandLine 'chmod'
48 | args '-R', '+x', '.git/hooks/'
49 | dependsOn copyGitHooks
50 | doLast {
51 | logger.info('Git hook installed successfully.')
52 | }
53 | }
--------------------------------------------------------------------------------
/buildscripts/setup.gradle:
--------------------------------------------------------------------------------
1 | def renameConfig = [
2 | templateName : "template",
3 | templateAppId : "template.app.id",
4 | templateMaterialThemeName : "TemplateTheme",
5 | templateApplicationClassName: "TemplateApp",
6 | newPackage : "aaa.yourname.app",
7 | newProjectName : "Your Project",
8 | newMaterialThemeName : "MyMaterialTheme",
9 | newApplicationClassName : "MyApp",
10 | useHiltDependencies : true,
11 | useRoomDependencies : true,
12 | useRetrofitDependencies : true,
13 | usePaparazziDependencies : true,
14 | useRenovateDependencies : true,
15 | useAndroidXR : false,
16 | ]
17 |
18 | task deleteSetupCode() {
19 | def workflowsFolder = "${rootDir}/.github/workflows"
20 | def buildscriptsFolder = "${rootDir}/buildscripts"
21 | def templateChangeWorkflowFile = "$workflowsFolder/template_change_test.yml"
22 | def macosHooksWorkflowFile = "$workflowsFolder/install_git_hooks_macos.yml"
23 | def windowsHooksWorkflowFile = "$workflowsFolder/install_git_hooks_windows.yml"
24 | def setupGradle = "$buildscriptsFolder/setup.gradle"
25 | def renovateFile = "${rootDir}/renovate.json5"
26 |
27 | doLast {
28 | removeTextFromFile("${rootDir}/build.gradle.kts", "setup.gradle")
29 | delete(templateChangeWorkflowFile)
30 | delete(macosHooksWorkflowFile)
31 | delete(windowsHooksWorkflowFile)
32 | delete(setupGradle)
33 |
34 | if (renameConfig.useRenovateDependencies != true) {
35 | println("Removing renovate dependencies")
36 | delete(renovateFile)
37 | }
38 | }
39 | }
40 |
41 | task renameAppPackage(type: Copy) {
42 | description "Renames the template package in the app module."
43 | group null
44 |
45 | def newPackageAsDirectory = renameConfig.newPackage.replaceAll("\\.", "/")
46 | def startingDirectory = "${rootDir}/app/src/main/java/${renameConfig.templateName}"
47 | def endingDirectory = "${rootDir}/app/src/main/java/${newPackageAsDirectory}"
48 |
49 | from(startingDirectory)
50 | into(endingDirectory)
51 |
52 | // Replace package statements
53 | filter { line ->
54 | line.replaceAll(
55 | "package ${renameConfig.templateName}",
56 | "package ${renameConfig.newPackage}"
57 | )
58 | }
59 |
60 | // Replace import statements
61 | filter { line ->
62 | line.replaceAll(
63 | "import ${renameConfig.templateName}",
64 | "import ${renameConfig.newPackage}"
65 | )
66 | }
67 |
68 | // Replace Theme references. We can just replace on name,
69 | // which covers both imports and function calls.
70 | filter { line ->
71 | line.replaceAll(
72 | "${renameConfig.templateMaterialThemeName}",
73 | "${renameConfig.newMaterialThemeName}"
74 | )
75 | }
76 |
77 | // Replace application class references
78 | filter { line ->
79 | line.replaceAll(
80 | "${renameConfig.templateApplicationClassName}",
81 | "${renameConfig.newApplicationClassName}",
82 | )
83 | }
84 |
85 | rename { fileName ->
86 | if (fileName.contains("${renameConfig.templateApplicationClassName}")) {
87 | fileName.replace(
88 | "${renameConfig.templateApplicationClassName}",
89 | "${renameConfig.newApplicationClassName}",
90 | )
91 | } else {
92 | fileName
93 | }
94 | }
95 |
96 | doLast {
97 | delete(startingDirectory)
98 | }
99 | }
100 |
101 | task replaceTemplateReferences {
102 | description "Replaces references to template in various files."
103 | group null
104 |
105 | doLast {
106 | replaceTextInFile(
107 | "${rootDir}/app/src/main/AndroidManifest.xml",
108 | "${renameConfig.templateName}.MainActivity",
109 | "${renameConfig.newPackage}.MainActivity",
110 | )
111 |
112 | replaceTextInFile(
113 | "${rootDir}/app/src/main/AndroidManifest.xml",
114 | ".${renameConfig.templateApplicationClassName}",
115 | ".${renameConfig.newApplicationClassName}",
116 | )
117 |
118 | replaceTextInFile(
119 | "${rootDir}/app/build.gradle.kts",
120 | "namespace = \"${renameConfig.templateName}\"",
121 | "namespace = \"${renameConfig.newPackage}\"",
122 | )
123 |
124 | replaceTextInFile(
125 | "${rootDir}/app/build.gradle.kts",
126 | "applicationId = \"${renameConfig.templateAppId}\"",
127 | "applicationId = \"${renameConfig.newPackage}\"",
128 | )
129 |
130 | replaceTextInFile(
131 | "${rootDir}/settings.gradle.kts",
132 | "rootProject.name = \"${renameConfig.templateName}\"",
133 | "rootProject.name = \"${renameConfig.newProjectName}\"",
134 | )
135 |
136 | replaceTextInFile(
137 | "${rootDir}/app/src/main/res/values/strings.xml",
138 | "${renameConfig.templateName}",
139 | "${renameConfig.newProjectName}",
140 | )
141 | }
142 | }
143 |
144 | task keepOrRemoveDependencies {
145 | description "Keeps or removes certain dependencies defined in renameConfig."
146 | group null
147 |
148 | doLast {
149 | def filesWithDependencies = [
150 | "${rootDir}/build.gradle.kts",
151 | "${rootDir}/gradle/libs.versions.toml",
152 | "${rootDir}/app/build.gradle.kts",
153 | "${rootDir}/app/src/main/AndroidManifest.xml",
154 | "${rootDir}/app/src/main/java/template/TemplateApp.kt",
155 | "${rootDir}/app/src/main/java/template/MainActivity.kt",
156 | ]
157 |
158 | filesWithDependencies.each { fileName ->
159 | if (renameConfig.useHiltDependencies != true) {
160 | println("Removing hilt dependencies")
161 | removeTextFromFile(fileName, "hilt")
162 | removeTextFromFile(fileName, "Hilt")
163 | removeTextFromFile(fileName, "AndroidEntryPoint")
164 | }
165 |
166 | if (renameConfig.useRoomDependencies != true) {
167 | println("Removing room dependencies")
168 | removeTextFromFile(fileName, "room")
169 | }
170 |
171 | if (renameConfig.useRetrofitDependencies != true) {
172 | println("Removing retrofit dependencies")
173 | removeTextFromFile(fileName, "retrofit")
174 | removeTextFromFile(fileName, "moshi")
175 | removeTextFromFile(fileName, "okhttp")
176 | }
177 |
178 | if (renameConfig.usePaparazziDependencies != true) {
179 | println("Removing paparazzi dependencies")
180 | removeTextFromFile(fileName, "paparazzi")
181 | }
182 |
183 | if (renameConfig.useAndroidXR != true) {
184 | println("Removing xr dependencies")
185 | removeTextFromFile(fileName, "xr")
186 | }
187 | }
188 | }
189 | }
190 |
191 | project('app').tasks.named {
192 | // startsWith is used because this applies to multiple tasks,
193 | // like formatKotlinMain, formatKotlinTest, etc.
194 | it.startsWith("formatKotlin")
195 | }.configureEach {
196 | mustRunAfter(rootProject.tasks.named("renameTemplate"))
197 | }
198 |
199 | task renameTemplate {
200 | description "Runs all of the necessary template setup tasks based on the renameConfig."
201 | group "Template Setup"
202 |
203 | dependsOn(
204 | keepOrRemoveDependencies,
205 | renameAppPackage,
206 | replaceTemplateReferences,
207 | deleteSetupCode,
208 | )
209 |
210 | finalizedBy("app:formatKotlin")
211 |
212 | doLast {
213 | exec {
214 | // After all setup changes happen, run a `git add` so
215 | // folks can just immediately commit and push if they wish.
216 | commandLine "git", "add", "${rootDir}/."
217 | }
218 | }
219 | }
220 |
221 | /**
222 | * Replaces all instances of [text] in a given [fileName].
223 | */
224 | static def replaceTextInFile(fileName, originalText, newText) {
225 | def file = new File(fileName)
226 |
227 | file.text = file.text.replaceAll(originalText, newText)
228 | }
229 |
230 | /**
231 | * Removes all lines from the given fileName that contain some supplied text.
232 | */
233 | static def removeTextFromFile(fileName, text) {
234 | def file = new File(fileName)
235 | List fileLines = file.readLines()
236 | file.text = ""
237 | fileLines.each { line ->
238 | if (!line.contains(text)) {
239 | file.append(line)
240 | file.append("\n")
241 | }
242 | }
243 | }
--------------------------------------------------------------------------------
/buildscripts/versionsplugin.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: "com.github.ben-manes.versions"
2 |
3 | def isNonStable = { String version ->
4 | def stableKeyword = ['RELEASE', 'FINAL', 'GA'].any { it -> version.toUpperCase().contains(it) }
5 | def regex = /^[0-9,.v-]+(-r)?$/
6 | return !stableKeyword && !(version ==~ regex)
7 | }
8 |
9 | tasks.named("dependencyUpdates").configure {
10 | rejectVersionIf {
11 | isNonStable(it.candidate.version)
12 | }
13 |
14 | gradleReleaseChannel = "current"
15 | }
--------------------------------------------------------------------------------
/config/detekt/detekt.yml:
--------------------------------------------------------------------------------
1 | # Note that this is a slimmed version of a detekt config file that only includes behavior we
2 | # want to override for our application. This is done by using `buildUponDefaultConfig` in the gradle
3 | # configuration.
4 |
5 | # You can find a list of rules in the Detekt docs: https://detekt.dev/docs/intro
6 |
7 | naming:
8 | active: true
9 | # Ignore function naming for Composable functions since they start with uppercase letters.
10 | FunctionNaming:
11 | active: true
12 | excludes: ['**/test/**', '**/androidTest/**', '**/commonTest/**', '**/jvmTest/**', '**/androidUnitTest/**', '**/androidInstrumentedTest/**', '**/jsTest/**', '**/iosTest/**']
13 | functionPattern: '[a-z][a-zA-Z0-9]*'
14 | excludeClassPattern: '$^'
15 | ignoreAnnotated: ['Composable']
16 |
17 | style:
18 | active: true
19 | # If a preview function is private and unused, Detekt flags that by default.AlsoCouldBeApply:
20 | # Disable this check if the function is annotated with Preview.
21 | UnusedPrivateMember:
22 | active: true
23 | ignoreAnnotated: ['Preview']
--------------------------------------------------------------------------------
/documentation/GitHooks.md:
--------------------------------------------------------------------------------
1 | # Git Hooks
2 |
3 | This project has some Git hooks included inside the [git-hooks](/git-hooks) folder. These hooks can be installed automatically via the Gradle commands `./gradlew copyGitHooks` and `./gradlew installGitHooks`. You can find these commands in [this Gradle file](/buildscripts/githooks.gradle), but it's also good to know that the hooks are installed automatically just by running a `clean` task. Thanks to [Sebastiano's blog post](https://blog.sebastiano.dev/ooga-chaka-git-hooks-to-enforce-code-quality/) for that inspiration.
4 |
5 | ## Pre-Commit
6 |
7 | There is a [pre-commit](/git-hooks/pre-commit-macos.sh) hook that will automatically run Ktlint formatting over any modified Kotlin files. This way you can just commit your code and trust that formatting happens behind the scenes, without having to consciously worry about it.
8 |
9 | ## Pre-Push
10 |
11 | There is a [pre-push](/git-hooks/pre-push-macos.sh) hook that will run static analysis checks before any code is pushed up to the remote repository. This way, if you have any code smells, you can be alerted right away without waiting for the GitHub Actions to fail.
--------------------------------------------------------------------------------
/documentation/GitHubActions.md:
--------------------------------------------------------------------------------
1 | # GitHub Actions
2 |
3 | This project has [GitHub Actions](https://github.com/features/actions) workflows to validate our code for us automatically. The project currently uses two workflows.
4 |
5 | ## Android Build
6 |
7 | The [Android Build](/.github/workflows/android_build.yml) workflow automates the core checks for the repository: compile, unit tests, lint checks. This is set to run on every push.
8 |
9 | ## Android UI Tests
10 |
11 | The [Android UI Tests](/.github/workflows/android_ui_tests.yml) is a separate workflow that is set to only run on pull request. This is because UI tests are slow and take up a lot of resources, so we only want to validate them when we're ready to merge changes into our base branch.
12 |
--------------------------------------------------------------------------------
/documentation/StaticAnalysis.md:
--------------------------------------------------------------------------------
1 | # Static Analysis
2 |
3 | This project leverages static analysis to ensure that the codebase meets certain standards that can be verified through automation. Two of these libraries are Detekt and Ktlint.
4 |
5 | ## Detekt
6 |
7 | [Detekt](https://github.com/detekt/detekt) is a static analysis tool that checks for code smells. Examples include magic numbers, complicated conditionals, long methods, long parameter lists, and so much more. It is highly configurable, and if you choose to turn off any checks or customize thresholds you can do so in the [config file](/config/detekt/detekt.yml).
8 |
9 | To run a detekt validation, use the one of the following Gradle commands:
10 |
11 | ```
12 | ./gradlew detekt # Runs over each module synchronously
13 | ./gradlew detektAll # Runs over each module in parallel.
14 | ```
15 |
16 | ## Ktlint
17 |
18 | [Ktlint](https://github.com/pinterest/ktlint) is a static analysis tool from Pinterest that prevents bike shedding when it comes to code formatting. It also comes with a Gradle task to automatically format your entire codebase, if it can. The benefit of a tool like this is to ensure everyone on the team will have code formatted the same way, and there's no debating around white spaces, indentation, imports, etc.
19 |
20 | We use the [Kotlinter](https://github.com/jeremymailen/kotlinter-gradle) Ktlint Gradle plugin in this project.
21 |
22 | The following Gradle commands can be helpful:
23 |
24 | ```
25 | // Will format the codebase
26 | ./gradlew formatKotlin
27 |
28 | // Will check if everything is formatted correctly
29 | ./gradlew lintKotlin
30 | ```
--------------------------------------------------------------------------------
/documentation/VersionsPlugin.md:
--------------------------------------------------------------------------------
1 | # Versions Plugin
2 |
3 | This project uses the [Gradle Versions Plugin](https://github.com/ben-manes/gradle-versions-plugin) from Ben Manes. Ths is an extremely helpful plugin that will check all of the dependencies in the project, and see if they have any new versions. Currently, it is configured to only check for stable versions, but you can customize that inside [this Gradle file](/buildscripts/versionsplugin.gradle).
4 |
5 | To run this check, use the following Gradle command:
6 |
7 | ```
8 | ./gradlew dependencyUpdates
9 | ```
10 |
11 | This will print the updates to the console, as well as a text file you can read from if necessary.
--------------------------------------------------------------------------------
/git-hooks/pre-commit-macos.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | ######## KTLINT-GRADLE HOOK START ########
4 |
5 | CHANGED_FILES="$(git --no-pager diff --name-status --no-color --cached | awk '$1 != "D" && $2 ~ /\.kts|\.kt/ { print $2}')"
6 |
7 | if [ -z "$CHANGED_FILES" ]; then
8 | echo "No Kotlin staged files."
9 | exit 0
10 | fi;
11 |
12 | echo "Running ktlint over these files:"
13 | echo "$CHANGED_FILES"
14 |
15 | ./gradlew --quiet formatKotlin -PinternalKtlintGitFilter="$CHANGED_FILES"
16 |
17 | echo "Completed ktlint run."
18 |
19 | echo "$CHANGED_FILES" | while read -r file; do
20 | if [ -f $file ]; then
21 | git add $file
22 | fi
23 | done
24 |
25 | ######## KTLINT-GRADLE HOOK END ########
26 |
27 | echo "Sorting dependencies."
28 |
29 | ./gradlew sortDependencies
30 |
31 | echo "Completed sorting dependencies."
32 |
33 | # Look for any changed files that are gradle, gradle.kts, or toml and git add them.
34 | # This ensures any files changed by sortDependencies get added to this git commit.
35 | CHANGED_VERSION_FILES="$(git --no-pager diff --name-status --no-color --cached | awk '$1 != "D" && $2 ~ /\.gradle|\.toml|\.gradle.kts/ { print $2}')"
36 |
37 | echo "$CHANGED_VERSION_FILES" | while read -r file; do
38 | if [ -f $file ]; then
39 | git add $file
40 | fi
41 | done
42 |
43 | echo "Completed pre-commit hook."
--------------------------------------------------------------------------------
/git-hooks/pre-commit-windows.sh:
--------------------------------------------------------------------------------
1 | #!C:/Program\ Files/Git/usr/bin/sh.exe
2 |
3 | ######## KTLINT-GRADLE HOOK START ########
4 |
5 | CHANGED_FILES="$(git --no-pager diff --name-status --no-color --cached | awk '$1 != "D" && $2 ~ /\.kts|\.kt/ { print $2}')"
6 |
7 | if [ -z "$CHANGED_FILES" ]; then
8 | echo "No Kotlin staged files."
9 | exit 0
10 | fi;
11 |
12 | echo "Running ktlint over these files:"
13 | echo "$CHANGED_FILES"
14 |
15 | ./gradlew --quiet formatKotlin -PinternalKtlintGitFilter="$CHANGED_FILES"
16 |
17 | echo "Completed ktlint run."
18 |
19 | echo "$CHANGED_FILES" | while read -r file; do
20 | if [ -f $file ]; then
21 | git add $file
22 | fi
23 | done
24 |
25 | ######## KTLINT-GRADLE HOOK END ########
26 |
27 | echo "Sorting dependencies."
28 |
29 | ./gradlew sortDependencies
30 |
31 | echo "Completed sorting dependencies."
32 |
33 | # Look for any changed files that are gradle, gradle.kts, or toml and git add them.
34 | # This ensures any files changed by sortDependencies get added to this git commit.
35 | CHANGED_VERSION_FILES="$(git --no-pager diff --name-status --no-color --cached | awk '$1 != "D" && $2 ~ /\.gradle|\.toml|\.gradle.kts/ { print $2}')"
36 |
37 | echo "$CHANGED_VERSION_FILES" | while read -r file; do
38 | if [ -f $file ]; then
39 | git add $file
40 | fi
41 | done
42 |
43 | echo "Completed pre-commit hook."
--------------------------------------------------------------------------------
/git-hooks/pre-push-macos.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | echo "Running static analysis."
4 |
5 | ./gradlew lintKotlin
6 | ./gradlew detektAll
--------------------------------------------------------------------------------
/git-hooks/pre-push-windows.sh:
--------------------------------------------------------------------------------
1 | #!C:/Program\ Files/Git/usr/bin/sh.exe
2 |
3 | echo "Running static analysis."
4 |
5 | ./gradlew lintKotlin
6 | ./gradlew detektAll
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 | # AndroidX package structure to make it clearer which packages are bundled with the
15 | # Android operating system, and which are packaged with your app"s APK
16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn
17 | android.useAndroidX=true
18 | # Kotlin code style for this project: "official" or "obsolete":
19 | kotlin.code.style=official
20 | # Enables tasks to run in parallel when possible
21 | # https://docs.gradle.org/current/userguide/performance.html#parallel_execution
22 | org.gradle.parallel=true
23 | # Enables caching results locally to improve subsequent builds
24 | # https://docs.gradle.org/current/userguide/build_cache.html#sec:build_cache_enable
25 | org.gradle.caching=true
--------------------------------------------------------------------------------
/gradle/libs.versions.toml:
--------------------------------------------------------------------------------
1 | [versions]
2 | activityCompose = "1.10.1"
3 | agp = "8.10.1"
4 | androidxTest = "1.2.1"
5 | appCompat = "1.7.1"
6 | coil = "3.2.0"
7 | compileSdk = "35"
8 | composeBom = "2025.06.00"
9 | detektGradlePlugin = "1.23.8"
10 | espresso = "3.6.1"
11 | gradleVersionsPlugin = "0.52.0"
12 | hilt = "2.56.2"
13 | hiltNavigationCompose = "1.2.0"
14 | junit = "4.13.2"
15 | kotlin = "2.1.21"
16 | kotlinter = "5.1.1"
17 | ksp = "2.1.21-2.0.2"
18 | ktxCore = "1.16.0"
19 | leakCanary = "2.14"
20 | lifecycle = "2.9.1"
21 | material = "1.12.0"
22 | minSdk = "23"
23 | moshi = "1.15.2"
24 | navigationCompose = "2.9.0"
25 | okhttp = "4.12.0"
26 | paparazzi = "1.3.5"
27 | retrofit = "3.0.0"
28 | room = "2.7.1"
29 | sortDependencies = "0.14"
30 | xr = "1.0.0-alpha04"
31 | xr-material = "1.0.0-alpha08"
32 |
33 | [libraries]
34 | android-material = { module = "com.google.android.material:material", version.ref = "material" }
35 | androidx-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "activityCompose" }
36 | androidx-core-ktx = { module = "androidx.core:core-ktx", version.ref = "ktxCore" }
37 | androidx-appcompat = { module = "androidx.appcompat:appcompat", version.ref = "appCompat" }
38 | androidx-lifecycle-runtime-ktx = { module = "androidx.lifecycle:lifecycle-runtime-ktx", version.ref = "lifecycle" }
39 | androidx-room-compiler = { module = "androidx.room:room-compiler", version.ref = "room" }
40 | androidx-room-runtime = { module = "androidx.room:room-runtime", version.ref = "room" }
41 | androidx-test-espresso-core = { module = "androidx.test.espresso:espresso-core", version.ref = "espresso" }
42 | androidx-test-junit = { module = "androidx.test.ext:junit", version.ref = "androidxTest" }
43 | androidx-xr-compose = { module = "androidx.xr.compose:compose", version.ref = "xr" }
44 | androidx-xr-compose-material3 = { module = "androidx.xr.compose.material3:material3", version.ref = "xr-material" }
45 | androidx-xr-scenecore = { module = "androidx.xr.scenecore:scenecore", version.ref = "xr" }
46 | coil-compose = { module = "io.coil-kt.coil3:coil-compose", version.ref = "coil" }
47 | coil-okhttp = { module = "io.coil-kt.coil3:coil-network-okhttp", version.ref = "coil" }
48 | compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "composeBom" }
49 | compose-material-icons-extended = { group = "androidx.compose.material", name = "material-icons-extended" }
50 | compose-material = { group = "androidx.compose.material3", name = "material3" }
51 | compose-navigation = { module = "androidx.navigation:navigation-compose", version.ref = "navigationCompose" }
52 | compose-ui = { group = "androidx.compose.ui", name = "ui" }
53 | compose-ui-test-junit = { group = "androidx.compose.ui", name = "ui-test-junit4" }
54 | compose-ui-test-manifest = { group = "androidx.compose.ui", name = "ui-test-manifest" }
55 | compose-ui-tooling = { group = "androidx.compose.ui", name = "ui-tooling" }
56 | detekt-gradle-plugin = { module = "io.gitlab.arturbosch.detekt:detekt-gradle-plugin", version.ref = "detektGradlePlugin" }
57 | gradle = { module = "com.android.tools.build:gradle", version.ref = "agp" }
58 | gradle-versions-plugin = { module = "com.github.ben-manes:gradle-versions-plugin", version.ref = "gradleVersionsPlugin" }
59 | hilt-android = { module = "com.google.dagger:hilt-android", version.ref = "hilt" }
60 | hilt-android-compiler = { module = "com.google.dagger:hilt-android-compiler", version.ref = "hilt" }
61 | hilt-android-testing = { module = "com.google.dagger:hilt-android-testing", version.ref = "hilt" }
62 | hilt-compiler = { module = "com.google.dagger:hilt-compiler", version.ref = "hilt" }
63 | hilt-navigation-compose = { module = "androidx.hilt:hilt-navigation-compose", version.ref = "hiltNavigationCompose" }
64 | junit = { module = "junit:junit", version.ref = "junit" }
65 | kotlin-gradle-plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
66 | square-leakcanary = { module = "com.squareup.leakcanary:leakcanary-android", version.ref = "leakCanary" }
67 | square-moshi-kotlin = { module = "com.squareup.moshi:moshi-kotlin", version.ref = "moshi" }
68 | square-moshi-kotlin-codegen = { module = "com.squareup.moshi:moshi-kotlin-codegen", version.ref = "moshi" }
69 | square-okhttp-logging-interceptor = { module = "com.squareup.okhttp3:logging-interceptor", version.ref = "okhttp" }
70 | square-retrofit = { module = "com.squareup.retrofit2:retrofit", version.ref = "retrofit" }
71 | square-retrofit-converter-moshi = { module = "com.squareup.retrofit2:converter-moshi", version.ref = "retrofit"}
72 |
73 | [plugins]
74 | android-application = { id = "com.android.application", version.ref = "agp" }
75 | benmanes-versions = { id = "com.github.ben-manes.versions", version.ref = "gradleVersionsPlugin" }
76 | cash-paparazzi = { id = "app.cash.paparazzi", version.ref = "paparazzi" }
77 | compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
78 | detekt = { id = "io.gitlab.arturbosch.detekt", version.ref = "detektGradlePlugin" }
79 | google-dagger-hilt = { id = "com.google.dagger.hilt.android", version.ref = "hilt" }
80 | google-ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
81 | kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
82 | kotlin-parcelize = { id = "org.jetbrains.kotlin.plugin.parcelize", version.ref = "kotlin" }
83 | kotlinter = { id = "org.jmailen.kotlinter", version.ref = "kotlinter" }
84 | square-sort-dependencies = { id = "com.squareup.sort-dependencies", version.ref = "sortDependencies" }
85 |
86 | [bundles]
87 | androidx-xr = ["androidx-xr-compose", "androidx-xr-compose-material3", "androidx-xr-scenecore"]
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AdamMc331/AndroidAppTemplate/4381309db8f736a56863d8bc657949e83d69e27b/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.2-bin.zip
4 | networkTimeout=10000
5 | validateDistributionUrl=true
6 | zipStoreBase=GRADLE_USER_HOME
7 | zipStorePath=wrapper/dists
8 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | #
4 | # Copyright © 2015-2021 the original authors.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # https://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 | # SPDX-License-Identifier: Apache-2.0
19 | #
20 |
21 | ##############################################################################
22 | #
23 | # Gradle start up script for POSIX generated by Gradle.
24 | #
25 | # Important for running:
26 | #
27 | # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
28 | # noncompliant, but you have some other compliant shell such as ksh or
29 | # bash, then to run this script, type that shell name before the whole
30 | # command line, like:
31 | #
32 | # ksh Gradle
33 | #
34 | # Busybox and similar reduced shells will NOT work, because this script
35 | # requires all of these POSIX shell features:
36 | # * functions;
37 | # * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
38 | # «${var#prefix}», «${var%suffix}», and «$( cmd )»;
39 | # * compound commands having a testable exit status, especially «case»;
40 | # * various built-in commands including «command», «set», and «ulimit».
41 | #
42 | # Important for patching:
43 | #
44 | # (2) This script targets any POSIX shell, so it avoids extensions provided
45 | # by Bash, Ksh, etc; in particular arrays are avoided.
46 | #
47 | # The "traditional" practice of packing multiple parameters into a
48 | # space-separated string is a well documented source of bugs and security
49 | # problems, so this is (mostly) avoided, by progressively accumulating
50 | # options in "$@", and eventually passing that to Java.
51 | #
52 | # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
53 | # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
54 | # see the in-line comments for details.
55 | #
56 | # There are tweaks for specific operating systems such as AIX, CygWin,
57 | # Darwin, MinGW, and NonStop.
58 | #
59 | # (3) This script is generated from the Groovy template
60 | # https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
61 | # within the Gradle project.
62 | #
63 | # You can find Gradle at https://github.com/gradle/gradle/.
64 | #
65 | ##############################################################################
66 |
67 | # Attempt to set APP_HOME
68 |
69 | # Resolve links: $0 may be a link
70 | app_path=$0
71 |
72 | # Need this for daisy-chained symlinks.
73 | while
74 | APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
75 | [ -h "$app_path" ]
76 | do
77 | ls=$( ls -ld "$app_path" )
78 | link=${ls#*' -> '}
79 | case $link in #(
80 | /*) app_path=$link ;; #(
81 | *) app_path=$APP_HOME$link ;;
82 | esac
83 | done
84 |
85 | # This is normally unused
86 | # shellcheck disable=SC2034
87 | APP_BASE_NAME=${0##*/}
88 | # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
89 | APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
90 |
91 | # Use the maximum available, or set MAX_FD != -1 to use that value.
92 | MAX_FD=maximum
93 |
94 | warn () {
95 | echo "$*"
96 | } >&2
97 |
98 | die () {
99 | echo
100 | echo "$*"
101 | echo
102 | exit 1
103 | } >&2
104 |
105 | # OS specific support (must be 'true' or 'false').
106 | cygwin=false
107 | msys=false
108 | darwin=false
109 | nonstop=false
110 | case "$( uname )" in #(
111 | CYGWIN* ) cygwin=true ;; #(
112 | Darwin* ) darwin=true ;; #(
113 | MSYS* | MINGW* ) msys=true ;; #(
114 | NONSTOP* ) nonstop=true ;;
115 | esac
116 |
117 | CLASSPATH="\\\"\\\""
118 |
119 |
120 | # Determine the Java command to use to start the JVM.
121 | if [ -n "$JAVA_HOME" ] ; then
122 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
123 | # IBM's JDK on AIX uses strange locations for the executables
124 | JAVACMD=$JAVA_HOME/jre/sh/java
125 | else
126 | JAVACMD=$JAVA_HOME/bin/java
127 | fi
128 | if [ ! -x "$JAVACMD" ] ; then
129 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
130 |
131 | Please set the JAVA_HOME variable in your environment to match the
132 | location of your Java installation."
133 | fi
134 | else
135 | JAVACMD=java
136 | if ! command -v java >/dev/null 2>&1
137 | then
138 | die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
139 |
140 | Please set the JAVA_HOME variable in your environment to match the
141 | location of your Java installation."
142 | fi
143 | fi
144 |
145 | # Increase the maximum file descriptors if we can.
146 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
147 | case $MAX_FD in #(
148 | max*)
149 | # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
150 | # shellcheck disable=SC2039,SC3045
151 | MAX_FD=$( ulimit -H -n ) ||
152 | warn "Could not query maximum file descriptor limit"
153 | esac
154 | case $MAX_FD in #(
155 | '' | soft) :;; #(
156 | *)
157 | # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
158 | # shellcheck disable=SC2039,SC3045
159 | ulimit -n "$MAX_FD" ||
160 | warn "Could not set maximum file descriptor limit to $MAX_FD"
161 | esac
162 | fi
163 |
164 | # Collect all arguments for the java command, stacking in reverse order:
165 | # * args from the command line
166 | # * the main class name
167 | # * -classpath
168 | # * -D...appname settings
169 | # * --module-path (only if needed)
170 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
171 |
172 | # For Cygwin or MSYS, switch paths to Windows format before running java
173 | if "$cygwin" || "$msys" ; then
174 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
175 | CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
176 |
177 | JAVACMD=$( cygpath --unix "$JAVACMD" )
178 |
179 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
180 | for arg do
181 | if
182 | case $arg in #(
183 | -*) false ;; # don't mess with options #(
184 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
185 | [ -e "$t" ] ;; #(
186 | *) false ;;
187 | esac
188 | then
189 | arg=$( cygpath --path --ignore --mixed "$arg" )
190 | fi
191 | # Roll the args list around exactly as many times as the number of
192 | # args, so each arg winds up back in the position where it started, but
193 | # possibly modified.
194 | #
195 | # NB: a `for` loop captures its iteration list before it begins, so
196 | # changing the positional parameters here affects neither the number of
197 | # iterations, nor the values presented in `arg`.
198 | shift # remove old arg
199 | set -- "$@" "$arg" # push replacement arg
200 | done
201 | fi
202 |
203 |
204 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
205 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
206 |
207 | # Collect all arguments for the java command:
208 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
209 | # and any embedded shellness will be escaped.
210 | # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
211 | # treated as '${Hostname}' itself on the command line.
212 |
213 | set -- \
214 | "-Dorg.gradle.appname=$APP_BASE_NAME" \
215 | -classpath "$CLASSPATH" \
216 | -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
217 | "$@"
218 |
219 | # Stop when "xargs" is not available.
220 | if ! command -v xargs >/dev/null 2>&1
221 | then
222 | die "xargs is not available"
223 | fi
224 |
225 | # Use "xargs" to parse quoted args.
226 | #
227 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed.
228 | #
229 | # In Bash we could simply go:
230 | #
231 | # readarray ARGS < <( xargs -n1 <<<"$var" ) &&
232 | # set -- "${ARGS[@]}" "$@"
233 | #
234 | # but POSIX shell has neither arrays nor command substitution, so instead we
235 | # post-process each arg (as a line of input to sed) to backslash-escape any
236 | # character that might be a shell metacharacter, then use eval to reverse
237 | # that process (while maintaining the separation between arguments), and wrap
238 | # the whole thing up as a single "set" statement.
239 | #
240 | # This will of course break if any of these variables contains a newline or
241 | # an unmatched quote.
242 | #
243 |
244 | eval "set -- $(
245 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
246 | xargs -n1 |
247 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
248 | tr '\n' ' '
249 | )" '"$@"'
250 |
251 | exec "$JAVACMD" "$@"
252 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 | @rem SPDX-License-Identifier: Apache-2.0
17 | @rem
18 |
19 | @if "%DEBUG%"=="" @echo off
20 | @rem ##########################################################################
21 | @rem
22 | @rem Gradle startup script for Windows
23 | @rem
24 | @rem ##########################################################################
25 |
26 | @rem Set local scope for the variables with windows NT shell
27 | if "%OS%"=="Windows_NT" setlocal
28 |
29 | set DIRNAME=%~dp0
30 | if "%DIRNAME%"=="" set DIRNAME=.
31 | @rem This is normally unused
32 | set APP_BASE_NAME=%~n0
33 | set APP_HOME=%DIRNAME%
34 |
35 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
36 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
37 |
38 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
39 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
40 |
41 | @rem Find java.exe
42 | if defined JAVA_HOME goto findJavaFromJavaHome
43 |
44 | set JAVA_EXE=java.exe
45 | %JAVA_EXE% -version >NUL 2>&1
46 | if %ERRORLEVEL% equ 0 goto execute
47 |
48 | echo. 1>&2
49 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
50 | echo. 1>&2
51 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2
52 | echo location of your Java installation. 1>&2
53 |
54 | goto fail
55 |
56 | :findJavaFromJavaHome
57 | set JAVA_HOME=%JAVA_HOME:"=%
58 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
59 |
60 | if exist "%JAVA_EXE%" goto execute
61 |
62 | echo. 1>&2
63 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
64 | echo. 1>&2
65 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2
66 | echo location of your Java installation. 1>&2
67 |
68 | goto fail
69 |
70 | :execute
71 | @rem Setup the command line
72 |
73 | set CLASSPATH=
74 |
75 |
76 | @rem Execute Gradle
77 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
78 |
79 | :end
80 | @rem End local scope for the variables with windows NT shell
81 | if %ERRORLEVEL% equ 0 goto mainEnd
82 |
83 | :fail
84 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
85 | rem the _cmd.exe /c_ return code!
86 | set EXIT_CODE=%ERRORLEVEL%
87 | if %EXIT_CODE% equ 0 set EXIT_CODE=1
88 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
89 | exit /b %EXIT_CODE%
90 |
91 | :mainEnd
92 | if "%OS%"=="Windows_NT" endlocal
93 |
94 | :omega
95 |
--------------------------------------------------------------------------------
/renovate.json5:
--------------------------------------------------------------------------------
1 | {
2 | $schema: 'https://docs.renovatebot.com/renovate-schema.json',
3 | extends: [
4 | 'config:base',
5 | ],
6 | packageRules: [
7 | {
8 | matchUpdateTypes: [
9 | 'minor',
10 | 'patch',
11 | 'pin',
12 | 'digest'
13 | ],
14 | automerge: true,
15 | },
16 | ],
17 | platformAutomerge: true,
18 | ignorePresets: [
19 | // Ensure we get the latest version and are not pinned to old versions.
20 | 'workarounds:javaLTSVersions',
21 | ],
22 | customManagers: [
23 | // Update .java-version file with the latest JDK version.
24 | {
25 | customType: 'regex',
26 | fileMatch: [
27 | '\\.java-version$',
28 | ],
29 | matchStrings: [
30 | '(?.*)\\n',
31 | ],
32 | datasourceTemplate: 'java-version',
33 | depNameTemplate: 'java',
34 | // Only write the major version.
35 | extractVersionTemplate: '^(?\\d+)',
36 | },
37 | ],
38 | }
--------------------------------------------------------------------------------
/settings.gradle.kts:
--------------------------------------------------------------------------------
1 | pluginManagement {
2 | repositories {
3 | google()
4 | mavenCentral()
5 | gradlePluginPortal()
6 | }
7 | }
8 | dependencyResolutionManagement {
9 | repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
10 | repositories {
11 | google()
12 | mavenCentral()
13 | }
14 | }
15 | rootProject.name = "template"
16 | include(":app")
17 |
--------------------------------------------------------------------------------