Skip to content

Commit

Permalink
Updates (#29)
Browse files Browse the repository at this point in the history
* updated gradle wrapper

* updated launcher icon

* updated gitignore

* remove supress annotation in build files

* switch to retrofit bom and retrofit provided kotlinx serialization lib

* cleanup settings file

* updated kotlin and ksp to v2.0.0

* cleanup code

* cleanup build-logic dir

* added info classes

* cleanup

* setup convention plugins properly

* updated readme
  • Loading branch information
nisrulz authored Jun 13, 2024
1 parent a3cbbab commit 118e59e
Show file tree
Hide file tree
Showing 79 changed files with 514 additions and 347 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,4 @@ Icon
Network Trash Folder
Temporary Items
.apdisk
/.kotlin/
2 changes: 1 addition & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ An Offline first Android app to consume the SpaceX Backend API [`https://github.
- Cacheing
- [Delegation](https://kotlinlang.org/docs/delegation.html)
- [Multibindings with Hilt](https://dagger.dev/dev-guide/multibindings.html)
- [Gradle Convention Plugins](https://docs.gradle.org/current/samples/sample_convention_plugins.html) | PR [#5](https://github.com/nisrulz/android-spacex-app/pull/5) [#7](https://github.com/nisrulz/android-spacex-app/pull/7)
- [Convention Plugins](https://github.com/nisrulz/android-spacex-app/pull/29/commits/2e05a6c3fa972cd29c89a28cb5a735aa073d4f43)
- [Github Actions](https://docs.github.com/en/actions) | [Workflows used](.github/workflows)

## Dependency Graph
Expand Down
26 changes: 5 additions & 21 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,31 +1,15 @@
@Suppress("DSL_SCOPE_VIOLATION") // TODO: Remove once KTIJ-19369 is fixed
import com.nisrulz.example.spacexapi.info.ApplicationInfo

plugins {
id("app-convention")
id("hilt-convention")
alias(libs.plugins.spacexapi.android.application)
alias(libs.plugins.spacexapi.android.app.hilt)
}

android {
namespace = "com.nisrulz.example.spacexapi"

defaultConfig {
applicationId = "com.nisrulz.example.spacexapi"
versionCode = 1
versionName = "1.0"
}
namespace = ApplicationInfo.BASE_NAMESPACE
}

dependencies {
// Module Dependency
implementation(projects.presentation)

/**
* @TODO: Remove this workaround when below issues are solved with AGP 8.3.0
* https://github.com/google/guava/issues/6618
* https://github.com/android/nowinandroid/pull/1140#issuecomment-1979431658
*/
modules {
module("com.google.guava:listenablefuture") {
replacedBy("com.google.guava:guava", "listenablefuture is part of guava")
}
}
}
1 change: 0 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.SpacexAPI"
tools:targetApi="tiramisu">
Expand Down
Binary file added app/src/main/play_store_512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
<monochrome android:drawable="@drawable/ic_launcher_foreground" />
<background android:drawable="@mipmap/ic_launcher_background"/>
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
<monochrome android:drawable="@mipmap/ic_launcher_monochrome"/>
</adaptive-icon>
6 changes: 0 additions & 6 deletions app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml

This file was deleted.

Binary file added app/src/main/res/mipmap-hdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed app/src/main/res/mipmap-hdpi/ic_launcher.webp
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed app/src/main/res/mipmap-hdpi/ic_launcher_round.webp
Binary file not shown.
Binary file added app/src/main/res/mipmap-mdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed app/src/main/res/mipmap-mdpi/ic_launcher.webp
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed app/src/main/res/mipmap-mdpi/ic_launcher_round.webp
Binary file not shown.
Binary file added app/src/main/res/mipmap-xhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed app/src/main/res/mipmap-xhdpi/ic_launcher.webp
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp
Binary file not shown.
Binary file added app/src/main/res/mipmap-xxhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed app/src/main/res/mipmap-xxhdpi/ic_launcher.webp
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file added app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
16 changes: 0 additions & 16 deletions build-logic/build.gradle.kts

This file was deleted.

73 changes: 73 additions & 0 deletions build-logic/convention/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
plugins {
`kotlin-dsl`
}

// Note: Replace with your package name
group = "com.nisrulz.example.spacexapi"

// https://kotlinlang.org/docs/gradle-configure-project.html#gradle-java-toolchains-support
// Note: Setting a toolchain via the kotlin extension updates the toolchain for Java compile
// tasks as well.
kotlin {
jvmToolchain(17)
}

tasks {
validatePlugins {
enableStricterValidation = true
failOnWarning = true
}
}

dependencies {
// Android
compileOnly(libs.android.gradle.plugin)
compileOnly(libs.android.tools.common)
compileOnly(libs.kotlin.gradle.plugin)

// Compose
compileOnly(libs.compose.gradle.plugin)

// Hilt
compileOnly(libs.symbol.processing.gradle.plugin)
}

// Register Convention Plugins
gradlePlugin {
plugins {

register("androidApplication") {
id = "spacexapi.android.application"
implementationClass = "com.nisrulz.example.spacexapi.AndroidApplicationConventionPlugin"
}

register("androidLibrary") {
id = "spacexapi.android.library"
implementationClass = "com.nisrulz.example.spacexapi.AndroidLibraryConventionPlugin"
}

register("testing") {
id = "spacexapi.android.testing"
implementationClass =
"com.nisrulz.example.spacexapi.TestingConventionPlugin"
}

register("hiltApp") {
id = "spacexapi.android.app.hilt"
implementationClass =
"com.nisrulz.example.spacexapi.HiltAppConventionPlugin"
}

register("hiltLib") {
id = "spacexapi.android.lib.hilt"
implementationClass =
"com.nisrulz.example.spacexapi.HiltLibConventionPlugin"
}

register("androidCompose") {
id = "spacexapi.android.compose"
implementationClass =
"com.nisrulz.example.spacexapi.AndroidComposeConventionPlugin"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.nisrulz.example.spacexapi

import com.nisrulz.example.spacexapi.ktx.configureAndroidApp
import org.gradle.api.Plugin
import org.gradle.api.Project

class AndroidApplicationConventionPlugin : Plugin<Project> {
override fun apply(target: Project) {
with(target) {
with(pluginManager) {
apply("com.android.application")
apply("org.jetbrains.kotlin.android")
}

configureAndroidApp()
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.nisrulz.example.spacexapi

import com.nisrulz.example.spacexapi.ktx.configureAndroidCompose
import org.gradle.api.Plugin
import org.gradle.api.Project

class AndroidComposeConventionPlugin : Plugin<Project> {
override fun apply(target: Project) {
with(target) {
with(pluginManager) {
apply("com.android.library")
apply("org.jetbrains.kotlin.plugin.compose")
}

configureAndroidCompose()
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.nisrulz.example.spacexapi

import com.nisrulz.example.spacexapi.ktx.configureAndroidLibrary
import org.gradle.api.Plugin
import org.gradle.api.Project

class AndroidLibraryConventionPlugin : Plugin<Project> {
override fun apply(target: Project) {
with(target) {
with(pluginManager) {
apply("com.android.library")
apply("org.jetbrains.kotlin.android")
}

configureAndroidLibrary()
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.nisrulz.example.spacexapi

import com.android.build.api.dsl.ApplicationExtension
import com.nisrulz.example.spacexapi.ktx.configureHilt
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.configure

class HiltAppConventionPlugin : Plugin<Project> {
override fun apply(target: Project) {
with(target) {
with(pluginManager) {
apply("com.android.application")
apply("com.google.devtools.ksp")
apply("dagger.hilt.android.plugin")
}

extensions.configure<ApplicationExtension> {
configureHilt(this)
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.nisrulz.example.spacexapi

import com.android.build.api.dsl.LibraryExtension
import com.nisrulz.example.spacexapi.ktx.configureHilt
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.configure

class HiltLibConventionPlugin : Plugin<Project> {
override fun apply(target: Project) {
with(target) {
with(pluginManager) {
apply("com.android.library")
apply("com.google.devtools.ksp")
apply("dagger.hilt.android.plugin")
}

extensions.configure<LibraryExtension> {
configureHilt(this)
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.nisrulz.example.spacexapi

import com.nisrulz.example.spacexapi.ktx.configureTesting
import org.gradle.api.Plugin
import org.gradle.api.Project

class TestingConventionPlugin : Plugin<Project> {
override fun apply(target: Project) {
with(target) {
with(pluginManager) {
apply("com.android.library")
}

configureTesting()
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.nisrulz.example.spacexapi.info

object ApplicationInfo {
const val VERSION_NAME = "1.0"
const val VERSION_CODE = 1
const val BASE_NAMESPACE = "com.nisrulz.example.spacexapi"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.nisrulz.example.spacexapi.info

object BuildSdkInfo {
const val COMPILE_SDK_VERSION = 34
const val MIN_SDK_VERSION = 21
const val TARGET_SDK_VERSION = 34
const val JVM_TARGET = 17
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.nisrulz.example.spacexapi.ktx

import com.android.build.api.dsl.LibraryExtension
import org.gradle.api.Project
import org.gradle.kotlin.dsl.assign
import org.gradle.kotlin.dsl.configure
import org.gradle.kotlin.dsl.dependencies
import org.jetbrains.kotlin.compose.compiler.gradle.ComposeCompilerGradlePluginExtension

/**
* Configure Compose-specific options
*/
internal fun Project.configureAndroidCompose() = configure<LibraryExtension> {
buildFeatures {
compose = true
}

dependencies {
val bom = catalogLibrary("compose-bom")
add("implementation", platform(bom))
add("androidTestImplementation", platform(bom))
add("implementation", catalogLibrary("ui-tooling-preview"))
add("debugImplementation", catalogLibrary("ui-tooling"))
}

extensions.configure<ComposeCompilerGradlePluginExtension> {
enableStrongSkippingMode = true
}
}
Loading

0 comments on commit 118e59e

Please sign in to comment.