Skip to content

Commit

Permalink
Store plugins (robot, ide-probe, the tested plugin) in a directory se…
Browse files Browse the repository at this point in the history
…parate from where bundled plugins live (#413)
  • Loading branch information
PawelLipski authored Feb 23, 2024
1 parent 6dd482e commit 34456d9
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ final class LocalIntelliJ(

override def cleanup(): Unit = {
cleanupIdeaProperties()
val pluginsDir = root.resolve("plugins")
val pluginsDir = paths.plugins
pluginsDir.delete()
pluginsBackup.moveTo(pluginsDir)
vmoptions.delete()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ final case class IntelliJPaths(
userPrefs: Path
) {
val bin: Path = root.resolve("bin")
val bundledPlugins = root.resolve("plugins")
val bundledPlugins: Path = root.resolve("plugins")
}

object IntelliJPaths {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ sealed trait IntelliJProvider {
val rootEntries: Set[String] = archive.rootEntries.toSet
}

val targetDir = intelliJ.paths.bundledPlugins
val targetDir = intelliJ.paths.plugins
val archives = withParallel[Plugin, PluginArchive](allPlugins)(_.map { plugin =>
val file = dependencies.plugin.fetch(plugin)
PluginArchive(plugin, file.toExtracted)
Expand Down Expand Up @@ -85,7 +85,7 @@ final case class ExistingIntelliJ(

override def setup(): InstalledIntelliJ = {
val intelliJPaths = IntelliJPaths.fromExistingInstance(path)
val pluginsDir = intelliJPaths.bundledPlugins
val pluginsDir = intelliJPaths.plugins
val backupDir = Files.createTempDirectory(path, "plugins")
val intelliJ = new LocalIntelliJ(path, paths, config, intelliJPaths, backupDir)
pluginsDir.copyDir(backupDir)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ final class IntelliJProviderTest {
@Test
def existingIntelliJShouldRetainItsOriginalPluginsDuringCleanup(): Unit = givenInstalledIntelliJ { installationRoot =>
// given a pre-installed IntelliJ and an IntelliJProvider
val preInstalledPlugins = installationRoot.resolve("plugins").directChildren().toSet
val preInstalledPlugins = installationRoot.resolve("user-plugins").directChildren().toSet

val config = Config.fromString(s"""
|probe.intellij {
Expand All @@ -97,15 +97,15 @@ final class IntelliJProviderTest {
val fixture = IntelliJFixture.fromConfig(config)

val existingIntelliJ = fixture.installIntelliJ()
val installedPlugins = existingIntelliJ.paths.bundledPlugins.directChildren().toSet
val installedPlugins = existingIntelliJ.paths.plugins.directChildren().toSet

assert(installedPlugins.diff(preInstalledPlugins).nonEmpty, "No plugins were installed.")

// when cleanup is called
existingIntelliJ.cleanup()

// then plugins after cleanup should be the same as initially
val pluginsAfterCleanup = existingIntelliJ.paths.bundledPlugins.directChildren().toSet
val pluginsAfterCleanup = existingIntelliJ.paths.plugins.directChildren().toSet
assert(installedPlugins.diff(pluginsAfterCleanup).nonEmpty, "No plugins were removed during cleanup.")
assert(
pluginsAfterCleanup == preInstalledPlugins,
Expand All @@ -118,7 +118,7 @@ final class IntelliJProviderTest {
private def givenInstalledIntelliJ(test: Path => Unit): Unit = {
val preInstalledIntelliJ = IntelliJProvider.Default.setup()
val installationRoot = preInstalledIntelliJ.paths.root
preInstalledIntelliJ.paths.bundledPlugins
preInstalledIntelliJ.paths.plugins
.resolve("ideprobe")
.delete() // Removing the ideprobe plugin - to avoid conflicts when installing it in tests.
try test(installationRoot)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ trait ScalaPluginExtension { this: IdeProbeFixture =>
// scala plugin. This is why we delete one of them. We declare the scala-library as an
// optional dependency with config file probePlugin/src/main/resources/META-INF/scala-plugin.xml
// so that ideprobe plugin can be loaded regardless of the missing scala-library.
inteliJ.paths.bundledPlugins.resolve("ideprobe/lib/scala-library.jar").delete()
inteliJ.paths.plugins.resolve("ideprobe/lib/scala-library.jar").delete()
}
}

Expand Down

0 comments on commit 34456d9

Please sign in to comment.