Skip to content

Commit

Permalink
Create Gamedge Remote Api plugin (#226)
Browse files Browse the repository at this point in the history
  • Loading branch information
mars885 authored Aug 21, 2024
1 parent bd83ab7 commit aaa891b
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 59 deletions.
4 changes: 4 additions & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ gradlePlugin {
id = "com.paulrybitskyi.gamedge.dagger.hilt"
implementationClass = "com.paulrybitskyi.gamedge.plugins.GamedgeDaggerHiltPlugin"
}
create("com.paulrybitskyi.gamedge.remote.api") {
id = "com.paulrybitskyi.gamedge.remote.api"
implementationClass = "com.paulrybitskyi.gamedge.plugins.GamedgeRemoteApiPlugin"
}
create("com.paulrybitskyi.gamedge.feature") {
id = "com.paulrybitskyi.gamedge.feature"
implementationClass = "com.paulrybitskyi.gamedge.plugins.GamedgeFeaturePlugin"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class GamedgeAndroidPlugin : Plugin<Project> {

private fun Project.configurePlugins() {
configureAndroidCommonInfo()
configureAndroidApplicationId()
configureAndroidApplication()
}

private fun Project.configureAndroidCommonInfo() = configure<BaseExtension> {
Expand Down Expand Up @@ -103,7 +103,7 @@ class GamedgeAndroidPlugin : Plugin<Project> {
}
}

private fun Project.configureAndroidApplicationId() {
private fun Project.configureAndroidApplication() {
plugins.withId(libs.plugins.androidApplication.get().pluginId) {
configure<BaseAppModuleExtension> {
namespace = APPLICATION_ID
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package com.paulrybitskyi.gamedge.plugins

import com.android.build.api.dsl.LibraryExtension
import com.paulrybitskyi.gamedge.extensions.libs
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.configure

class GamedgeRemoteApiPlugin : Plugin<Project> {

override fun apply(project: Project) = with(project) {
setupPlugins()
configurePlugins()
addDependencies()
}

private fun Project.setupPlugins(): Unit = with(plugins) {
apply(libs.plugins.androidLibrary.get().pluginId)
apply(libs.plugins.gamedgeAndroid.get().pluginId)
apply(libs.plugins.gamedgeDaggerHilt.get().pluginId)
apply(libs.plugins.kotlinxSerialization.get().pluginId)
}

private fun Project.configurePlugins() {
configure<LibraryExtension> {
buildFeatures {
buildConfig = true
}
}
}

private fun Project.addDependencies(): Unit = with(dependencies) {
add("api", project(localModules.commonApi))
add("implementation", project(localModules.core))

add("implementation", libs.coroutines.get())
add("implementation", libs.kotlinxSerialization.get())
add("implementation", libs.retrofit.get())
add("implementation", libs.kotlinResult.get())

add("testImplementation", project(localModules.commonTesting))
add("testImplementation", libs.jUnit.get())
add("testImplementation", libs.truth.get())
add("testImplementation", libs.mockk.get())
add("testImplementation", libs.coroutinesTesting.get())

add("androidTestImplementation", libs.testRunner.get())
add("androidTestImplementation", libs.jUnitExt.get())
add("androidTestImplementation", libs.truth.get())
add("androidTestImplementation", libs.mockWebServer.get())
}
}
1 change: 1 addition & 0 deletions database/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ plugins {
id(libs.plugins.gamedgeAndroid.get().pluginId)
id(libs.plugins.gamedgeDaggerHilt.get().pluginId)

alias(libs.plugins.ksp)
alias(libs.plugins.kotlinxSerialization)
}

Expand Down
30 changes: 1 addition & 29 deletions gamespot-api/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,7 @@ import com.paulrybitskyi.gamedge.extensions.property
import com.paulrybitskyi.gamedge.extensions.stringField

plugins {
id(libs.plugins.androidLibrary.get().pluginId)
id(libs.plugins.gamedgeAndroid.get().pluginId)
id(libs.plugins.gamedgeDaggerHilt.get().pluginId)

alias(libs.plugins.kotlinxSerialization)
id(libs.plugins.gamedgeRemoteApi.get().pluginId)
}

android {
Expand All @@ -31,32 +27,8 @@ android {
defaultConfig {
stringField("GAMESPOT_API_KEY", property("GAMESPOT_API_KEY", ""))
}

buildFeatures {
buildConfig = true
}
}

dependencies {
api(project(localModules.commonApi))
implementation(project(localModules.core))

implementation(libs.coroutines)
implementation(libs.kotlinxSerialization)

implementation(libs.retrofit)
implementation(libs.retrofitKotlinxSerializationConverter)

implementation(libs.kotlinResult)

testImplementation(project(localModules.commonTesting))
testImplementation(libs.jUnit)
testImplementation(libs.truth)
testImplementation(libs.mockk)
testImplementation(libs.coroutinesTesting)

androidTestImplementation(libs.testRunner)
androidTestImplementation(libs.jUnitExt)
androidTestImplementation(libs.truth)
androidTestImplementation(libs.mockWebServer)
}
1 change: 1 addition & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ gamedgeAndroid = { id = "com.paulrybitskyi.gamedge.android" }
gamedgeProtobuf = { id = "com.paulrybitskyi.gamedge.protobuf" }
gamedgeJetpackCompose = { id = "com.paulrybitskyi.gamedge.jetpack.compose" }
gamedgeDaggerHilt = { id = "com.paulrybitskyi.gamedge.dagger.hilt" }
gamedgeRemoteApi = { id = "com.paulrybitskyi.gamedge.remote.api" }
gamedgeFeature = { id = "com.paulrybitskyi.gamedge.feature" }

[libraries]
Expand Down
29 changes: 1 addition & 28 deletions igdb-api/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,7 @@ import com.paulrybitskyi.gamedge.extensions.property
import com.paulrybitskyi.gamedge.extensions.stringField

plugins {
id(libs.plugins.androidLibrary.get().pluginId)
id(libs.plugins.gamedgeAndroid.get().pluginId)
id(libs.plugins.gamedgeDaggerHilt.get().pluginId)

alias(libs.plugins.kotlinxSerialization)
id(libs.plugins.gamedgeRemoteApi.get().pluginId)
}

android {
Expand All @@ -32,33 +28,10 @@ android {
stringField("TWITCH_APP_CLIENT_ID", property("TWITCH_APP_CLIENT_ID", ""))
stringField("TWITCH_APP_CLIENT_SECRET", property("TWITCH_APP_CLIENT_SECRET", ""))
}

buildFeatures {
buildConfig = true
}
}

dependencies {
api(project(localModules.commonApi))
implementation(project(localModules.igdbApicalypse))
implementation(project(localModules.core))

implementation(libs.coroutines)
implementation(libs.kotlinxSerialization)

implementation(libs.retrofit)
implementation(libs.retrofitScalarsConverter)

implementation(libs.kotlinResult)

testImplementation(project(localModules.commonTesting))
testImplementation(libs.jUnit)
testImplementation(libs.truth)
testImplementation(libs.mockk)
testImplementation(libs.coroutinesTesting)

androidTestImplementation(libs.testRunner)
androidTestImplementation(libs.jUnitExt)
androidTestImplementation(libs.truth)
androidTestImplementation(libs.mockWebServer)
}

0 comments on commit aaa891b

Please sign in to comment.