mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-16 14:23:28 +07:00
Revert "PKGS-951 Resolve configurations from Gradle sync for PKGS"
GitOrigin-RevId: 43dc630da0f01dbbe279c4014629a6b08d8b6a46
This commit is contained in:
committed by
intellij-monorepo-bot
parent
fb0825f2ad
commit
f9563fd4f3
12
.idea/libraries/kotlinx_serialization_protobuf.xml
generated
12
.idea/libraries/kotlinx_serialization_protobuf.xml
generated
@@ -1,12 +0,0 @@
|
||||
<component name="libraryTable">
|
||||
<library name="kotlinx-serialization-protobuf" type="repository">
|
||||
<properties include-transitive-deps="false" maven-id="org.jetbrains.kotlinx:kotlinx-serialization-protobuf-jvm:1.3.3" />
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlinx/kotlinx-serialization-protobuf-jvm/1.3.3/kotlinx-serialization-protobuf-jvm-1.3.3.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlinx/kotlinx-serialization-protobuf-jvm/1.3.3/kotlinx-serialization-protobuf-jvm-1.3.3-sources.jar!/" />
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
||||
1
.idea/modules.xml
generated
1
.idea/modules.xml
generated
@@ -760,7 +760,6 @@
|
||||
<module fileurl="file://$PROJECT_DIR$/plugins/package-search/intellij.packageSearch.iml" filepath="$PROJECT_DIR$/plugins/package-search/intellij.packageSearch.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/plugins/package-search/compat/intellij.packageSearch.compat.iml" filepath="$PROJECT_DIR$/plugins/package-search/compat/intellij.packageSearch.compat.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/plugins/package-search/gradle/intellij.packageSearch.gradle.iml" filepath="$PROJECT_DIR$/plugins/package-search/gradle/intellij.packageSearch.gradle.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/plugins/package-search/gradleTooling/intellij.packageSearch.gradleTooling.iml" filepath="$PROJECT_DIR$/plugins/package-search/gradleTooling/intellij.packageSearch.gradleTooling.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/plugins/package-search/kotlin/intellij.packageSearch.kotlin.iml" filepath="$PROJECT_DIR$/plugins/package-search/kotlin/intellij.packageSearch.kotlin.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/plugins/package-search/maven/intellij.packageSearch.maven.iml" filepath="$PROJECT_DIR$/plugins/package-search/maven/intellij.packageSearch.maven.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/platform/analysis-api/intellij.platform.analysis.iml" filepath="$PROJECT_DIR$/platform/analysis-api/intellij.platform.analysis.iml" />
|
||||
|
||||
@@ -146,7 +146,6 @@
|
||||
<orderEntry type="module" module-name="intellij.space.java.jps" scope="TEST" />
|
||||
<orderEntry type="module" module-name="intellij.packageSearch" scope="RUNTIME" />
|
||||
<orderEntry type="module" module-name="intellij.packageSearch.gradle" scope="RUNTIME" />
|
||||
<orderEntry type="module" module-name="intellij.packageSearch.gradleTooling" scope="RUNTIME" />
|
||||
<orderEntry type="module" module-name="intellij.packageSearch.kotlin" scope="RUNTIME" />
|
||||
<orderEntry type="module" module-name="intellij.packageSearch.maven" scope="RUNTIME" />
|
||||
<orderEntry type="module" module-name="intellij.emojipicker" scope="RUNTIME" />
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<facet type="kotlin-language" name="Kotlin">
|
||||
<configuration version="5" platform="JVM 17" allPlatforms="JVM [17]" useProjectSettings="false">
|
||||
<compilerSettings>
|
||||
<option name="additionalArguments" value="-Xjvm-default=enable -opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi -opt-in=kotlin.ExperimentalStdlibApi -opt-in=kotlinx.coroutines.FlowPreview -opt-in=kotlin.time.ExperimentalTime -opt-in=kotlinx.serialization.ExperimentalSerializationApi" />
|
||||
<option name="additionalArguments" value="-Xjvm-default=enable -opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi -opt-in=kotlin.ExperimentalStdlibApi -opt-in=kotlinx.coroutines.FlowPreview -opt-in=kotlin.time.ExperimentalTime" />
|
||||
</compilerSettings>
|
||||
<compilerArguments>
|
||||
<stringArguments>
|
||||
@@ -41,7 +41,5 @@
|
||||
<orderEntry type="module" module-name="intellij.platform.ide" />
|
||||
<orderEntry type="module" module-name="intellij.platform.projectModel.impl" />
|
||||
<orderEntry type="module" module-name="intellij.platform.statistics" />
|
||||
<orderEntry type="module" module-name="intellij.packageSearch.gradleTooling" />
|
||||
<orderEntry type="library" name="kotlinx-serialization-protobuf" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -33,8 +33,6 @@
|
||||
<packagesearch.coroutineModuleTransformer
|
||||
implementation="com.jetbrains.packagesearch.intellij.plugin.gradle.GradleModuleTransformer"/>
|
||||
|
||||
<externalProjectDataService implementation="com.jetbrains.packagesearch.intellij.plugin.gradle.GradleConfigurationReportNodeProcessor"/>
|
||||
|
||||
<packagesearch.flowModuleChangesSignalProvider
|
||||
implementation="com.jetbrains.packagesearch.intellij.plugin.gradle.SmartModeSignalProvider"/>
|
||||
|
||||
@@ -56,9 +54,6 @@
|
||||
<projectService
|
||||
serviceImplementation="com.jetbrains.packagesearch.intellij.plugin.gradle.configuration.PackageSearchGradleConfiguration"/>
|
||||
</extensions>
|
||||
<extensions defaultExtensionNs="org.jetbrains.plugins.gradle">
|
||||
<projectResolve implementation="com.jetbrains.packagesearch.intellij.plugin.gradle.GradleConfigurationResolver"/>
|
||||
</extensions>
|
||||
|
||||
<actions>
|
||||
<action id="PackageSearch.Gradle.DependencyAnalyzer.GoTo"
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
/*******************************************************************************
|
||||
* Copyright 2000-2022 JetBrains s.r.o. and contributors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
******************************************************************************/
|
||||
|
||||
package com.jetbrains.packagesearch.intellij.plugin.gradle
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class ConfigurationReport(
|
||||
val configurationName: String,
|
||||
val dependencies: List<Dependency>
|
||||
) {
|
||||
|
||||
@Serializable
|
||||
data class Dependency(val groupId: String, val artifactId: String, val version: String)
|
||||
}
|
||||
@@ -1,131 +0,0 @@
|
||||
package com.jetbrains.packagesearch.intellij.plugin.gradle
|
||||
|
||||
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.externalSystem.model.DataNode
|
||||
import com.intellij.openapi.externalSystem.model.Key
|
||||
import com.intellij.openapi.externalSystem.model.project.ModuleData
|
||||
import com.intellij.openapi.externalSystem.model.project.ProjectData
|
||||
import com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProvider
|
||||
import com.intellij.openapi.externalSystem.service.project.manage.AbstractProjectDataService
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.project.getProjectDataPath
|
||||
import com.intellij.util.io.createDirectories
|
||||
import com.intellij.util.io.exists
|
||||
import com.intellij.util.io.readBytes
|
||||
import com.jetbrains.packagesearch.intellij.plugin.gradle.GradleConfigurationReportNodeProcessor.Companion.ESM_REPORTS_KEY
|
||||
import com.jetbrains.packagesearch.intellij.plugin.gradle.tooling.GradleConfigurationModelBuilder
|
||||
import com.jetbrains.packagesearch.intellij.plugin.gradle.tooling.GradleConfigurationReportModel
|
||||
import com.jetbrains.packagesearch.intellij.plugin.util.logDebug
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.builtins.MapSerializer
|
||||
import kotlinx.serialization.builtins.serializer
|
||||
import kotlinx.serialization.protobuf.ProtoBuf
|
||||
import org.gradle.tooling.model.idea.IdeaModule
|
||||
import org.jetbrains.plugins.gradle.service.project.AbstractProjectResolverExtension
|
||||
import kotlin.io.path.absolutePathString
|
||||
import kotlin.io.path.writeBytes
|
||||
|
||||
class GradleConfigurationResolver : AbstractProjectResolverExtension() {
|
||||
|
||||
override fun getExtraProjectModelClasses(): Set<Class<*>> =
|
||||
setOf(GradleConfigurationReportModel::class.java, Unit::class.java)
|
||||
|
||||
override fun getToolingExtensionsClasses(): Set<Class<*>> =
|
||||
setOf(GradleConfigurationModelBuilder::class.java, Unit::class.java)
|
||||
|
||||
private inline fun <reified T> IdeaModule.getExtraProject(): T? =
|
||||
resolverCtx.getExtraProject(this@getExtraProject, T::class.java)
|
||||
|
||||
override fun populateModuleExtraModels(gradleModule: IdeaModule, ideModule: DataNode<ModuleData>) {
|
||||
gradleModule.getExtraProject<GradleConfigurationReportModel>()
|
||||
?.also { ideModule.createChild(ESM_REPORTS_KEY, it.toPublic()) }
|
||||
super.populateModuleExtraModels(gradleModule, ideModule)
|
||||
}
|
||||
}
|
||||
|
||||
class GradleConfigurationReportNodeProcessor : AbstractProjectDataService<PublicGradleConfigurationReportModel, Unit>() {
|
||||
|
||||
companion object {
|
||||
|
||||
internal val ESM_REPORTS_KEY: Key<PublicGradleConfigurationReportModel> =
|
||||
Key.create(PublicGradleConfigurationReportModel::class.java, 100)
|
||||
}
|
||||
|
||||
@Service(Level.PROJECT)
|
||||
class Cache(private val project: Project) : Disposable {
|
||||
|
||||
// TODO when kotlinx.serialization is bumped to 1.4.0 it can be removed
|
||||
// sealed interface serializers do not get retrieved correctly atm otherwise
|
||||
private val serializer
|
||||
get() = MapSerializer(String.serializer(), PublicGradleConfigurationReportModel.serializer())
|
||||
|
||||
private val cacheFile
|
||||
get() = project.getProjectDataPath("pkgs")
|
||||
.also { if (!it.exists()) it.createDirectories() }
|
||||
.resolve("gradle.proto.bin")
|
||||
|
||||
var state = load()
|
||||
internal set
|
||||
|
||||
private fun load(): Map<String, PublicGradleConfigurationReportModel> =
|
||||
cacheFile.takeIf { it.exists() }
|
||||
?.runCatching { ProtoBuf.decodeFromByteArray(serializer, readBytes()) }
|
||||
?.onFailure { logDebug(this::class.qualifiedName+"#load()", it) { "Error while decoding ${cacheFile.absolutePathString()}" } }
|
||||
?.getOrNull()
|
||||
?.let { emptyMap() }
|
||||
?: emptyMap()
|
||||
|
||||
override fun dispose() {
|
||||
cacheFile.writeBytes(ProtoBuf.encodeToByteArray(serializer, state))
|
||||
}
|
||||
}
|
||||
|
||||
override fun getTargetDataKey() = ESM_REPORTS_KEY
|
||||
|
||||
override fun importData(
|
||||
toImport: Collection<DataNode<PublicGradleConfigurationReportModel>>,
|
||||
projectData: ProjectData?,
|
||||
project: Project,
|
||||
modelsProvider: IdeModifiableModelsProvider
|
||||
) {
|
||||
project.service<Cache>().state = toImport.associate { it.data.projectDir to it.data }
|
||||
super.importData(toImport, projectData, project, modelsProvider)
|
||||
}
|
||||
}
|
||||
|
||||
@Serializable
|
||||
data class PublicGradleConfigurationReportModel(
|
||||
val projectDir: String,
|
||||
val configurations: List<Configuration>
|
||||
) {
|
||||
|
||||
@Serializable
|
||||
@SerialName("PublicGradleConfigurationReportModel.Configuration")
|
||||
data class Configuration(
|
||||
val name: String,
|
||||
val dependencies: List<Dependency>
|
||||
)
|
||||
|
||||
@Serializable
|
||||
@SerialName("PublicGradleConfigurationReportModel.Dependency")
|
||||
data class Dependency(
|
||||
val groupId: String,
|
||||
val artifactId: String,
|
||||
val version: String
|
||||
)
|
||||
}
|
||||
|
||||
private fun GradleConfigurationReportModel.toPublic() =
|
||||
PublicGradleConfigurationReportModel(projectDir, configurations.toPublic())
|
||||
|
||||
@JvmName("toPublicGradleConfigurationReportModelConfiguration")
|
||||
private fun List<GradleConfigurationReportModel.Configuration>.toPublic() =
|
||||
map { PublicGradleConfigurationReportModel.Configuration(it.name, it.dependencies.toPublic()) }
|
||||
|
||||
@JvmName("toPublicGradleConfigurationReportModelDependency")
|
||||
private fun List<GradleConfigurationReportModel.Dependency>.toPublic() =
|
||||
map { PublicGradleConfigurationReportModel.Dependency(it.groupId, it.artifactId, it.version) }
|
||||
@@ -14,23 +14,30 @@
|
||||
* limitations under the License.
|
||||
******************************************************************************/
|
||||
|
||||
@file:Suppress("ThrowableNotThrown")
|
||||
|
||||
package com.jetbrains.packagesearch.intellij.plugin.gradle
|
||||
|
||||
import com.intellij.buildsystem.model.OperationFailure
|
||||
import com.intellij.buildsystem.model.OperationItem
|
||||
import com.intellij.buildsystem.model.unified.UnifiedDependency
|
||||
import com.intellij.openapi.components.service
|
||||
import com.intellij.openapi.externalSystem.model.ProjectKeys.MODULE
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.util.io.FileUtil
|
||||
import com.intellij.psi.PsiFile
|
||||
import com.jetbrains.packagesearch.intellij.plugin.PackageSearchBundle
|
||||
import com.jetbrains.packagesearch.intellij.plugin.extensibility.AbstractCoroutineProjectModuleOperationProvider
|
||||
import com.jetbrains.packagesearch.intellij.plugin.extensibility.DependencyOperationMetadata
|
||||
import com.jetbrains.packagesearch.intellij.plugin.extensibility.ProjectModule
|
||||
import com.jetbrains.packagesearch.intellij.plugin.extensibility.ProjectModuleType
|
||||
import com.jetbrains.packagesearch.intellij.plugin.gradle.GradleConfigurationReportNodeProcessor.Companion.ESM_REPORTS_KEY
|
||||
import com.jetbrains.packagesearch.intellij.plugin.gradle.configuration.PackageSearchGradleConfiguration
|
||||
import kotlinx.coroutines.sync.Mutex
|
||||
import kotlinx.coroutines.sync.withLock
|
||||
import kotlinx.serialization.decodeFromString
|
||||
import kotlinx.serialization.json.Json
|
||||
import org.jetbrains.plugins.gradle.execution.build.CachedModuleDataFinder
|
||||
import org.jetbrains.plugins.gradle.util.GradleBundle
|
||||
import java.io.File
|
||||
import kotlin.random.Random
|
||||
|
||||
private const val FILE_TYPE_GROOVY = "groovy"
|
||||
private const val FILE_TYPE_KOTLIN = "kotlin"
|
||||
@@ -54,8 +61,39 @@ internal open class GradleProjectModuleOperationProvider : AbstractCoroutineProj
|
||||
|
||||
fun hasSupportFor(projectModuleType: ProjectModuleType): Boolean =
|
||||
projectModuleType is GradleProjectModuleType
|
||||
|
||||
private fun getDependencyTaskScript(taskName: String, outputFile: File, scopes: Set<String>, gradlePath: String) =
|
||||
// language=Groovy
|
||||
"""
|
||||
allprojects {
|
||||
if (project.path == '${gradlePath}' || ':' + rootProject.projectDir.name + project.path == '$gradlePath}') {
|
||||
tasks.register('${taskName}') {
|
||||
def outputFile = project.file("${FileUtil.toCanonicalPath(outputFile.absolutePath)}")
|
||||
outputs.file(outputFile)
|
||||
doLast {
|
||||
def json = []
|
||||
def scopes = [${scopes.joinToString { "'$it'" }}]
|
||||
for (configuration in configurations) {
|
||||
if (configuration.name in scopes) {
|
||||
def deps = []
|
||||
for (dependency in configuration.allDependencies) {
|
||||
if (dependency.group != null && dependency.version != null) {
|
||||
deps.add([groupId: dependency.group, artifactId: dependency.name, version: dependency.version])
|
||||
}
|
||||
}
|
||||
json.add([configurationName: configuration.name, dependencies: deps])
|
||||
}
|
||||
}
|
||||
outputFile.write(groovy.json.JsonOutput.toJson(json))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
""".trimIndent()
|
||||
}
|
||||
|
||||
private val gradleMutex = Mutex()
|
||||
|
||||
override fun hasSupportFor(project: Project, psiFile: PsiFile?) = Companion.hasSupportFor(psiFile)
|
||||
|
||||
override fun hasSupportFor(projectModuleType: ProjectModuleType): Boolean = Companion.hasSupportFor(projectModuleType)
|
||||
@@ -87,17 +125,34 @@ internal open class GradleProjectModuleOperationProvider : AbstractCoroutineProj
|
||||
configuration.addGradleScope(scopeName)
|
||||
}
|
||||
}
|
||||
override suspend fun resolvedDependenciesInModule(module: ProjectModule, scopes: Set<String>) =
|
||||
module.nativeModule.project
|
||||
.service<GradleConfigurationReportNodeProcessor.Cache>()
|
||||
.state[module.projectDir.absolutePath]
|
||||
?.configurations
|
||||
?.asSequence()
|
||||
?.filter { it.name in scopes }
|
||||
?.flatMap { configuration ->
|
||||
configuration.dependencies.map { UnifiedDependency(it.groupId, it.artifactId, it.version, configuration.name) }
|
||||
}
|
||||
?.toList()
|
||||
?: emptyList()
|
||||
|
||||
override suspend fun resolvedDependenciesInModule(module: ProjectModule, scopes: Set<String>): List<UnifiedDependency> {
|
||||
if (scopes.isEmpty()) return emptyList()
|
||||
val fullGradlePath = CachedModuleDataFinder.getGradleModuleData(module.nativeModule)?.fullGradlePath ?: return emptyList()
|
||||
return getGradleConfigurations(module, fullGradlePath, scopes).flatMap { configuration ->
|
||||
configuration.dependencies.map { UnifiedDependency(it.groupId, it.artifactId, it.version, configuration.configurationName) }
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun getGradleConfigurations(
|
||||
module: ProjectModule,
|
||||
gradlePath: String,
|
||||
scopes: Set<String>
|
||||
): List<ConfigurationReport> {
|
||||
val outputFile = FileUtil.createTempFile("dependencies", ".json", true)
|
||||
val isTaskSuccessful = gradleMutex.withLock {
|
||||
val taskName = "generateDependenciesOutput${Random.nextLong()}"
|
||||
CoroutineGradleTaskManager.runTask(
|
||||
taskScript = getDependencyTaskScript(taskName, outputFile, scopes, gradlePath),
|
||||
taskName = taskName,
|
||||
project = module.nativeModule.project,
|
||||
executionName = GradleBundle.message("gradle.dependency.analyzer.loading"),
|
||||
projectPath = module.projectDir.path,
|
||||
gradlePath = gradlePath
|
||||
)
|
||||
}
|
||||
val result: List<ConfigurationReport> = if (isTaskSuccessful) Json.decodeFromString(outputFile.readText()) else emptyList()
|
||||
outputFile.delete()
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,10 +16,11 @@
|
||||
|
||||
package com.jetbrains.packagesearch.intellij.plugin.gradle
|
||||
|
||||
import com.intellij.openapi.externalSystem.model.DataNode
|
||||
import com.intellij.openapi.externalSystem.model.Key
|
||||
import com.intellij.openapi.components.service
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.util.text.StringUtil
|
||||
import com.jetbrains.packagesearch.intellij.plugin.extensibility.BuildSystemType
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import org.jetbrains.plugins.gradle.util.GradleConstants
|
||||
|
||||
internal fun StringBuilder.appendEscapedToRegexp(text: String) =
|
||||
@@ -43,11 +44,5 @@ val BuildSystemType.Companion.GRADLE_CONTAINER
|
||||
statisticsKey = "gradle"
|
||||
)
|
||||
|
||||
internal fun DataNode<*>.childrenGroupedByKey() = NodesMap(children)
|
||||
|
||||
internal class NodesMap(children: Iterable<DataNode<*>>) {
|
||||
private val map = children.groupBy { it.key }
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
operator fun <T> get(key: Key<T>): List<DataNode<T>> = map[key]?.let { it as List<DataNode<T>> } ?: emptyList()
|
||||
}
|
||||
internal val Project.lifecycleScope: CoroutineScope
|
||||
get() = service<PackageSearchGradleLifecycleScope>()
|
||||
@@ -1,30 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="FacetManager">
|
||||
<facet type="kotlin-language" name="Kotlin">
|
||||
<configuration version="5" platform="JVM 17" allPlatforms="JVM [17]" useProjectSettings="false">
|
||||
<compilerSettings>
|
||||
<option name="additionalArguments" value="-Xjvm-default=enable -opt-in=kotlin.ExperimentalStdlibApi" />
|
||||
</compilerSettings>
|
||||
<compilerArguments>
|
||||
<stringArguments>
|
||||
<stringArg name="jvmTarget" arg="1.8" />
|
||||
<stringArg name="apiVersion" arg="1.7" />
|
||||
<stringArg name="languageVersion" arg="1.7" />
|
||||
</stringArguments>
|
||||
</compilerArguments>
|
||||
</configuration>
|
||||
</facet>
|
||||
</component>
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/resources" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="kotlin-stdlib-jdk8" level="project" />
|
||||
<orderEntry type="module" module-name="intellij.gradle.toolingExtension" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -1,2 +0,0 @@
|
||||
# Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
com.jetbrains.packagesearch.intellij.plugin.gradle.tooling.GradleConfigurationModelBuilder
|
||||
@@ -1,5 +0,0 @@
|
||||
<idea-plugin package="com.jetbrains.packagesearch.intellij.plugin.gradle.tooling" implementation-detail="true">
|
||||
<dependencies>
|
||||
<plugin id="com.intellij.gradle"/>
|
||||
</dependencies>
|
||||
</idea-plugin>
|
||||
@@ -1,114 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* Copyright 2000-2022 JetBrains s.r.o. and contributors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
******************************************************************************/
|
||||
|
||||
package com.jetbrains.packagesearch.intellij.plugin.gradle.tooling
|
||||
|
||||
import com.jetbrains.packagesearch.intellij.plugin.gradle.tooling.GradleConfigurationReportModelImpl.ConfigurationImpl
|
||||
import com.jetbrains.packagesearch.intellij.plugin.gradle.tooling.GradleConfigurationReportModelImpl.DependencyImpl
|
||||
import org.gradle.api.Project
|
||||
import org.jetbrains.plugins.gradle.tooling.AbstractModelBuilderService
|
||||
import org.jetbrains.plugins.gradle.tooling.ErrorMessageBuilder
|
||||
import org.jetbrains.plugins.gradle.tooling.ModelBuilderContext
|
||||
import java.io.Serializable as JavaSerializable
|
||||
|
||||
sealed interface GradleConfigurationReportModel : JavaSerializable {
|
||||
|
||||
companion object {
|
||||
|
||||
internal operator fun invoke(
|
||||
projectDir: String,
|
||||
configurations: List<Configuration>
|
||||
): GradleConfigurationReportModel = GradleConfigurationReportModelImpl(projectDir, configurations)
|
||||
}
|
||||
|
||||
val configurations: List<Configuration>
|
||||
val projectDir: String
|
||||
|
||||
sealed interface Configuration : JavaSerializable {
|
||||
|
||||
val name: String
|
||||
val dependencies: List<Dependency>
|
||||
|
||||
companion object {
|
||||
|
||||
internal operator fun invoke(
|
||||
name: String,
|
||||
dependencies: List<Dependency>
|
||||
): Configuration = ConfigurationImpl(name, dependencies)
|
||||
}
|
||||
}
|
||||
|
||||
sealed interface Dependency : JavaSerializable {
|
||||
|
||||
val groupId: String
|
||||
val artifactId: String
|
||||
val version: String
|
||||
|
||||
companion object {
|
||||
|
||||
internal operator fun invoke(
|
||||
groupId: String,
|
||||
artifactId: String,
|
||||
version: String
|
||||
): Dependency = DependencyImpl(groupId, artifactId, version)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal data class GradleConfigurationReportModelImpl(
|
||||
override val projectDir: String,
|
||||
override val configurations: List<GradleConfigurationReportModel.Configuration>
|
||||
) : GradleConfigurationReportModel {
|
||||
|
||||
internal data class ConfigurationImpl(
|
||||
override val name: String,
|
||||
override val dependencies: List<GradleConfigurationReportModel.Dependency>
|
||||
) : GradleConfigurationReportModel.Configuration
|
||||
|
||||
internal data class DependencyImpl(
|
||||
override val groupId: String,
|
||||
override val artifactId: String,
|
||||
override val version: String
|
||||
) : GradleConfigurationReportModel.Dependency
|
||||
}
|
||||
|
||||
class GradleConfigurationModelBuilder : AbstractModelBuilderService() {
|
||||
|
||||
override fun canBuild(modelName: String?): Boolean =
|
||||
modelName == GradleConfigurationReportModel::class.java.name
|
||||
|
||||
override fun buildAll(modelName: String, project: Project, context: ModelBuilderContext): GradleConfigurationReportModel =
|
||||
GradleConfigurationReportModel(
|
||||
project.projectDir.absolutePath,
|
||||
project.configurations.map {
|
||||
GradleConfigurationReportModel.Configuration(
|
||||
it.name,
|
||||
it.dependencies.mapNotNull { dependency ->
|
||||
project.projectDir
|
||||
GradleConfigurationReportModel.Dependency(
|
||||
groupId = dependency.group ?: return@mapNotNull null,
|
||||
artifactId = dependency.name,
|
||||
version = dependency.version ?: return@mapNotNull null
|
||||
)
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
override fun getErrorMessageBuilder(project: Project, e: Exception): ErrorMessageBuilder =
|
||||
ErrorMessageBuilder
|
||||
.create(project, e, "Gradle import errors")
|
||||
.withDescription("Unable to import resolved versions from configurations in project ''${project.name}'' for the Dependency toolwindow.")
|
||||
}
|
||||
@@ -84,5 +84,5 @@ internal class MavenModuleTransformer : CoroutineModuleTransformer {
|
||||
|
||||
val BuildSystemType.Companion.MAVEN
|
||||
get() = BuildSystemType(
|
||||
name = "MAVEN", language = "xml", dependencyAnalyzerKey = MavenUtil.SYSTEM_ID, statisticsKey = "maven"
|
||||
name = "MAVEN", language = "xml", dependencyAnalyzerKey = MavenUtil.SYSTEM_ID, statisticsKey = "maven"
|
||||
)
|
||||
|
||||
@@ -22,7 +22,6 @@ packagesearch.configuration.recovery.caches=Delete Package Search project caches
|
||||
packagesearch.configuration.recovery.caches.global=Delete Package Search global caches
|
||||
packagesearch.configuration.title=Package Search
|
||||
packagesearch.configuration.update.scopes.on.usage=Save configurations to this list when using them for the first time
|
||||
packagesearch.gradle.sync.errorMessage=Unable to import resolved versions from configurations in project ''{0}'' for the Dependency toolwindow.
|
||||
packagesearch.inspection.range.key.gradle=Check for ranges in dependency versions (Gradle)
|
||||
packagesearch.inspection.range.key.maven=Check for ranges in dependency versions (Maven)
|
||||
packagesearch.inspection.range.description.gradle=Detects whether a dependency version is a range in Gradle projects
|
||||
|
||||
@@ -61,6 +61,7 @@ import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.SharingStarted
|
||||
import kotlinx.coroutines.flow.asFlow
|
||||
import kotlinx.coroutines.flow.combine
|
||||
import kotlinx.coroutines.flow.combineTransform
|
||||
import kotlinx.coroutines.flow.consumeAsFlow
|
||||
import kotlinx.coroutines.flow.filter
|
||||
import kotlinx.coroutines.flow.flatMapLatest
|
||||
@@ -107,7 +108,7 @@ internal class PackageSearchProjectService(private val project: Project) {
|
||||
|
||||
private val cacheDirectory = project.packageSearchProjectCachesService.projectCacheDirectory.resolve("installedDependencies")
|
||||
|
||||
val isLoadingFlow = combine(
|
||||
val isLoadingFlow = combineTransform(
|
||||
projectModulesLoadingFlow,
|
||||
knownRepositoriesLoadingFlow,
|
||||
moduleModelsLoadingFlow,
|
||||
@@ -116,7 +117,7 @@ internal class PackageSearchProjectService(private val project: Project) {
|
||||
installedPackagesStep2LoadingFlow,
|
||||
installedPackagesDifferenceLoadingFlow,
|
||||
packageUpgradesLoadingFlow
|
||||
) { booleans -> booleans.any { it } }
|
||||
) { booleans -> emit(booleans.any { it }) }
|
||||
.stateIn(project.lifecycleScope, SharingStarted.Eagerly, false)
|
||||
|
||||
private val projectModulesSharedFlow = project.trustedProjectFlow
|
||||
@@ -308,4 +309,4 @@ internal class PackageSearchProjectService(private val project: Project) {
|
||||
suspend fun restart() {
|
||||
restartChannel.send(Unit)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,8 +24,7 @@ internal data class PackagesToUpgrade(
|
||||
val upgradesByModule: Map<Module, Set<PackageUpgradeInfo>>
|
||||
) {
|
||||
|
||||
val allUpdates
|
||||
get() = upgradesByModule.values.flatten()
|
||||
val allUpdates by lazy { upgradesByModule.values.flatten() }
|
||||
|
||||
fun getUpdatesForModule(moduleModel: ModuleModel) =
|
||||
upgradesByModule[moduleModel.projectModule.nativeModule]?.toList() ?: emptyList()
|
||||
|
||||
@@ -181,11 +181,8 @@ internal fun <T, R> Flow<T>.mapLatestTimedWithLoading(
|
||||
|
||||
internal fun <T> Flow<T>.catchAndLog(context: String, message: String? = null) =
|
||||
catch {
|
||||
if (message != null) {
|
||||
logDebug(context, it) { message }
|
||||
} else {
|
||||
logDebug(context, it)
|
||||
}
|
||||
if (message!= null) { logDebug(context, it) { message } }
|
||||
else logDebug(context, it)
|
||||
}
|
||||
|
||||
internal suspend inline fun <R> MutableStateFlow<Boolean>.whileLoading(action: () -> R): TimedValue<R> {
|
||||
|
||||
Reference in New Issue
Block a user