[Kotlin] Don't check manifest properties in Kotlin JS stdlib detector

Use name matching as it's done for JVM stdlib.
Allows removing org.jetbrains.kotlin.utils.LibraryUtils in kotlin.git.

Changes:
— Remove LibraryUtils usage and supporting code
— Add tests for watershed versions
— Allow requesting KLIBs from MavenDependencyUtil for the new tests
— Workaround: extract VFGist used for KotlinLibraryKind from the service

A comment about the last workaround. StdlibJsDetectorFacilityTest revealed a
Project leakage. The project is captured by a coroutine context and is hard
referenced through ComponentManager by an application-level virtual file gist
cleanup task. The exact reference chain is not clear, but removing the gist
construction from the service prevents the leakage.

KTIJ-27969

GitOrigin-RevId: 7d6dbe93f4aa3125f5d204a81babcf8483874cb4
This commit is contained in:
Pavel Kirpichenkov
2024-07-18 16:20:26 +03:00
committed by intellij-monorepo-bot
parent 934691271b
commit aae5c6cd9f
5 changed files with 157 additions and 55 deletions

View File

@@ -14,6 +14,7 @@ import com.intellij.openapi.roots.libraries.ui.OrderRoot;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.idea.maven.utils.library.RepositoryLibraryProperties;
import org.jetbrains.jps.model.library.JpsMavenRepositoryLibraryDescriptor;
import java.util.Collection;
import java.util.Collections;
@@ -57,7 +58,7 @@ public final class MavenDependencyUtil {
}
/**
* Adds a Maven library to {@code model}
* Adds a Maven library with the default packaging (JAR) to {@code model}
* @param additionalRepositories additional Maven repositories where the artifacts should be searched (in addition to repositories
* configured in intellij project)
*/
@@ -66,9 +67,24 @@ public final class MavenDependencyUtil {
boolean includeTransitiveDependencies,
DependencyScope dependencyScope,
List<RemoteRepositoryDescription> additionalRepositories) {
addFromMaven(model, mavenCoordinates, includeTransitiveDependencies, dependencyScope, additionalRepositories,
JpsMavenRepositoryLibraryDescriptor.DEFAULT_PACKAGING);
}
/**
* Adds a Maven library to {@code model}
* @param packaging artifact packaging matching {@link org.jetbrains.idea.maven.aether.ArtifactKind} of the requested library
*/
public static void addFromMaven(@NotNull ModifiableRootModel model,
String mavenCoordinates,
boolean includeTransitiveDependencies,
DependencyScope dependencyScope,
List<RemoteRepositoryDescription> additionalRepositories,
@NotNull String packaging) {
List<RemoteRepositoryDescription> remoteRepositoryDescriptions = ContainerUtil.concat(getRemoteRepositoryDescriptions(),
additionalRepositories);
RepositoryLibraryProperties libraryProperties = new RepositoryLibraryProperties(mavenCoordinates, includeTransitiveDependencies);
RepositoryLibraryProperties libraryProperties =
new RepositoryLibraryProperties(mavenCoordinates, packaging, includeTransitiveDependencies);
Collection<OrderRoot> roots =
JarRepositoryManager.loadDependenciesModal(model.getProject(), libraryProperties, false, false, null, remoteRepositoryDescriptions);
LibraryTable.ModifiableModel tableModel = model.getModuleLibraryTable().getModifiableModel();