@dhinojosa
Whether IntelliJ will accept it or not will be a concern
A confirmation on this, will be really helpful
[error] scala.reflect.internal.MissingRequirementError: object scala in compiler mirror not found.
[error] scala.reflect.internal.MissingRequirementError$.notFound(MissingRequirementError.scala:24)
[error] scala.reflect.internal.Mirrors$RootsBase.$anonfun$getModuleOrClass$6(Mirrors.scala:66)
[error] scala.reflect.internal.Mirrors$RootsBase.getPackage(Mirrors.scala:66)
[error] scala.reflect.internal.Definitions$DefinitionsClass.ScalaPackage$lzycompute(Definitions.scala:196)
[error] scala.reflect.internal.Definitions$DefinitionsClass.ScalaPackage(Definitions.scala:196)
[error] scala.reflect.internal.Definitions$DefinitionsClass.ScalaPackageClass$lzycompute(Definitions.scala:197) | => mogli-dev / Compile / compileIncremental 11s
//this will enable scala in complete project
scalaVersion := "2.13.5"
//this will disable scala
autoScalaLibrary := false
//and this will enable scala again in test scope
libraryDependencies += "org.scala-lang" % "scala-library" % scalaVersion.value % "test"
//this will enable scala in complete project
scalaVersion := "2.13.5"
//this will disable scala
autoScalaLibrary := false
//and this will enable scala again in test scope
libraryDependencies += "org.scala-lang" % "scala-library" % scalaVersion.value % "test"
[IJ]{file:/Users/eric/dd/bigdata-master/web_api/}web_api/ testOnly feature_factory_interfaces.output.SmallFeatureDescriptorSetSerializerTest
how can I use the ScalaTest
and just have it run the single testPreRelease
There is a sample intellij plugin that depends on org.intellij.scala plugin also.
Now, this sample intellij plugin has a functionality to fetch json over http and then parse it.
For parsing json in scala, there are multiple libraries, and we decided to use spray json library.
Reason for choosing spray json :-
spray json library is present in library dependency graph of org.intellij.scala, and sample intellij plugin directly depends on org.intellij.scala plugin.
So to keep sample intellij plugin library size minimum, we thought of using json parser library that is used by org.intellij.scala plugin.
But, we are getting PluginClassLoader exception :-
java.lang.LinkageError: loader constraint violation: when resolving method 'spray.json.RootJsonFormat spray.json.DefaultJsonProtocol$.jsonFormat1(scala.Function1, spray.json.JsonFormat, scala.reflect.ClassTag)' the class loader com.intellij.ide.plugins.cl.PluginClassLoader @2a4b0539 of the current class, com/sample/plugin/FetchDomainObjectsFromWire, and the class loader com.intellij.ide.plugins.cl.PluginClassLoader @573b8e9c for the method's defining class, spray/json/DefaultJsonProtocol$, have different Class objects for the type scala/Function1 used in the signature (com.sample.plugin.FetchDomainObjectsFromWire is in unnamed module of loader com.intellij.ide.plugins.cl.PluginClassLoader @2a4b0539, parent loader 'bootstrap'; spray.json.DefaultJsonProtocol$ is in unnamed module of loader com.intellij.ide.plugins.cl.PluginClassLoader @573b8e9c, parent loader 'bootstrap')
Our understanding so far for this exception :-
As org.intellij.scala and sample intellij are loaded in different classloaders, so sample intellij plugin can't use any class loaded by PluginClassLoader of org.intellij.scala.
To use spray json classes in sample intellij plugin, spray json should be explicitly added to libraryDependencies in sample intellij plugin.
Adding spray json to libraryDependencies in sample intellij plugin will solve the class-loader issue,
but increase the packaged plugin binary size, as spray json library is also packaged in sample intellij plugin.
plugin.xml
<id>com.logicovercode</id>
<name>IjPlugin</name>
<vendor email="moglideveloper@gmail.com" url="https://github.com/JetBrains/sbt-idea-plugin/discussions/107">Linkage Error</vendor>
<version>2021.1.18</version>
<depends>org.intellij.scala</depends>
<idea-version since-build="211.5538" until-build="211.*"/>
build.sbt :
scalaVersion := "2.13.2"
intellijPlugins += "org.intellij.scala:2021.1.18".toPlugin
intellijDownloadSources := true
ThisBuild / bundleScalaLibrary := false
plugins.sbt
addSbtPlugin("org.jetbrains" % "sbt-idea-plugin" % "3.12.2")
Final Note: if spray-json is not present in SamplePlugin/target/plugin/logicIj/lib, then plugin is giving LinkageError, when run from intellij-run configuration or by loading sample plugin izip in fresh intellij instance.
Kindly confirm, if our understanding is correct and please suggest recommended approach/ best practices for this scenario.
For reference purpose, this question can also be found here :
https://github.com/JetBrains/sbt-idea-plugin/discussions/107
Thanks.