Revert "fix: configure Dagger Hilt for DI"

This reverts commit 874d32bc4c.
This commit is contained in:
Akash Yadav
2024-06-19 09:07:30 +05:30
parent c806ece666
commit 788ae2dfaf
12 changed files with 16 additions and 153 deletions
-1
View File
@@ -37,7 +37,6 @@ plugins {
alias(libs.plugins.gradle.publish) apply false
alias(libs.plugins.protobuf) apply false
alias(libs.plugins.benchmark) apply false
alias(libs.plugins.hilt) apply false
}
buildscript {
@@ -37,7 +37,6 @@ dependencies {
implementation(projects.buildLogic.propertiesParser)
implementation("com.android.tools.build:gradle:${libs.versions.agp.asProvider().get()}")
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:${libs.versions.kotlin.asProvider().get()}")
implementation(libs.maven.publish)
implementation(libs.common.jkotlin)
@@ -40,10 +40,7 @@ class AndroidIDEPlugin : Plugin<Project> {
return@run
}
// Apply dependency injection for all modules
plugins.apply(DIConfigPlugin::class.java)
if (this.isAndroidModule && !isFDroidBuild) {
if (isAndroidModule && !isFDroidBuild) {
// setup signing configuration
plugins.apply(SigningConfigPlugin::class.java)
}
@@ -58,7 +55,7 @@ class AndroidIDEPlugin : Plugin<Project> {
}
val taskName = when {
this.isAndroidModule -> "testDebugUnitTest"
isAndroidModule -> "testDebugUnitTest"
else -> "test"
}
@@ -1,42 +0,0 @@
/*
* This file is part of AndroidIDE.
*
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* AndroidIDE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*/
package com.itsaky.androidide.plugins
import com.itsaky.androidide.plugins.util.isAndroidModule
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.artifacts.VersionCatalogsExtension
/**
* Configures dependency injection in a module.
*
* @author Akash Yadav
*/
class DIConfigPlugin : Plugin<Project> {
override fun apply(target: Project) = target.run {
dependencies.add("implementation", "javax.inject:javax.inject:1")
if (isAndroidModule) {
val libs =
rootProject.extensions.getByType(VersionCatalogsExtension::class.java).named("libs")
val hiltAndroid = libs.findLibrary("hilt-android").get().get()
dependencies.add("implementation", hiltAndroid)
}
Unit
}
}
-6
View File
@@ -13,7 +13,6 @@ plugins {
id("realm-android")
id("androidx.navigation.safeargs.kotlin")
id("com.itsaky.androidide.desugaring")
id("com.google.dagger.hilt.android")
}
apply {
@@ -59,8 +58,6 @@ kapt {
arguments {
arg("eventBusIndex", "${BuildConfig.packageName}.events.AppEventsIndex")
}
correctErrorTypes = true
}
desugaring {
@@ -79,7 +76,6 @@ dependencies {
// Annotation processors
kapt(libs.common.glide.ap)
kapt(libs.google.auto.service)
kapt(libs.hilt.compiler)
kapt(projects.annotation.processors)
implementation(libs.common.editor)
@@ -96,8 +92,6 @@ dependencies {
implementation(libs.google.gson)
implementation(libs.google.guava)
implementation(libs.hilt.android)
// Git
implementation(libs.git.jgit)
@@ -102,7 +102,6 @@ import com.itsaky.androidide.viewmodel.EditorViewModel
import com.itsaky.androidide.xml.resources.ResourceTableRegistry
import com.itsaky.androidide.xml.versions.ApiVersionsRegistry
import com.itsaky.androidide.xml.widgets.WidgetTableRegistry
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import org.greenrobot.eventbus.Subscribe
@@ -119,7 +118,6 @@ import kotlin.math.roundToLong
* @author Akash Yadav
*/
@Suppress("MemberVisibilityCanBePrivate")
@AndroidEntryPoint
abstract class BaseEditorActivity : EdgeToEdgeIDEActivity(), TabLayout.OnTabSelectedListener,
DiagnosticClickListener {
@@ -454,7 +454,7 @@ abstract class ProjectHandlerActivity : BaseEditorActivity() {
buildServiceConnection.onConnected = null
editorViewModel.isBoundToBuildSerice = true
Lookup.getDefault().update(BuildService.KEY_BUILD_SERVICE, service)
service.setEventListener(mBuildEventListener)
if (!service.isToolingServerStarted()) {
@@ -58,7 +58,6 @@ import com.itsaky.androidide.utils.VMUtils
import com.itsaky.androidide.utils.flashError
import com.termux.app.TermuxApplication
import com.termux.shared.reflection.ReflectionUtils
import dagger.hilt.android.HiltAndroidApp
import io.github.rosemoe.sora.widget.schemes.EditorColorScheme
import io.realm.Realm
import kotlinx.coroutines.DelicateCoroutinesApi
@@ -72,7 +71,7 @@ import java.lang.Thread.UncaughtExceptionHandler
import java.time.Duration
import kotlin.system.exitProcess
@HiltAndroidApp
class IDEApplication : TermuxApplication() {
private var uncaughtExceptionHandler: UncaughtExceptionHandler? = null
@@ -1,30 +0,0 @@
/*
* This file is part of AndroidIDE.
*
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* AndroidIDE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*/
package com.itsaky.androidide.di
import dagger.Module
import dagger.hilt.InstallIn
import dagger.hilt.android.components.ActivityComponent
/**
* @author Akash Yadav
*/
@Module
@InstallIn(ActivityComponent::class)
abstract class ActivityModule {
}
@@ -1,30 +0,0 @@
/*
* This file is part of AndroidIDE.
*
* AndroidIDE is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* AndroidIDE is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
*/
package com.itsaky.androidide.di
import dagger.Module
import dagger.hilt.InstallIn
import dagger.hilt.android.components.ActivityComponent
/**
* @author Akash Yadav
*/
@Module
@InstallIn(ActivityComponent::class)
abstract class EditorActivityModule {
}
@@ -59,7 +59,6 @@ import com.itsaky.androidide.tooling.api.models.ToolingServerMetadata
import com.itsaky.androidide.tooling.events.ProgressEvent
import com.itsaky.androidide.utils.Environment
import com.termux.shared.termux.shell.command.environment.TermuxShellEnvironment
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.CoroutineName
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
@@ -79,7 +78,6 @@ import java.util.concurrent.TimeUnit
*
* @author Akash Yadav
*/
@AndroidEntryPoint
class GradleBuildService : Service(), BuildService, IToolingApiClient,
ToolingServerRunner.Observer {
@@ -102,8 +100,7 @@ class GradleBuildService : Service(), BuildService, IToolingApiClient,
private var eventListener: EventListener? = null
private val buildServiceScope = CoroutineScope(
Dispatchers.Default + CoroutineName("GradleBuildService")
)
Dispatchers.Default + CoroutineName("GradleBuildService"))
private val isGradleWrapperAvailable: Boolean
get() {
@@ -125,6 +122,7 @@ class GradleBuildService : Service(), BuildService, IToolingApiClient,
}
companion object {
private val log = LoggerFactory.getLogger(GradleBuildService::class.java)
private val NOTIFICATION_ID = R.string.app_name
private val SERVER_System_err = LoggerFactory.getLogger("ToolingApiErrorStream")
@@ -140,10 +138,8 @@ class GradleBuildService : Service(), BuildService, IToolingApiClient,
return isToolingServerStarted && server != null
}
private fun showNotification(
message: String,
@Suppress("SameParameterValue") isProgress: Boolean
) {
private fun showNotification(message: String,
@Suppress("SameParameterValue") isProgress: Boolean) {
log.info("Showing notification to user...")
createNotificationChannels()
startForeground(NOTIFICATION_ID, buildNotification(message, isProgress))
@@ -153,8 +149,7 @@ class GradleBuildService : Service(), BuildService, IToolingApiClient,
val buildNotificationChannel = NotificationChannel(
BaseApplication.NOTIFICATION_GRADLE_BUILD_SERVICE,
getString(string.title_gradle_service_notification_channel),
NotificationManager.IMPORTANCE_LOW
)
NotificationManager.IMPORTANCE_LOW)
NotificationManagerCompat.from(this)
.createNotificationChannel(buildNotificationChannel)
}
@@ -320,8 +315,7 @@ class GradleBuildService : Service(), BuildService, IToolingApiClient,
override fun checkGradleWrapperAvailability(): CompletableFuture<GradleWrapperCheckResult> {
return if (isGradleWrapperAvailable) CompletableFuture.completedFuture(
GradleWrapperCheckResult(true)
) else installWrapper()
GradleWrapperCheckResult(true)) else installWrapper()
}
internal fun setServerListener(listener: OnServerStartListener?) {
@@ -341,10 +335,8 @@ class GradleBuildService : Service(), BuildService, IToolingApiClient,
private fun doInstallWrapper(): GradleWrapperCheckResult {
val extracted = File(Environment.TMP_DIR, "gradle-wrapper.zip")
if (!ResourceUtils.copyFileFromAssets(
ToolsManager.getCommonAsset("gradle-wrapper.zip"),
extracted.absolutePath
)
if (!ResourceUtils.copyFileFromAssets(ToolsManager.getCommonAsset("gradle-wrapper.zip"),
extracted.absolutePath)
) {
log.error("Unable to extract gradle-plugin.zip from IDE resources.")
return GradleWrapperCheckResult(false)
@@ -366,10 +358,8 @@ class GradleBuildService : Service(), BuildService, IToolingApiClient,
}
private fun doUpdateNotification(message: String, isProgress: Boolean) {
(getSystemService(NOTIFICATION_SERVICE) as NotificationManager).notify(
NOTIFICATION_ID,
buildNotification(message, isProgress)
)
(getSystemService(NOTIFICATION_SERVICE) as NotificationManager).notify(NOTIFICATION_ID,
buildNotification(message, isProgress))
}
override fun metadata(): CompletableFuture<ToolingServerMetadata> {
@@ -378,8 +368,7 @@ class GradleBuildService : Service(), BuildService, IToolingApiClient,
}
override fun initializeProject(
params: InitializeProjectParams
): CompletableFuture<InitializeResult> {
params: InitializeProjectParams): CompletableFuture<InitializeResult> {
checkServerStarted()
Objects.requireNonNull(params)
return performBuildTasks(server!!.initialize(params))
@@ -492,8 +481,7 @@ class GradleBuildService : Service(), BuildService, IToolingApiClient,
}
outputReaderJob = buildServiceScope.launch(
Dispatchers.IO + CoroutineName("ToolingServerErrorReader")
) {
Dispatchers.IO + CoroutineName("ToolingServerErrorReader")) {
val reader = input.bufferedReader()
try {
reader.forEachLine { line ->
-9
View File
@@ -21,7 +21,6 @@ logback = "1.5.3"
realm = "10.18.0"
benchmark = "1.2.4"
benchmark-junit4 = "1.2.4"
hilt = "2.51.1"
[libraries]
@@ -76,13 +75,6 @@ common-hiddenApiBypass = { module = "org.lsposed.hiddenapibypass:hiddenapibypass
common-termuxAmLib = { module = "com.termux:termux-am-library", version = "v2.0.0" }
common-charts = { module = "com.github.AppDevNext:AndroidChart", version = "3.1.0.21" }
# Dependency Injection
## DO NOT REMOVE
## Accessed programmatically in DIConfigPlugin
## Update DIConfigPlugin if renamed
hilt-android = { module = "com.google.dagger:hilt-android", version.ref = "hilt" }
hilt-compiler = { module = "com.google.dagger:hilt-compiler", version.ref = "hilt" }
# AndroidX
androidx-annotation = { module = "androidx.annotation:annotation", version = "1.7.1" }
androidx-appcompat = { module = "androidx.appcompat:appcompat", version = "1.6.1" }
@@ -187,4 +179,3 @@ maven-publish = { id = "com.vanniktech.maven.publish.base", version.ref = "maven
gradle-publish = { id = "com.gradle.plugin-publish", version = "1.2.1" }
protobuf = { id = "com.google.protobuf", version = "0.9.4" }
benchmark = { id = "androidx.benchmark", version.ref = "benchmark" }
hilt = { id = "com.google.dagger.hilt.android", version.ref = "hilt" }