Skip to content

Commit

Permalink
deprecate support of generation run configuration with `-Didea.Proces…
Browse files Browse the repository at this point in the history
…sCanceledException`

`-Didea.ProcessCanceledException` VM options is dropped in IDEA 2022.3, for details see https://youtrack.jetbrains.com/issue/IDEA-304945
  • Loading branch information
unkarjedy committed Feb 2, 2023
1 parent 53bb44d commit 0f2b86d
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 26 deletions.
12 changes: 5 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ patchPluginXml := pluginXmlOptions { xml =>

#### `intellijVMOptions :: SettingKey[IntellijVMOptions]`

Fine tune java VM options for running the plugin with [`runIDE`](#runide-nopce-nodebug-suspend--inputkeyunit) task.
Fine tune java VM options for running the plugin with [runIDE](#runide-nodebug-suspend-blocking--inputkeyunit) task.
Example:

```SBT
Expand All @@ -177,14 +177,12 @@ intellijVMOptions := intellijVMOptions.value.copy(xmx = 2048, xms = 256)

Fine tune how IntelliJ run configurations are generated when importing the project in IDEA.

#### `runIDE [noPCE] [noDebug] [suspend] [blocking] :: InputKey[Unit]`
#### `runIDE [noDebug] [suspend] [blocking] :: InputKey[Unit]`

Runs IntelliJ IDE with current plugin. This task is non-blocking by default, so you can continue using SBT console.

By default, IDE is run with non-suspending debug agent on port `5005`. This can be overridden by either optional
arguments above, or by modifying default [`intellijVMOptions`](#intellijvmoptions--settingkeyintellijvmoptions).
[`ProcessCancelledExceptiona`](https://www.jetbrains.org/intellij/sdk/docs/basics/architectural_overview/general_threading_rules.html#background-processes-and-processcanceledexception)
can also be disabled for current run by providing `noPCE` option.
arguments above, or by modifying default [`intellijVMOptions`](#intellijvmoptions--settingkeyintellijvmoptions).

### Publishing and Verification

Expand Down Expand Up @@ -305,7 +303,7 @@ packageLibraryMappings += "org.scala-lang" % "scala-library" % scalaVersion -> S

**Default**: `file("lib")`

Sets the per-project default sub-folder into which external libraries are packaged. Rules from [`packageLibraryMappings`](#packagefilemappings--settingkeyseqfile-string)
Sets the per-project default sub-folder into which external libraries are packaged. Rules from [`packageLibraryMappings`](#packagefilemappings--taskkeyseqfile-string)
will override this setting.

**NB!**: This directory must be relative to the [`packageOutputDir`](#packageoutputdir--settingkeyfile) so don't prepend
Expand Down Expand Up @@ -415,7 +413,7 @@ Prints ASCII graph of currently selected project to console. Useful for debuggin

### From SBT

To run the plugin from SBT simply use [runIDE](#runide-nopce-nodebug-suspend-blocking--inputkeyunit) task.
To run the plugin from SBT simply use [runIDE](#runide-nodebug-suspend-blocking--inputkeyunit) task.
Your plugin will be automatically compiled, an artifact built and attached to new IntelliJ instance.

Debugger can later be attached to the process remotely - the default port is 5005.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
package org.jetbrains.sbtidea

import scala.annotation.nowarn

@nowarn("cat=deprecation")
case class IdeaConfigBuildingOptions(generateDefaultRunConfig: Boolean = true,
generateJUnitTemplate: Boolean = true,
generateNoPCEConfiguration: Boolean = false,
programParams: String = "",
ideaRunEnv: Map[String, String] = Map.empty,
ideaTestEnv: Map[String, String] = Map.empty,
testModuleName: String = "",
workingDir: String = "$PROJECT_DIR$/",
testSearchScope: String = "moduleWithDependencies")
generateJUnitTemplate: Boolean = true,
@deprecated("This value is unused and will be deleted in future releases. In IntelliJ IDEA 2023.1 `-Didea.ProcessCanceledException` VM options is dropped (for details see https://youtrack.jetbrains.com/issue/IDEA-304945)")
generateNoPCEConfiguration: Boolean = false,
programParams: String = "",
ideaRunEnv: Map[String, String] = Map.empty,
ideaTestEnv: Map[String, String] = Map.empty,
testModuleName: String = "",
workingDir: String = "$PROJECT_DIR$/",
testSearchScope: String = "moduleWithDependencies")
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import org.jetbrains.sbtidea.download.{IntelliJVersionDetector, Version}
import sbt.pathToPathOps

import java.nio.file.Path
import scala.annotation.nowarn
import scala.collection.JavaConverters.*
import scala.collection.mutable
import scala.math.Ordered.orderingToOrdered
Expand All @@ -14,6 +15,7 @@ import scala.math.Ordered.orderingToOrdered
* example: {{{ <userHome>/.ScalaPluginIU }}}
* @param intellijDirectory example: {{{ <userHome>/.ScalaPluginIU/sdk/223.6160 }}}
*/
@nowarn("cat=deprecation")
case class IntellijVMOptions(platform: IntelliJPlatform,
pluginPath: Path,
ideaHome: Path,
Expand All @@ -24,6 +26,7 @@ case class IntellijVMOptions(platform: IntelliJPlatform,
softRefLRUPolicyMSPerMB: Int = 50,
gc: String = "-XX:+UseG1GC",
gcOpt: String = "-XX:CICompilerCount=2",
@deprecated("This value is unused and will be deleted in future releases. In IntelliJ IDEA 2023.1 `-Didea.ProcessCanceledException` VM options is dropped (for details see https://youtrack.jetbrains.com/issue/IDEA-304945)")
noPCE: Boolean = false,
debug: Boolean = true,
debugPort: Int = 5005,
Expand Down Expand Up @@ -74,8 +77,6 @@ object IntellijVMOptions {
buffer += "-Didea.use.core.classloader.for.plugin.path=true"
buffer += "-Didea.force.use.core.classloader=true"
}
if (noPCE)
buffer += "-Didea.ProcessCanceledException=disabled"
if (!test)
buffer += "-Didea.is.internal=true"
if (debug) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ class IdeaConfigBuilder(moduleName: String,

def build(): Unit = {
if (options.generateDefaultRunConfig)
writeToFile(runConfigDir / s"$configName.xml", buildRunConfigurationXML())
if (options.generateNoPCEConfiguration)
writeToFile(runConfigDir / s"$configName-noPCE.xml", buildRunConfigurationXML(noPCE = true))
writeToFile(runConfigDir / s"$configName.xml", buildRunConfigurationXML)
if (options.generateJUnitTemplate)
writeToFile(runConfigDir / "_template__of_JUnit.xml", buildJUnitTemplate)
}
Expand Down Expand Up @@ -155,16 +153,15 @@ class IdeaConfigBuilder(moduleName: String,
}


private def buildRunConfigurationXML(noPCE: Boolean = false): String = {
val vmOptions = if (noPCE) intellijVMOptions.copy(noPCE = true) else intellijVMOptions
private def buildRunConfigurationXML: String = {
val vmOptions = intellijVMOptions
val env = mkEnv(options.ideaRunEnv)
val name = if (noPCE) s"$configName-noPCE" else configName

val classpathEntries = intellijPlatformJarsClasspath
val classpathString = classpathEntries.mkString(File.pathSeparator)

s"""<component name="ProjectRunConfigurationManager">
| <configuration default="false" name="$name" type="Application" factoryName="Application">
| <configuration default="false" name="$configName" type="Application" factoryName="Application">
| $jreSettings
| <log_file alias="IJ LOG" path="$dataDir/system/log/idea.log" />
| <log_file alias="JPS LOG" path="$dataDir/system/log/build-log/build.log" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ object RunIDETask extends SbtIdeaInputTask[Unit] {
import complete.DefaultParsers.*
packageArtifact.value // build the plugin before running
PluginLogger.bind(new SbtPluginLogger(streams.value))
val opts = spaceDelimited("[noPCE] [noDebug] [suspend] [blocking]").parsed
val opts = spaceDelimited("[noDebug] [suspend] [blocking]").parsed
val vmOptions = intellijVMOptions.value.copy(
noPCE = opts.contains("noPCE"),
debug = !opts.contains("noDebug"),
suspend = opts.contains("suspend")
)
Expand Down

0 comments on commit 0f2b86d

Please sign in to comment.