From d995c5d49a0c35ee23b58d2496a749ef623028f7 Mon Sep 17 00:00:00 2001 From: Matej Trakal Date: Thu, 15 May 2025 11:50:37 +0200 Subject: [PATCH] Support again Intellij IDEA IDEs not only Android Studio --- DEVELOP.md | 18 ++++++++- build.gradle.kts | 38 ++++++++++++++----- gradle.properties | 2 + .../adbidea/adb/DeviceResultFetcher.kt | 6 +-- src/main/resources/META-INF/plugin.xml | 1 - 5 files changed, 50 insertions(+), 15 deletions(-) diff --git a/DEVELOP.md b/DEVELOP.md index be766492..e7db35ab 100644 --- a/DEVELOP.md +++ b/DEVELOP.md @@ -14,6 +14,22 @@ Running from command line ./gradlew runIde ``` +Override running IDE +-------------------- + +* Create `local.properties` file in root directory of the project with content: +``` +# Uncomment when you want to use local IDE instead install specified IDE by ideOverride +#localIdePath=C:\\Users\\[USER]\\AppData\\Local\\Programs\\IntelliJ IDEA Ultimate + +# Allowed types +# IU - Intellij Idea Ultimate +# IC - Intellij Idea Community +# IA - Android Studio +ideOverride=IU +``` +* Select which IDE you want to use or uncomment `localIdePath` and specify the path to IDE. + Create new menu item ==================== @@ -31,4 +47,4 @@ Create new menu item * Add new entry in `QuickListAction.kt` like this ```kotlin addAction("com.developerphil.adbidea.action.NewAction", group) -``` \ No newline at end of file +``` diff --git a/build.gradle.kts b/build.gradle.kts index 29f4008c..a1d65143 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -9,7 +9,7 @@ plugins { id("org.jetbrains.kotlin.jvm") version "2.1.0" // https://github.com/JetBrains/intellij-platform-gradle-plugin - id("org.jetbrains.intellij.platform") version "2.4.0" + id("org.jetbrains.intellij.platform") version "2.6.0" // https://github.com/ajoberstar/reckon id("org.ajoberstar.reckon") version "0.14.0" @@ -78,14 +78,35 @@ localIdePath?.let { dependencies { intellijPlatform { - bundledPlugin("org.jetbrains.android") - instrumentationTools() - if (project.hasProperty("localIdeOverride")) { - local(property("localIdeOverride").toString()) - } else { - androidStudio(property("ideVersion").toString()) + val version = property("ideVersion").toString() + val ide = property("ideOverride").toString() + val pluginVersion = property("sinceBuild").toString() + + when { + localIdePath?.isNotBlank() == true -> { + // We don't recognize if it's local Android Studio or Idea. + // In case that's Android Studio, it's required to replace the line with: + // bundledPlugin("org.jetbrains.android") + plugin("org.jetbrains.android:$pluginVersion") + local(localPath = localIdePath.toString()) + } + + ide == "IC" -> { + plugin("org.jetbrains.android:$pluginVersion") + intellijIdeaCommunity(version) + } + + ide == "IU" -> { + plugin("org.jetbrains.android:$pluginVersion") + intellijIdeaUltimate(version) + } + + else -> { + // Only for Android studio itself: https://github.com/JetBrains/intellij-platform-gradle-plugin/issues/1843#issuecomment-2658420485 + bundledPlugin("org.jetbrains.android") + androidStudio(version) + } } - } implementation("org.jooq:joor:0.9.15") @@ -107,4 +128,3 @@ fun recentChanges(outputType: Changelog.OutputType): String { return s } - diff --git a/gradle.properties b/gradle.properties index 07b16180..73d9af3f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,6 +4,8 @@ ideVersion=2025.1.1.2 # Minimum Intellij PLatform version supported by this plugin # see https://plugins.jetbrains.com/docs/intellij/android-studio-releases-list.html +# Versions used by IntelliJ IDEA IDEs +# https://plugins.jetbrains.com/plugin/22989-android/versions sinceBuild=251.23774.16 # The path to a local Android Studio installation. diff --git a/src/main/kotlin/com/developerphil/adbidea/adb/DeviceResultFetcher.kt b/src/main/kotlin/com/developerphil/adbidea/adb/DeviceResultFetcher.kt index ee43fcec..455226cd 100644 --- a/src/main/kotlin/com/developerphil/adbidea/adb/DeviceResultFetcher.kt +++ b/src/main/kotlin/com/developerphil/adbidea/adb/DeviceResultFetcher.kt @@ -1,9 +1,8 @@ package com.developerphil.adbidea.adb import com.android.ddmlib.IDevice -import com.android.tools.idea.insights.isAndroidApp import com.android.tools.idea.model.AndroidModel -import com.android.tools.idea.projectsystem.gradle.getHolderModule +import com.android.tools.idea.projectsystem.getHolderModule import com.android.tools.idea.util.androidFacet import com.developerphil.adbidea.adb.DeviceResult.DeviceNotFound import com.developerphil.adbidea.adb.DeviceResult.SuccessfulDeviceResult @@ -58,7 +57,6 @@ class DeviceResultFetcher( private fun getFacet(facets: List): AndroidFacet? { val appFacets = facets .map { HolderModuleGetter(it).get() } - .filter { it.isAndroidApp } .mapNotNull { it.androidFacet } .distinct() @@ -115,4 +113,4 @@ sealed class DeviceResult { data object Cancelled : DeviceResult() data object DeviceNotFound : DeviceResult() -} \ No newline at end of file +} diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index 8233f91e..74c34fc1 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -33,7 +33,6 @@ ]]> com.intellij.modules.platform - com.intellij.modules.androidstudio org.jetbrains.android