From 8f9cb126db81230d2c53a0c6e7cf9b72361c9bac Mon Sep 17 00:00:00 2001 From: Lamberto Basti Date: Wed, 29 Nov 2023 16:11:15 +0100 Subject: [PATCH] Preparing for 233 publication --- .github/workflows/build.yml | 14 +- .github/workflows/publish-release.yml | 25 ++++ .github/workflows/publish-snapshot.yml | 24 ++++ .space.kts | 123 ------------------ build.gradle.kts | 11 +- buildSrc/build.gradle.kts | 1 + .../gradle/ConfigureGradleIntellijPlugin.kt | 3 +- gradle.properties | 3 +- plugin/build.gradle.kts | 66 +++++----- plugin/core/build.gradle.kts | 25 ++++ .../PackageSearchProjectCachesService.kt | 14 +- .../PackageSearchGradleModelBuilder.java | 28 ---- .../PackageSearchGradleModelBuilder.java | 21 ++- .../PackageSearchApplicationCachesService.kt | 8 +- .../services/PackageSearchProjectService.kt | 11 +- .../plugin/ui/model/NoModulesFoundViewMode.kt | 16 +-- .../plugin/ui/model/ToolWindowViewModel.kt | 15 +-- .../ui/model/infopanel/InfoPanelViewModel.kt | 16 +-- .../packageslist/PackageListViewModel.kt | 14 +- .../plugin/ui/model/tree/TreeViewModel.kt | 26 +--- .../plugin/utils/LogExtensions.kt | 2 +- .../packagesearch/plugin/utils/Utils.kt | 2 +- settings.gradle.kts | 8 -- 23 files changed, 164 insertions(+), 312 deletions(-) create mode 100644 .github/workflows/publish-release.yml create mode 100644 .github/workflows/publish-snapshot.yml delete mode 100644 .space.kts delete mode 100644 plugin/gradle/tooling/src/233Main/java/com/jetbrains/packagesearch/plugin/gradle/tooling/PackageSearchGradleModelBuilder.java diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 77e5834f..8872a3a9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,22 +1,20 @@ name: Build Package Search -on: [push] +on: [ push, pull_request ] jobs: build: - strategy: - matrix: - supported-ij-version: [232, 233, 241] runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up JDK 17 uses: actions/setup-java@v3 with: java-version: '17' distribution: 'zulu' cache: gradle - - name: Grant execute permission for gradlew - run: chmod +x gradlew + - uses: gradle/gradle-build-action@v2 - name: Run :buildShadowPlugin task - run: ./gradlew :plugin:buildShadowPlugin -PintelliJversion=${{ matrix.supported-ij-version }} + run: ./gradlew :plugin:buildShadowPlugin + env: + GRADLE_ENTERPRISE_KEY: ${{ secrets.GRADLE_ENTERPRISE_KEY }} diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml new file mode 100644 index 00000000..572fed95 --- /dev/null +++ b/.github/workflows/publish-release.yml @@ -0,0 +1,25 @@ +name: Build Package Search + +on: + release: + types: [published] + +jobs: + publish: + name: Publish Package Search to Marketplace + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + submodules: true + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'zulu' + - uses: gradle/gradle-build-action@v2 + - name: Run :publishShadowPlugin task + run: ./gradlew :plugin:publishShadowPluginToMarketplace + env: + MARKETPLACE_TOKEN: ${{ secrets.MARKETPLACE_TOKEN }} + GRADLE_ENTERPRISE_KEY: ${{ secrets.GRADLE_ENTERPRISE_KEY }} diff --git a/.github/workflows/publish-snapshot.yml b/.github/workflows/publish-snapshot.yml new file mode 100644 index 00000000..55c35a20 --- /dev/null +++ b/.github/workflows/publish-snapshot.yml @@ -0,0 +1,24 @@ +name: Build Package Search + +on: + push: + branches: [ master ] + +jobs: + publish: + name: Publish Package Search Snapshot to TBE + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'zulu' + cache: gradle + - uses: gradle/gradle-build-action@v2 + - name: Run :publishShadowPlugin task + run: ./gradlew :plugin:publishShadowPlugin + env: + TOOLBOX_ENTERPRISE_TOKEN: ${{ secrets.TOOLBOX_ENTERPRISE_TOKEN }} + GRADLE_ENTERPRISE_KEY: ${{ secrets.GRADLE_ENTERPRISE_KEY }} diff --git a/.space.kts b/.space.kts deleted file mode 100644 index 8885cdec..00000000 --- a/.space.kts +++ /dev/null @@ -1,123 +0,0 @@ -import circlet.pipelines.script.ScriptApi -import java.io.File -import java.time.LocalDate.now - -job("Publish jar snapshots") { - startOn { - gitPush { - enabled = true - anyBranchMatching { +"master" } - } - } - // DO NOT USE THE gradlew FUNCTION! - // gradlew uses a container which isolates the git configuration - // of the host machine. Our gradle build interacts with git! - host("Run Gradle") { - shellScript { - content = "./gradlew publish" - } - env["IS_SNAPSHOT"] = "true" - env["MAVEN_SPACE_USERNAME"] = "{{ project:jetbrains_team_registry_username }}" - env["MAVEN_SPACE_PASSWORD"] = "{{ project:jetbrains_team_registry_key }}" - env["GRADLE_ENTERPRISE_KEY"] = "{{ project:gradle_enterprise_access_key }}" - env["TOOLBOX_ENTERPRISE_TOKEN"] = "{{ project:toolbox-enterprise-token }}" - env["CI"] = "true" - } -} - -job("Publish plugin nightly") { - startOn { - schedule { - // triggers every day, runs only in the master branch - cron("0 8 * * *") - } - } - - host("Run Gradle") { - - env["MAVEN_SPACE_USERNAME"] = "{{ project:jetbrains_team_registry_username }}" - env["MAVEN_SPACE_PASSWORD"] = "{{ project:jetbrains_team_registry_key }}" - env["GRADLE_ENTERPRISE_KEY"] = "{{ project:gradle_enterprise_access_key }}" - env["TOOLBOX_ENTERPRISE_TOKEN"] = "{{ project:toolbox-enterprise-token }}" - env["CI"] = "true" - - kotlinScript { api -> - val now = now() - val pluginSnapshotVersion = "${now.year}.10.${now.dayOfYear}" - val targetIdentifier = TargetIdentifier.Key("pkgs-plugin-snapshot-deploy") - api.space().projects.automation.deployments.start( - project = api.projectIdentifier(), - targetIdentifier = targetIdentifier, - version = pluginSnapshotVersion, - // automatically update deployment status based on a status of a job - syncWithAutomationJob = true - ) - - val isSuccess = listOf("232", "233", "241").all { - api.runCatchingGradlew { - task(":plugin:publishShadowPlugin") - task("publish") - param("pluginVersion", pluginSnapshotVersion) - param("intelliJVersion", it) - } - } - - val buildScanLink = File(".") - .walkTopDown() - .maxDepth(2) - .find { it.name == "build-scan-url.txt" } - ?.readLines() - ?.first() - - when { - !isSuccess -> { - val channel = ChannelIdentifier.Channel(ChatChannel.FromName("package-search-notifications")) - val text = buildString { - appendLine("[pkgs-plugin-v2] Build failed: ${api.executionUrl()}") - if (buildScanLink != null) { - append(" | Build scan: $buildScanLink") - } - } - val content = ChatMessage.Text(text) - api.space().chats.messages.sendMessage(channel = channel, content = content) - error("Build failed") - } - - else -> api.space().projects.automation.deployments.update( - project = api.projectIdentifier(), - targetIdentifier = targetIdentifier, - deploymentIdentifier = DeploymentIdentifier.Version(pluginSnapshotVersion), - externalLink = buildScanLink?.let { ExternalLink("Build scan", it) } - ) - } - } - } -} - -class GradleCommandBuilder { - private val tasks = mutableListOf() - private val args = mutableMapOf() - private val params = mutableMapOf() - - fun task(name: String) { - tasks.add(name) - } - - fun arg(name: String, value: String) { - args[name] = value - } - - fun param(name: String, value: String) { - params[name] = value - } - - fun build(): List = buildList { - addAll(tasks) - args.forEach { (name, value) -> add("-D$name=$value") } - params.forEach { (name, value) -> add("-P$name=$value") } - } -} - -inline fun ScriptApi.runCatchingGradlew(builder: GradleCommandBuilder.() -> Unit) = - runCatching { gradlew(*GradleCommandBuilder().apply(builder).build().toTypedArray()) } - .isSuccess \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index 8ab5d36f..f870e301 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,6 +1,9 @@ @file:Suppress("UnstableApiUsage") -import java.time.LocalDate +import java.lang.System.getenv +import kotlinx.datetime.Clock +import kotlinx.datetime.TimeZone +import kotlinx.datetime.toLocalDateTime import org.jetbrains.packagesearch.gradle.pkgsSpace plugins { @@ -11,8 +14,10 @@ plugins { allprojects { group = "org.jetbrains.packagesearch" - version = project.properties["pluginVersion"]?.toString() - ?: "2.0.0" + version = when (val ref = getenv("GITHUB_REF")) { + null -> "2.0.0-SNAPSHOT" + else -> ref.substringAfterLast("/") + } repositories { mavenCentral() diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 17199620..27a63437 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -30,4 +30,5 @@ dependencies { implementation(packageSearchCatalog.kotlinx.serialization.json) implementation("com.squareup:kotlinpoet:1.14.2") implementation("io.github.pdvrieze.xmlutil:serialization:0.86.2") + implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.4.1") } diff --git a/buildSrc/src/main/kotlin/org/jetbrains/packagesearch/gradle/ConfigureGradleIntellijPlugin.kt b/buildSrc/src/main/kotlin/org/jetbrains/packagesearch/gradle/ConfigureGradleIntellijPlugin.kt index e8be1088..81d2a96c 100644 --- a/buildSrc/src/main/kotlin/org/jetbrains/packagesearch/gradle/ConfigureGradleIntellijPlugin.kt +++ b/buildSrc/src/main/kotlin/org/jetbrains/packagesearch/gradle/ConfigureGradleIntellijPlugin.kt @@ -15,7 +15,7 @@ fun Project.configureGradleIntellijPlugin(packageSearchExtension: PackageSearchE plugins.withId("org.jetbrains.intellij") { extensions.withType { - version = "2023.2.5" + version = "233-EAP-SNAPSHOT" instrumentCode = false downloadSources = !isCI } @@ -32,6 +32,7 @@ fun Project.configureGradleIntellijPlugin(packageSearchExtension: PackageSearchE && !it.name.containsAny(packageSearchExtension.librariesToKeep.get()) } exclude { it.name == "module-info.class" } + exclude { it.name.endsWith("kotlin_module") } } named("prepareSandbox") { pluginJar = shadowJar.flatMap { it.archiveFile } diff --git a/gradle.properties b/gradle.properties index 77cfd196..c0748d80 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,4 +3,5 @@ org.gradle.jvmargs=-Xmx10g kotlin.native.ignoreDisabledTargets=true org.gradle.java.installations.auto-detect=false kotlin.incremental.useClasspathSnapshot=false -org.gradle.parallel=true \ No newline at end of file +org.gradle.parallel=true +pkgsPluginId = "com.jetbrains.packagesearch.intellij-plugin" \ No newline at end of file diff --git a/plugin/build.gradle.kts b/plugin/build.gradle.kts index ba32b19b..4d8be40a 100644 --- a/plugin/build.gradle.kts +++ b/plugin/build.gradle.kts @@ -1,7 +1,9 @@ @file:Suppress("UnstableApiUsage") +import kotlinx.datetime.Clock +import kotlinx.datetime.TimeZone +import kotlinx.datetime.toLocalDateTime import org.jetbrains.intellij.tasks.PublishPluginTask -import org.jetbrains.packagesearch.gradle.GeneratePackageSearchObject import org.jetbrains.packagesearch.gradle.lafFile import org.jetbrains.packagesearch.gradle.logCategoriesFile import org.jetbrains.packagesearch.gradle.patchLafFile @@ -51,7 +53,7 @@ dependencies { implementation(compose.desktop.macos_x64) implementation(compose.desktop.windows_x64) implementation(packageSearchCatalog.kotlinx.serialization.core) - implementation(packageSearchCatalog.jewel.bridge.ij232) + implementation(packageSearchCatalog.jewel.bridge.ij233) implementation(packageSearchCatalog.ktor.client.logging) implementation(packageSearchCatalog.packagesearch.api.models) implementation(projects.plugin.gradle.base) @@ -71,13 +73,7 @@ dependencies { testRuntimeOnly(packageSearchCatalog.junit.jupiter.engine) } -val pkgsPluginId = "com.jetbrains.packagesearch.intellij-plugin" - -val generatedDir: Provider = layout.buildDirectory.dir("generated/main/kotlin") - -kotlin.sourceSets.main { - kotlin.srcDirs(generatedDir) -} +val pkgsPluginId: String by project tasks { val patchIdeSettings by registering { @@ -96,36 +92,39 @@ tasks { runIde { dependsOn(patchIdeSettings) } - val generatePluginDataSources by registering(GeneratePackageSearchObject::class) { - pluginId = pkgsPluginId - outputDir = generatedDir - packageName = "com.jetbrains.packagesearch.plugin" - } - sourcesJar { - dependsOn(generatePluginDataSources) - } - dokkaHtml { - dependsOn(generatePluginDataSources) - } - shadowJar { - archiveBaseName = "packagesearch-plugin" - } prepareSandbox { runtimeClasspathFiles = tooling } - compileKotlin { - dependsOn(generatePluginDataSources) + val snapshotDateSuffix = buildString { + val now = Clock.System.now().toLocalDateTime(TimeZone.UTC) + append(now.year) + append(now.monthNumber) + append(now.dayOfMonth) + append(now.hour.toString().padStart(2, '0')) + append(now.minute.toString().padStart(2, '0')) + append(now.second.toString().padStart(2, '0')) } patchPluginXml { pluginId = pkgsPluginId - sinceBuild = "232.*" - untilBuild = "232.*" + version = when { + project.version.toString().endsWith("-SNAPSHOT") -> "${project.version}-$snapshotDateSuffix" + else -> project.version.toString() + } } - val buildShadowPlugin by registering(Zip::class) { group = "intellij" - from(shadowJar, tooling, jarSearchableOptions) - into("com.jetbrains.packagesearch.intellij-plugin/lib") // <-- ONLY ONE into()! + from(shadowJar) { + rename { + "package-search-plugin" + when { + it.endsWith("-SNAPSHOT.jar") -> it.replace(".jar", "-$snapshotDateSuffix.jar") + else -> it + } + } + } + from(tooling) { + rename { "gradle-tooling.jar" } + } + into("$pkgsPluginId/lib") archiveFileName.set("packagesearch-plugin.zip") destinationDirectory = layout.buildDirectory.dir("distributions") } @@ -140,4 +139,11 @@ tasks { channels = listOf("Stable") } + register("publishShadowPluginToMarketplace") { + group = "publishing" + distributionFile = buildShadowPlugin.flatMap { it.archiveFile } + token = project.properties["marketplaceToken"]?.toString() + ?: System.getenv("MARKETPLACE_TOKEN") + } + } diff --git a/plugin/core/build.gradle.kts b/plugin/core/build.gradle.kts index 09193bb0..981fb2a0 100644 --- a/plugin/core/build.gradle.kts +++ b/plugin/core/build.gradle.kts @@ -1,5 +1,8 @@ @file:Suppress("UnstableApiUsage") +import org.jetbrains.packagesearch.gradle.GeneratePackageSearchObject + + plugins { id(packageSearchCatalog.plugins.kotlin.jvm) id(packageSearchCatalog.plugins.dokka) @@ -31,8 +34,30 @@ dependencies { testImplementation(kotlin("test-junit5")) } +val generatedDir: Provider = layout.buildDirectory.dir("generated/main/kotlin") + +kotlin.sourceSets.main { + kotlin.srcDirs(generatedDir) +} + +val pkgsPluginId: String by project + tasks { withType { environment("DB_PATH", layout.buildDirectory.file("tests/cache.db").get().asFile.absolutePath) } + val generatePluginDataSources by registering(GeneratePackageSearchObject::class) { + pluginId = pkgsPluginId + outputDir = generatedDir + packageName = "com.jetbrains.packagesearch.plugin.core" + } + sourcesJar { + dependsOn(generatePluginDataSources) + } + dokkaHtml { + dependsOn(generatePluginDataSources) + } + compileKotlin { + dependsOn(generatePluginDataSources) + } } \ No newline at end of file diff --git a/plugin/core/src/main/kotlin/com/jetbrains/packagesearch/plugin/core/services/PackageSearchProjectCachesService.kt b/plugin/core/src/main/kotlin/com/jetbrains/packagesearch/plugin/core/services/PackageSearchProjectCachesService.kt index f6ba3024..03d704e6 100644 --- a/plugin/core/src/main/kotlin/com/jetbrains/packagesearch/plugin/core/services/PackageSearchProjectCachesService.kt +++ b/plugin/core/src/main/kotlin/com/jetbrains/packagesearch/plugin/core/services/PackageSearchProjectCachesService.kt @@ -5,17 +5,24 @@ import com.intellij.openapi.components.Service import com.intellij.openapi.components.Service.Level import com.intellij.openapi.project.Project import com.intellij.openapi.project.getProjectDataPath +import com.jetbrains.packagesearch.plugin.core.PackageSearch import com.jetbrains.packagesearch.plugin.core.nitrite.buildDefaultNitrate import com.jetbrains.packagesearch.plugin.core.utils.PKGSInternalAPI import kotlin.io.path.absolutePathString +import kotlin.io.path.div @Service(Level.PROJECT) -class PackageSearchProjectCachesService(project: Project ) : Disposable { +class PackageSearchProjectCachesService(private val project: Project) : Disposable { + + private val cacheFilePath + get() = cachesDirectory / "db-${PackageSearch.pluginVersion}.db" + + private val cachesDirectory + get() = project.getProjectDataPath("caches") / "packagesearch" @PKGSInternalAPI val cache = buildDefaultNitrate( - path = project.getProjectDataPath("packagesearch") - .resolve("cache.db") + path = cacheFilePath .apply { parent.toFile().mkdirs() } .absolutePathString() ) @@ -28,4 +35,3 @@ class PackageSearchProjectCachesService(project: Project ) : Disposable { cache.getRepository(key) } - diff --git a/plugin/gradle/tooling/src/233Main/java/com/jetbrains/packagesearch/plugin/gradle/tooling/PackageSearchGradleModelBuilder.java b/plugin/gradle/tooling/src/233Main/java/com/jetbrains/packagesearch/plugin/gradle/tooling/PackageSearchGradleModelBuilder.java deleted file mode 100644 index 9e9e1522..00000000 --- a/plugin/gradle/tooling/src/233Main/java/com/jetbrains/packagesearch/plugin/gradle/tooling/PackageSearchGradleModelBuilder.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.jetbrains.packagesearch.plugin.gradle.tooling; - -import org.gradle.api.Project; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.plugins.gradle.tooling.ErrorMessageBuilder; -import org.jetbrains.plugins.gradle.tooling.Message; -import org.jetbrains.plugins.gradle.tooling.ModelBuilderContext; - -@SuppressWarnings("ALL") -public class PackageSearchGradleModelBuilder extends AbstractPackageSearchGradleModelBuilder { - - @NotNull - @Override - public void reportErrorMessage( - @NotNull String modelName, - @NotNull Project project, - @NotNull ModelBuilderContext context, - @NotNull Exception exception - ) { - context.getMessageReporter() - .createMessage() - .withException(exception) - .withKind(Message.Kind.ERROR) - .withGroup("gradle.packageSearch") - .withText("Error while building Package Search Gradle model") - .reportMessage(project); - } -} diff --git a/plugin/gradle/tooling/src/main/java/com/jetbrains/packagesearch/plugin/gradle/tooling/PackageSearchGradleModelBuilder.java b/plugin/gradle/tooling/src/main/java/com/jetbrains/packagesearch/plugin/gradle/tooling/PackageSearchGradleModelBuilder.java index 5edae905..b6ba7fb2 100644 --- a/plugin/gradle/tooling/src/main/java/com/jetbrains/packagesearch/plugin/gradle/tooling/PackageSearchGradleModelBuilder.java +++ b/plugin/gradle/tooling/src/main/java/com/jetbrains/packagesearch/plugin/gradle/tooling/PackageSearchGradleModelBuilder.java @@ -10,6 +10,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.plugins.gradle.tooling.AbstractModelBuilderService; import org.jetbrains.plugins.gradle.tooling.ErrorMessageBuilder; +import org.jetbrains.plugins.gradle.tooling.Message; import org.jetbrains.plugins.gradle.tooling.ModelBuilderContext; import java.util.ArrayList; @@ -99,14 +100,20 @@ public boolean canBuild(String modelName) { return modelName.equals(PackageSearchGradleJavaModel.class.getName()); } - @NotNull @Override - public ErrorMessageBuilder getErrorMessageBuilder(@NotNull Project project, @NotNull Exception e) { - return ErrorMessageBuilder - .create(project, e, "Gradle import errors") - .withDescription("Unable to import resolved versions " + - "from configurations in project ''${project.name}'' for" + - " the Dependencies toolwindow."); + public void reportErrorMessage( + @NotNull String modelName, + @NotNull Project project, + @NotNull ModelBuilderContext context, + @NotNull Exception exception + ) { + context.getMessageReporter() + .createMessage() + .withException(exception) + .withKind(Message.Kind.ERROR) + .withGroup("gradle.packageSearch") + .withText("Error while building Package Search Gradle model") + .reportMessage(project); } } diff --git a/plugin/src/main/kotlin/com/jetbrains/packagesearch/plugin/services/PackageSearchApplicationCachesService.kt b/plugin/src/main/kotlin/com/jetbrains/packagesearch/plugin/services/PackageSearchApplicationCachesService.kt index 9112bbd3..ac383374 100644 --- a/plugin/src/main/kotlin/com/jetbrains/packagesearch/plugin/services/PackageSearchApplicationCachesService.kt +++ b/plugin/src/main/kotlin/com/jetbrains/packagesearch/plugin/services/PackageSearchApplicationCachesService.kt @@ -10,8 +10,8 @@ import com.intellij.openapi.application.appSystemDir import com.intellij.openapi.components.Service import com.intellij.openapi.components.Service.Level import com.intellij.openapi.components.service -import com.jetbrains.packagesearch.plugin.PackageSearch import com.jetbrains.packagesearch.plugin.PackageSearchBundle +import com.jetbrains.packagesearch.plugin.core.PackageSearch import com.jetbrains.packagesearch.plugin.core.nitrite.buildDefaultNitrate import com.jetbrains.packagesearch.plugin.core.nitrite.div import com.jetbrains.packagesearch.plugin.core.utils.PKGSInternalAPI @@ -47,9 +47,6 @@ import org.jetbrains.packagesearch.api.v3.http.PackageSearchEndpoints @Service(Level.APP) class PackageSearchApplicationCachesService(private val coroutineScope: CoroutineScope) : Disposable, RecoveryAction { - // for 232 compatibility - constructor() : this(CoroutineScope(SupervisorJob())) - companion object { private val cacheFilePath get() = appSystemDir / "caches" / "packagesearch" / "db-${PackageSearch.pluginVersion}.db" @@ -65,9 +62,6 @@ class PackageSearchApplicationCachesService(private val coroutineScope: Coroutin override fun dispose() { cache.close() - if ("232" in PackageSearch.intelliJVersion) { - coroutineScope.cancel() - } } private inline fun getRepository(key: String) = diff --git a/plugin/src/main/kotlin/com/jetbrains/packagesearch/plugin/services/PackageSearchProjectService.kt b/plugin/src/main/kotlin/com/jetbrains/packagesearch/plugin/services/PackageSearchProjectService.kt index 86e1ca21..6ebf2c54 100644 --- a/plugin/src/main/kotlin/com/jetbrains/packagesearch/plugin/services/PackageSearchProjectService.kt +++ b/plugin/src/main/kotlin/com/jetbrains/packagesearch/plugin/services/PackageSearchProjectService.kt @@ -10,7 +10,6 @@ import com.intellij.openapi.components.Service.Level import com.intellij.openapi.project.Project import com.intellij.openapi.vfs.toNioPathOrNull import com.intellij.psi.PsiManager -import com.jetbrains.packagesearch.plugin.PackageSearch import com.jetbrains.packagesearch.plugin.PackageSearchModuleBaseTransformerUtils import com.jetbrains.packagesearch.plugin.core.extensions.PackageSearchKnownRepositoriesContext import com.jetbrains.packagesearch.plugin.core.utils.IntelliJApplication @@ -52,10 +51,7 @@ import org.jetbrains.packagesearch.api.v3.ApiRepository class PackageSearchProjectService( override val project: Project, override val coroutineScope: CoroutineScope, -) : PackageSearchKnownRepositoriesContext, Disposable { - - // for 232 compatibility - constructor(project: Project) : this(project, CoroutineScope(SupervisorJob())) +) : PackageSearchKnownRepositoriesContext { private val restartChannel = Channel() @@ -155,11 +151,6 @@ class PackageSearchProjectService( .launchIn(coroutineScope) } - override fun dispose() { - if ("232" in PackageSearch.intelliJVersion) { - coroutineScope.cancel() - } - } } diff --git a/plugin/src/main/kotlin/com/jetbrains/packagesearch/plugin/ui/model/NoModulesFoundViewMode.kt b/plugin/src/main/kotlin/com/jetbrains/packagesearch/plugin/ui/model/NoModulesFoundViewMode.kt index 72ad2b5d..2e6caa08 100644 --- a/plugin/src/main/kotlin/com/jetbrains/packagesearch/plugin/ui/model/NoModulesFoundViewMode.kt +++ b/plugin/src/main/kotlin/com/jetbrains/packagesearch/plugin/ui/model/NoModulesFoundViewMode.kt @@ -1,18 +1,13 @@ package com.jetbrains.packagesearch.plugin.ui.model -import com.intellij.dependencytoolwindow.extensionsFlow -import com.intellij.openapi.Disposable import com.intellij.openapi.components.Service import com.intellij.openapi.externalSystem.ExternalSystemManager import com.intellij.openapi.externalSystem.importing.ImportSpecBuilder import com.intellij.openapi.externalSystem.util.ExternalSystemUtil import com.intellij.openapi.project.Project -import com.jetbrains.packagesearch.plugin.PackageSearch import com.jetbrains.packagesearch.plugin.core.utils.availableExtensionsFlow import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.SupervisorJob -import kotlinx.coroutines.cancel import kotlinx.coroutines.flow.SharingStarted import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.stateIn @@ -22,10 +17,7 @@ import kotlinx.coroutines.launch class NoModulesFoundViewMode( private val project: Project, private val viewModelScope: CoroutineScope, -) : Disposable { - - // for 232 compatibility - constructor(project: Project) : this(project, CoroutineScope(SupervisorJob())) +) { val isRefreshing = project.isProjectSyncing .stateIn(viewModelScope, SharingStarted.WhileSubscribed(), false) @@ -46,11 +38,5 @@ class NoModulesFoundViewMode( .forEach { ExternalSystemUtil.refreshProjects(it) } } } - - override fun dispose() { - if ("232" in PackageSearch.intelliJVersion) { - viewModelScope.cancel() - } - } } \ No newline at end of file diff --git a/plugin/src/main/kotlin/com/jetbrains/packagesearch/plugin/ui/model/ToolWindowViewModel.kt b/plugin/src/main/kotlin/com/jetbrains/packagesearch/plugin/ui/model/ToolWindowViewModel.kt index 9978cc68..c257deb4 100644 --- a/plugin/src/main/kotlin/com/jetbrains/packagesearch/plugin/ui/model/ToolWindowViewModel.kt +++ b/plugin/src/main/kotlin/com/jetbrains/packagesearch/plugin/ui/model/ToolWindowViewModel.kt @@ -1,11 +1,9 @@ package com.jetbrains.packagesearch.plugin.ui.model -import com.intellij.openapi.Disposable import com.intellij.openapi.components.Service import com.intellij.openapi.components.Service.Level import com.intellij.openapi.components.service import com.intellij.openapi.project.Project -import com.jetbrains.packagesearch.plugin.PackageSearch import com.jetbrains.packagesearch.plugin.PackageSearchBundle.message import com.jetbrains.packagesearch.plugin.core.utils.smartModeFlow import com.jetbrains.packagesearch.plugin.ui.bridge.openLinkInBrowser @@ -14,8 +12,6 @@ import com.jetbrains.packagesearch.plugin.utils.PackageSearchProjectService import kotlin.random.Random import kotlin.time.Duration.Companion.milliseconds import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.SupervisorJob -import kotlinx.coroutines.cancel import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.SharingStarted import kotlinx.coroutines.flow.combine @@ -24,10 +20,7 @@ import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.stateIn @Service(Level.PROJECT) -class ToolWindowViewModel(project: Project, private val viewModelScope: CoroutineScope) : Disposable { - - // for 232 compatibility - constructor(project: Project) : this(project, CoroutineScope(SupervisorJob())) +class ToolWindowViewModel(project: Project, private val viewModelScope: CoroutineScope) { fun openLinkInBrowser(url: String) { viewModelScope.openLinkInBrowser(url) @@ -71,11 +64,5 @@ class ToolWindowViewModel(project: Project, private val viewModelScope: Coroutin started = SharingStarted.Lazily, initialValue = PackageSearchToolWindowState.Loading(message = easterEggMessage) ) - - override fun dispose() { - if ("232" in PackageSearch.intelliJVersion) { - viewModelScope.cancel() - } - } } diff --git a/plugin/src/main/kotlin/com/jetbrains/packagesearch/plugin/ui/model/infopanel/InfoPanelViewModel.kt b/plugin/src/main/kotlin/com/jetbrains/packagesearch/plugin/ui/model/infopanel/InfoPanelViewModel.kt index 1208121e..0fb50cff 100644 --- a/plugin/src/main/kotlin/com/jetbrains/packagesearch/plugin/ui/model/infopanel/InfoPanelViewModel.kt +++ b/plugin/src/main/kotlin/com/jetbrains/packagesearch/plugin/ui/model/infopanel/InfoPanelViewModel.kt @@ -1,20 +1,16 @@ package com.jetbrains.packagesearch.plugin.ui.model.infopanel import androidx.compose.foundation.ScrollState -import com.intellij.openapi.Disposable import com.intellij.openapi.components.Service import com.intellij.openapi.components.Service.Level import com.intellij.openapi.components.service import com.intellij.openapi.project.Project -import com.jetbrains.packagesearch.plugin.PackageSearch import com.jetbrains.packagesearch.plugin.core.data.PackageSearchDeclaredPackage import com.jetbrains.packagesearch.plugin.core.data.PackageSearchModule import com.jetbrains.packagesearch.plugin.ui.model.packageslist.PackageListItem import com.jetbrains.packagesearch.plugin.ui.model.packageslist.PackageListViewModel import com.jetbrains.packagesearch.plugin.utils.PackageSearchProjectService import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.SupervisorJob -import kotlinx.coroutines.cancel import kotlinx.coroutines.channels.Channel import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.SharingStarted @@ -32,11 +28,8 @@ import org.jetbrains.packagesearch.api.v3.ApiPackage @Service(Level.PROJECT) class InfoPanelViewModel( private val project: Project, - private val viewModelScope: CoroutineScope, -) : Disposable { - - // for 232 compatibility - constructor(project: Project) : this(project, CoroutineScope(SupervisorJob())) + viewModelScope: CoroutineScope, +) { private val setDataEventChannel = Channel() @@ -142,11 +135,6 @@ class InfoPanelViewModel( ) } - override fun dispose() { - if ("232" in PackageSearch.intelliJVersion) { - viewModelScope.cancel() - } - } } diff --git a/plugin/src/main/kotlin/com/jetbrains/packagesearch/plugin/ui/model/packageslist/PackageListViewModel.kt b/plugin/src/main/kotlin/com/jetbrains/packagesearch/plugin/ui/model/packageslist/PackageListViewModel.kt index b4df6c90..5f234573 100644 --- a/plugin/src/main/kotlin/com/jetbrains/packagesearch/plugin/ui/model/packageslist/PackageListViewModel.kt +++ b/plugin/src/main/kotlin/com/jetbrains/packagesearch/plugin/ui/model/packageslist/PackageListViewModel.kt @@ -1,7 +1,6 @@ package com.jetbrains.packagesearch.plugin.ui.model.packageslist import androidx.compose.foundation.lazy.LazyListState -import com.intellij.openapi.Disposable import com.intellij.openapi.components.Service import com.intellij.openapi.components.Service.Level import com.intellij.openapi.components.service @@ -9,7 +8,6 @@ import com.intellij.openapi.fileEditor.FileEditorManager import com.intellij.openapi.fileEditor.OpenFileDescriptor import com.intellij.openapi.project.Project import com.intellij.openapi.vfs.LocalFileSystem -import com.jetbrains.packagesearch.plugin.PackageSearch import com.jetbrains.packagesearch.plugin.core.data.PackageSearchDependencyManager import com.jetbrains.packagesearch.plugin.core.data.PackageSearchModule import com.jetbrains.packagesearch.plugin.core.data.PackageSearchModuleEditor @@ -28,8 +26,6 @@ import com.jetbrains.packagesearch.plugin.utils.searchPackages import kotlin.time.Duration.Companion.milliseconds import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.SupervisorJob -import kotlinx.coroutines.cancel import kotlinx.coroutines.channels.Channel import kotlinx.coroutines.delay import kotlinx.coroutines.flow.MutableStateFlow @@ -56,10 +52,7 @@ import org.jetbrains.packagesearch.api.v3.search.buildSearchParameters class PackageListViewModel( private val project: Project, private val viewModelScope: CoroutineScope, -) : Disposable { - - // for 232 compatibility - constructor(project: Project) : this(project, CoroutineScope(SupervisorJob())) +) { private val isOnline get() = IntelliJApplication.PackageSearchApplicationCachesService @@ -621,9 +614,4 @@ class PackageListViewModel( } } - override fun dispose() { - if ("232" in PackageSearch.intelliJVersion) { - viewModelScope.cancel() - } - } } diff --git a/plugin/src/main/kotlin/com/jetbrains/packagesearch/plugin/ui/model/tree/TreeViewModel.kt b/plugin/src/main/kotlin/com/jetbrains/packagesearch/plugin/ui/model/tree/TreeViewModel.kt index 4adcda44..b1815893 100644 --- a/plugin/src/main/kotlin/com/jetbrains/packagesearch/plugin/ui/model/tree/TreeViewModel.kt +++ b/plugin/src/main/kotlin/com/jetbrains/packagesearch/plugin/ui/model/tree/TreeViewModel.kt @@ -1,43 +1,27 @@ package com.jetbrains.packagesearch.plugin.ui.model.tree import androidx.compose.foundation.lazy.LazyListState -import com.intellij.openapi.Disposable import com.intellij.openapi.components.Service import com.intellij.openapi.components.Service.Level import com.intellij.openapi.project.Project -import com.jetbrains.packagesearch.plugin.PackageSearch -import com.jetbrains.packagesearch.plugin.core.data.PackageSearchModule import com.jetbrains.packagesearch.plugin.core.utils.IntelliJApplication -import com.jetbrains.packagesearch.plugin.ui.model.hasUpdates import com.jetbrains.packagesearch.plugin.utils.PackageSearchApplicationCachesService import com.jetbrains.packagesearch.plugin.utils.PackageSearchProjectService import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.SupervisorJob -import kotlinx.coroutines.cancel import kotlinx.coroutines.flow.SharingStarted import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.combine -import kotlinx.coroutines.flow.flowOn -import kotlinx.coroutines.flow.launchIn -import kotlinx.coroutines.flow.onEach -import kotlinx.coroutines.flow.runningFold import kotlinx.coroutines.flow.stateIn import org.jetbrains.jewel.foundation.lazy.SelectableLazyListState import org.jetbrains.jewel.foundation.lazy.tree.Tree -import org.jetbrains.jewel.foundation.lazy.tree.TreeGeneratorScope import org.jetbrains.jewel.foundation.lazy.tree.TreeState -import org.jetbrains.jewel.foundation.lazy.tree.buildTree import org.jetbrains.jewel.foundation.lazy.tree.emptyTree @Service(Level.PROJECT) internal class TreeViewModel( project: Project, - private val viewModelScope: CoroutineScope, -) : Disposable { - - // for 232 compatibility - constructor(project: Project) : this(project, CoroutineScope(SupervisorJob())) + viewModelScope: CoroutineScope, +) { val tree: StateFlow> = combine( project.PackageSearchProjectService.modulesStateFlow, @@ -62,11 +46,5 @@ internal class TreeViewModel( treeState.openNodes = emptySet() } - override fun dispose() { - if ("232" in PackageSearch.intelliJVersion) { - viewModelScope.cancel() - } - } - } diff --git a/plugin/src/main/kotlin/com/jetbrains/packagesearch/plugin/utils/LogExtensions.kt b/plugin/src/main/kotlin/com/jetbrains/packagesearch/plugin/utils/LogExtensions.kt index b901ce50..3032b3dc 100644 --- a/plugin/src/main/kotlin/com/jetbrains/packagesearch/plugin/utils/LogExtensions.kt +++ b/plugin/src/main/kotlin/com/jetbrains/packagesearch/plugin/utils/LogExtensions.kt @@ -21,7 +21,7 @@ package com.jetbrains.packagesearch.plugin.utils import com.intellij.openapi.diagnostic.Logger import com.intellij.openapi.progress.ProcessCanceledException import com.jetbrains.packagesearch.plugin.FeatureFlags -import com.jetbrains.packagesearch.plugin.PackageSearch +import com.jetbrains.packagesearch.plugin.core.PackageSearch import java.util.concurrent.atomic.AtomicBoolean import kotlinx.coroutines.CancellationException diff --git a/plugin/src/main/kotlin/com/jetbrains/packagesearch/plugin/utils/Utils.kt b/plugin/src/main/kotlin/com/jetbrains/packagesearch/plugin/utils/Utils.kt index 801bc323..5395f555 100644 --- a/plugin/src/main/kotlin/com/jetbrains/packagesearch/plugin/utils/Utils.kt +++ b/plugin/src/main/kotlin/com/jetbrains/packagesearch/plugin/utils/Utils.kt @@ -29,7 +29,7 @@ internal val Project.nativeModules: List get() = ModuleManager.getInstance(this).modules.toList() internal val Project.nativeModulesFlow: FlowWithInitialValue> - get() = messageBus.flow(ProjectTopics.MODULES) { + get() = messageBus.flow(ModuleListener.TOPIC) { object : ModuleListener { override fun modulesAdded(project: Project, modules: NativeModules) { trySend(nativeModules) diff --git a/settings.gradle.kts b/settings.gradle.kts index bf0bf6cd..2884cbb6 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -17,14 +17,6 @@ dependencyResolutionManagement { } } -if (file(".gitsubmoduleinit").run { !exists() }) { - logger.lifecycle("Initializing git submodules") - exec { - commandLine("git", "submodule", "update", "--init") - } - file(".gitsubmoduleinit").writeText("stub") -} - include( ":nitrite", ":plugin",