@@ -118,7 +118,7 @@ final class ScalaMavenImporter extends MavenImporter("org.scala-tools", "maven-s
118118 *
119119 * @see [[implicitScalaLibraryIfNeeded ]]
120120 */
121- val scalaLibraryToMarkAsSdk : Either [ Unit , Option [(Library , Version )] ] = {
121+ val scalaLibraryToMarkAsSdk : Option [(Library , Version )] = {
122122 val expectedLibraryName = scalaCompilerArtifactName(" library" , compilerVersion.presentation)
123123 val moduleModel = modelsProvider.getModifiableRootModel(module)
124124
@@ -144,41 +144,36 @@ final class ScalaMavenImporter extends MavenImporter("org.scala-tools", "maven-s
144144 librariesWithSameMajorVersion.maxByOption(_._2)
145145 }
146146
147- // TODO - this workaround should be removed when #IDEA-348826 is merged to IDEA 2024.1 (around 20.04)
148- if (libraryEntriesGroupedByScope.isEmpty) Left (())
149- else {
150- val selectedLibrary = libraryEntriesGroupedByScope.iterator
151- .flatMap { case _ -> entries => selectScalaLibrary(entries) }
152- .nextOption()
153- Right (selectedLibrary)
154- }
147+ libraryEntriesGroupedByScope.iterator
148+ .flatMap { case _ -> entries => selectScalaLibrary(entries) }
149+ .nextOption()
155150 }
156151
157- scalaLibraryToMarkAsSdk.foreach {
158- case Some ((scalaLibrary, scalaLibraryVersion)) =>
159- val compilerClasspathFull = module.getProject.getUserData(MavenFullCompilerClasspathKey )
160-
161- val compilerBridgeBinaryJar =
162- ScalaSdkUtils .compilerBridgeJarName(scalaLibraryVersion.presentation).flatMap { bridgeJarName =>
163- compilerClasspathFull.find(_.getName == bridgeJarName)
164- }
165-
166- val classpath = compilerClasspathFull.diff(compilerBridgeBinaryJar.toSeq)
167-
168- ScalaSdkUtils .ensureScalaLibraryIsConvertedToScalaSdk(
169- modelsProvider,
170- scalaLibrary,
171- Some (scalaLibraryVersion.presentation),
172- classpath,
173- scaladocExtraClasspath = Nil , // TODO SCL-17219
174- compilerBridgeBinaryJar = compilerBridgeBinaryJar
175- )
176- case None =>
177- val msg = s " Cannot find project Scala library ${compilerVersion.presentation} for module ${module.getName}"
178- val exception = new IllegalArgumentException (msg)
179- val console = MavenProjectsManager .getInstance(module.getProject).getSyncConsole
180- console.addException(exception)
181- }
152+ scalaLibraryToMarkAsSdk match {
153+ case Some ((scalaLibrary, scalaLibraryVersion)) =>
154+ val compilerClasspathFull = module.getProject.getUserData(MavenFullCompilerClasspathKey )
155+
156+ val compilerBridgeBinaryJar =
157+ ScalaSdkUtils .compilerBridgeJarName(scalaLibraryVersion.presentation).flatMap { bridgeJarName =>
158+ compilerClasspathFull.find(_.getName == bridgeJarName)
159+ }
160+
161+ val classpath = compilerClasspathFull.diff(compilerBridgeBinaryJar.toSeq)
162+
163+ ScalaSdkUtils .ensureScalaLibraryIsConvertedToScalaSdk(
164+ modelsProvider,
165+ scalaLibrary,
166+ Some (scalaLibraryVersion.presentation),
167+ classpath,
168+ scaladocExtraClasspath = Nil , // TODO SCL-17219
169+ compilerBridgeBinaryJar = compilerBridgeBinaryJar
170+ )
171+ case None =>
172+ val msg = s " Cannot find project Scala library ${compilerVersion.presentation} for module ${module.getName}"
173+ val exception = new IllegalArgumentException (msg)
174+ val console = MavenProjectsManager .getInstance(module.getProject).getSyncConsole
175+ console.addException(exception)
176+ }
182177 }
183178
184179 // called before `process`
0 commit comments