Skip to content

Commit 2ed5285

Browse files
committed
fix attaching sources to INTELLIJ-SDK-TEST & IJ-PLUGIN libraries
1 parent 08613ec commit 2ed5285

File tree

2 files changed

+31
-11
lines changed

2 files changed

+31
-11
lines changed

ideaSupport/src/main/scala/org/jetbrains/sbtidea/tasks/UpdateWithIDEAInjectionTask.scala

+7-2
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,12 @@ object UpdateWithIDEAInjectionTask extends SbtIdeaTask[UpdateReport] {
5353
intellijMainJars.map(mainJarsArtifact -> _) ++ sourcesArtifactMapping
5454
}
5555

56-
val ideaTestArtifactMappings: Seq[(sbt.Artifact, File)] =
57-
intellijTestJars.map(Artifacts.ideaTestArtifact -> _)
56+
val ideaTestArtifactMappings: Seq[(sbt.Artifact, File)] = {
57+
//testFramework sources are located in the same archive as main sources
58+
val sourcesArtifactMapping = if (attachSources) Seq(Artifacts.ideaTestSourcesArtifact -> intelliJSourcesArchive) else Seq.empty
59+
val testJarsArtifact = Artifacts.ideaTestArtifact
60+
intellijTestJars.map(testJarsArtifact -> _) ++ sourcesArtifactMapping
61+
}
5862

5963
val pluginArtifactsMappings: Seq[(ModuleID, Seq[(Artifact, File)], Configuration)] = intellijPluginClasspath.flatMap { case (_, classpath) =>
6064
val representativeJar = classpath.headOption
@@ -64,6 +68,7 @@ object UpdateWithIDEAInjectionTask extends SbtIdeaTask[UpdateReport] {
6468
val pluginModule = f.get(moduleID.key).get
6569
val pluginArtifact = f.get(artifact.key).get
6670
val mainArtifactMapping = classpath.map(pluginArtifact -> _.data)
71+
//bundled plugin sources are located in the same archive as main sources
6772
val sourcesArtifactMapping = Artifacts.pluginSourcesArtifact(pluginArtifact.name) -> intelliJSourcesArchive
6873

6974
// bundled plugin has the same version as the platform; add sources

ideaSupport/src/main/scala/org/jetbrains/sbtidea/tasks/classpath/AttributedClasspathTasks.scala

+24-9
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,18 @@ import scala.collection.mutable
1111
object AttributedClasspathTasks {
1212

1313
import Artifacts.*
14-
import Modules.*
1514

1615
private val INTELLIJ_SDK_ARTIFACT_NAME = "INTELLIJ-SDK"
1716
private val INTELLIJ_SDK_TEST_ARTIFACT_NAME: String = "INTELLIJ-SDK-TEST"
1817

18+
// These special classifiers have a special handling logic in Scala plugin and DevKit plugin
19+
// See org.jetbrains.sbt.project.SbtProjectResolver.IJ_SDK_CLASSIFIERS
20+
// See https://youtrack.jetbrains.com/issue/SCL-17415 (though it doesn't have many details)
21+
// NOTE: it seems like it's some legacy and DevKit doesn't actually need this, but it's not 100%
22+
// same classifier is used for both main and test jars
23+
private val IJ_SDK_CLASSIFIER = "IJ-SDK"
24+
private val IJ_PLUGIN_CLASSIFIER = "IJ-PLUGIN"
25+
1926
object Artifacts {
2027
private val intellijMainJarsHashToArtifactSuffix = mutable.Map[Int, String]()
2128

@@ -24,6 +31,9 @@ object AttributedClasspathTasks {
2431
* (it better shouldn't be so, but it might occur accidentally, e.g., due to misconfiguration)<br>
2532
* In this case, we want to create different libraries.<br>
2633
* For this we need unique names
34+
*
35+
* @return 1. empty string in the simplest case, when all modules depend on the same set of jars from the platform<br>
36+
* 2. jars hash code otherwise
2737
*/
2838
private def getUniqueArtifactSuffix(jars: Seq[File], cache: mutable.Map[Int, String]): String =
2939
cache.synchronized {
@@ -36,29 +46,34 @@ object AttributedClasspathTasks {
3646
}
3747

3848
def ideaMainJarsArtifact(intellijMainJarsValue: Seq[File]): Artifact = {
49+
//should be empty in simple cases
3950
val artifactSuffix = getUniqueArtifactSuffix(intellijMainJarsValue, intellijMainJarsHashToArtifactSuffix)
40-
Artifact(INTELLIJ_SDK_ARTIFACT_NAME, s"IJ-SDK$artifactSuffix")
51+
Artifact(name = INTELLIJ_SDK_ARTIFACT_NAME + artifactSuffix, classifier = IJ_SDK_CLASSIFIER)
4152
}
4253

4354
val ideaTestArtifact: Artifact =
44-
Artifact(INTELLIJ_SDK_TEST_ARTIFACT_NAME, "IJ-SDK-TEST")
55+
Artifact(name = INTELLIJ_SDK_TEST_ARTIFACT_NAME, classifier = IJ_SDK_CLASSIFIER)
4556

4657
val ideaSourcesArtifact: Artifact =
47-
Artifact(INTELLIJ_SDK_ARTIFACT_NAME, Artifact.SourceType, "zip", "IJ-SDK")
58+
Artifact(name = INTELLIJ_SDK_ARTIFACT_NAME, `type` = Artifact.SourceType, extension = "zip", classifier = IJ_SDK_CLASSIFIER)
59+
60+
val ideaTestSourcesArtifact: Artifact =
61+
Artifact(name = INTELLIJ_SDK_TEST_ARTIFACT_NAME, `type` = Artifact.SourceType, extension = "zip", classifier = IJ_SDK_CLASSIFIER)
62+
4863

4964
def pluginArtifact(descriptor: PluginDescriptor): Artifact =
50-
Artifact(s"IJ-PLUGIN[${descriptor.id}]", "IJ-PLUGIN")
65+
Artifact(name = s"IJ-PLUGIN[${descriptor.id}]", classifier = IJ_PLUGIN_CLASSIFIER)
5166

5267
def pluginSourcesArtifact(pluginName: String): Artifact =
53-
Artifact(pluginName, Artifact.SourceType, "zip", Artifact.SourceClassifier)
68+
Artifact(name = pluginName, `type` = Artifact.SourceType, extension = "zip", classifier = IJ_PLUGIN_CLASSIFIER)
5469
}
5570

5671
object Modules {
5772
def getIntellijSdkModule(buildNumber: String): ModuleID =
5873
"org.jetbrains" % INTELLIJ_SDK_ARTIFACT_NAME % buildNumber withSources()
5974

6075
def getIntellijSdkTestModule(buildNumber: String): ModuleID =
61-
"org.jetbrains" % INTELLIJ_SDK_TEST_ARTIFACT_NAME % buildNumber % Test
76+
"org.jetbrains" % INTELLIJ_SDK_TEST_ARTIFACT_NAME % buildNumber % Test withSources()
6277
}
6378

6479
//======= ATTRIBUTED CLASSPATH =======
@@ -79,7 +94,7 @@ object AttributedClasspathTasks {
7994
buildNumber: String
8095
): Classpath = {
8196
val artifact = ideaMainJarsArtifact(jars)
82-
val module = getIntellijSdkModule(buildNumber)
97+
val module = Modules.getIntellijSdkModule(buildNumber)
8398
buildAttributedClasspath(jars)(artifact, module, Compile)
8499
}
85100

@@ -88,7 +103,7 @@ object AttributedClasspathTasks {
88103
buildNumber: String
89104
): Classpath = {
90105
val artifact = ideaTestArtifact
91-
val module = getIntellijSdkTestModule(buildNumber)
106+
val module = Modules.getIntellijSdkTestModule(buildNumber)
92107
buildAttributedClasspath(jars)(artifact, module, Test)
93108
}
94109

0 commit comments

Comments
 (0)