diff --git a/idea/src/mill/idea/GenIdeaImpl.scala b/idea/src/mill/idea/GenIdeaImpl.scala
index f2d17b6bf6d..3ca45e25f09 100755
--- a/idea/src/mill/idea/GenIdeaImpl.scala
+++ b/idea/src/mill/idea/GenIdeaImpl.scala
@@ -161,18 +161,16 @@ case class GenIdeaImpl(
mod.resolveDeps(allIvyDeps, sources = true)()
}
- val (scalacPluginsIvyDeps, allScalacOptions) = mod match {
+ val (scalacPluginsIvyDeps, allScalacOptions, scalaVersion) = mod match {
case mod: ScalaModule => (
T.task(mod.scalacPluginIvyDeps()),
- T.task(mod.allScalacOptions())
+ T.task(mod.allScalacOptions()),
+ T.task { Some(mod.scalaVersion()) }
)
case _ => (
- T.task {
- Agg[Dep]()
- },
- T.task {
- Seq()
- }
+ T.task(Agg[Dep]()),
+ T.task(Seq[String]()),
+ T.task(None)
)
}
@@ -215,6 +213,7 @@ case class GenIdeaImpl(
val resolvedConfigFileContributions: Seq[IdeaConfigFile] =
configFileContributions()
val resolvedCompilerOutput = compilerOutput()
+ val resolvedScalaVersion = scalaVersion()
ResolvedModule(
path = path,
@@ -224,12 +223,13 @@ case class GenIdeaImpl(
module = mod,
pluginClasspath = resolvedSp.map(_.path).filter(_.ext == "jar"),
scalaOptions = scalacOpts,
- compilerClasspath = resolvedCompilerCp.map(_.path),
+ scalaCompilerClasspath = resolvedCompilerCp.map(_.path),
libraryClasspath = resolvedLibraryCp.map(_.path),
facets = resolvedFacets,
configFileContributions = resolvedConfigFileContributions,
compilerOutput = resolvedCompilerOutput.path,
- evaluator = evaluator
+ evaluator = evaluator,
+ scalaVersion = resolvedScalaVersion
)
}
}
@@ -255,11 +255,6 @@ case class GenIdeaImpl(
.distinct
.sorted
- val librariesProperties: Map[os.Path, Agg[os.Path]] =
- resolvedModules
- .flatMap(rm => rm.libraryClasspath.map(_ -> rm.compilerClasspath))
- .toMap
-
val (wholeFileConfigs, configFileContributions) =
resolvedModules
.flatMap(_.configFileContributions)
@@ -466,8 +461,8 @@ case class GenIdeaImpl(
* @note `:` in path isn't supported on Windows ~ https://github.com/com-lihaoyi/mill/issues/2243
* It comes from [[sbtLibraryNameFromPom]]
*/
- def libraryNameToFileSystemPathPart(name: String): String = {
- name.replaceAll("""[-.:]""", "_")
+ def libraryNameToFileSystemPathPart(name: String, ext: String): os.SubPath = {
+ os.sub / s"${name.replaceAll("""[-.:]""", "_")}.${ext}"
}
val libraries: Seq[(os.SubPath, Elem)] =
@@ -480,47 +475,31 @@ case class GenIdeaImpl(
}
for (name <- names)
yield {
- val compilerCp: Agg[os.Path] = librariesProperties.getOrElse(resolved.path, Agg.empty)
- val languageLevel = name match {
- case _ if compilerCp.iterator.isEmpty => None
- case _ if name.startsWith("scala3-library_3-3.3.") => Some("Scala_3_3")
- case _ if name.startsWith("scala3-library_3-3.2.") => Some("Scala_3_2")
- case _ if name.startsWith("scala3-library_3-3.1.") => Some("Scala_3_1")
- case _ if name.startsWith("scala3-library_3-3.0.") => Some("Scala_3_0")
- case _ if name.startsWith("scala-library-2.13.") => Some("Scala_2_13")
- case _ if name.startsWith("scala-library-2.12.") => Some("Scala_2_12")
- case _ if name.startsWith("scala-library-2.11.") => Some("Scala_2_11")
- case _ if name.startsWith("scala-library-2.10.") => Some("Scala_2_10")
- case _ if name.startsWith("scala-library-2.9.") => Some("Scala_2_9")
- case _ if name.startsWith("dotty-library-0.27") => Some("Scala_0_27")
- case _ => None
- }
Tuple2(
- os.sub / "libraries" / s"${libraryNameToFileSystemPathPart(name)}.xml",
+ os.sub / "libraries" / libraryNameToFileSystemPathPart(name, "xml"),
libraryXmlTemplate(
name = name,
path = resolved.path,
- sources = sources,
- scalaCompilerClassPath = compilerCp,
- languageLevel = languageLevel
+ sources = sources
)
)
}
}
- val moduleFiles: Seq[(os.SubPath, Elem)] = resolvedModules.map {
+ val moduleFiles: Seq[(os.SubPath, Elem)] = resolvedModules.flatMap {
case ResolvedModule(
path,
resolvedDeps,
mod,
_,
_,
- _,
+ compilerClasspath,
_,
facets,
_,
compilerOutput,
- evaluator
+ evaluator,
+ scalaVersion
) =>
val Seq(
resourcesPathRefs: Seq[PathRef],
@@ -541,19 +520,6 @@ case class GenIdeaImpl(
.map(_.path)
.toSet -- generatedSourcePaths.toSet).toSeq
- val scalaVersionOpt = mod match {
- case x: ScalaModule =>
- Some(
- evaluator.evalOrThrow(
- exceptionFactory = r =>
- GenIdeaException(
- s"Failure during evaluation of the scalaVersion: ${Evaluator.formatFailing(r)}"
- )
- )(x.scalaVersion)
- )
- case _ => None
- }
-
val sanizedDeps: Seq[ScopedOrd[String]] = {
resolvedDeps
.map((s: Scoped[os.Path]) => pathToLibName(s.value) -> s.scope)
@@ -592,9 +558,9 @@ case class GenIdeaImpl(
val isTest = mod.isInstanceOf[TestModule]
- val elem = moduleXmlTemplate(
+ val moduleXml = moduleXmlTemplate(
basePath = mod.intellijModulePath,
- scalaVersionOpt = scalaVersionOpt,
+ scalaVersionOpt = scalaVersion,
resourcePaths = Strict.Agg.from(resourcesPathRefs.map(_.path)),
normalSourcePaths = Strict.Agg.from(normalSourcePaths),
generatedSourcePaths = Strict.Agg.from(generatedSourcePaths),
@@ -605,10 +571,32 @@ case class GenIdeaImpl(
facets = facets
)
- Tuple2(
+ val moduleFile = Tuple2(
os.sub / "mill_modules" / s"${moduleName(path)}.iml",
- elem
+ moduleXml
)
+
+ val scalaSdkFile = {
+ Option.when(scalaVersion.isDefined && compilerClasspath.nonEmpty) {
+ val name = s"scala-SDK-${scalaVersion.get}"
+ val languageLevel =
+ scalaVersion.map(_.split("[.]", 3).take(2).mkString("Scala_", "_", ""))
+
+ Tuple2(
+ os.sub / "libraries" / libraryNameToFileSystemPathPart(name, "xml"),
+ scalaSdkTemplate(
+ name = name,
+ languageLevel = languageLevel,
+ scalaCompilerClassPath = compilerClasspath,
+ // FIXME: fill in these fields
+ compilerBridgeJar = None,
+ scaladocExtraClasspath = None
+ )
+ )
+ }
+ }
+
+ Seq(moduleFile) ++ scalaSdkFile
}
{
@@ -764,32 +752,43 @@ case class GenIdeaImpl(
}
}
- def libraryXmlTemplate(
+ def scalaSdkTemplate(
name: String,
- path: os.Path,
- sources: Option[os.Path],
+ languageLevel: Option[String],
scalaCompilerClassPath: Agg[os.Path],
- languageLevel: Option[String]
+ compilerBridgeJar: Option[os.Path],
+ scaladocExtraClasspath: Agg[os.Path]
): Elem = {
- val isScalaLibrary = scalaCompilerClassPath.iterator.nonEmpty
-
- {
- if (isScalaLibrary) {
+
- {
- if (languageLevel.isDefined) {languageLevel.get}
- }
-
{
- scalaCompilerClassPath.iterator.toSeq.sortBy(_.wrapped).map(p =>
-
- )
- }
-
-
- }
+ if (languageLevel.isDefined) {languageLevel.get}
}
+
+ {
+ scalaCompilerClassPath.iterator.toSeq.sortBy(_.wrapped).map(p =>
+
+ )
+ }
+
+ {
+ if (compilerBridgeJar.isDefined) {
+ relativeFileUrl(compilerBridgeJar.get)
+ }
+ }
+
+
+
+ }
+
+ def libraryXmlTemplate(
+ name: String,
+ path: os.Path,
+ sources: Option[os.Path]
+ ): Elem = {
+
+
@@ -892,6 +891,11 @@ case class GenIdeaImpl(
}
+ {
+ for {
+ scalaVersion <- scalaVersionOpt.toSeq
+ } yield
+ }
{
for (name <- libNames.sorted)
@@ -1011,12 +1015,13 @@ object GenIdeaImpl {
module: JavaModule,
pluginClasspath: Agg[os.Path],
scalaOptions: Seq[String],
- compilerClasspath: Agg[os.Path],
+ scalaCompilerClasspath: Agg[os.Path],
libraryClasspath: Agg[os.Path],
facets: Seq[JavaFacet],
configFileContributions: Seq[IdeaConfigFile],
compilerOutput: os.Path,
- evaluator: Evaluator
+ evaluator: Evaluator,
+ scalaVersion: Option[String]
)
case class GenIdeaException(msg: String) extends RuntimeException
diff --git a/integration/feature/gen-idea/repo/extended/idea/libraries/scala3_library_3_3_0_2_jar.xml b/integration/feature/gen-idea/repo/extended/idea/libraries/scala3_library_3_3_0_2_jar.xml
new file mode 100644
index 00000000000..ca7833076cc
--- /dev/null
+++ b/integration/feature/gen-idea/repo/extended/idea/libraries/scala3_library_3_3_0_2_jar.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/integration/feature/gen-idea/repo/extended/idea/libraries/scala_SDK_2_13_6.xml b/integration/feature/gen-idea/repo/extended/idea/libraries/scala_SDK_2_13_6.xml
new file mode 100644
index 00000000000..085bfbc1195
--- /dev/null
+++ b/integration/feature/gen-idea/repo/extended/idea/libraries/scala_SDK_2_13_6.xml
@@ -0,0 +1,14 @@
+
+
+
+ Scala_2_13
+
+
+
+
+
+
+
+
+
+
diff --git a/integration/feature/gen-idea/repo/extended/idea/libraries/scala_SDK_3_0_2.xml b/integration/feature/gen-idea/repo/extended/idea/libraries/scala_SDK_3_0_2.xml
new file mode 100644
index 00000000000..117d206d050
--- /dev/null
+++ b/integration/feature/gen-idea/repo/extended/idea/libraries/scala_SDK_3_0_2.xml
@@ -0,0 +1,22 @@
+
+
+
+ Scala_3_0
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/integration/feature/gen-idea/repo/extended/idea/libraries/scala_library_2_13_6_jar.xml b/integration/feature/gen-idea/repo/extended/idea/libraries/scala_library_2_13_6_jar.xml
index d69a1376af8..e5827cc0f84 100644
--- a/integration/feature/gen-idea/repo/extended/idea/libraries/scala_library_2_13_6_jar.xml
+++ b/integration/feature/gen-idea/repo/extended/idea/libraries/scala_library_2_13_6_jar.xml
@@ -1,15 +1,5 @@
-
-
- Scala_2_13
-
-
-
-
-
-
-
-
+
diff --git a/integration/feature/gen-idea/repo/extended/idea/mill_modules/helloworld.iml b/integration/feature/gen-idea/repo/extended/idea/mill_modules/helloworld.iml
index 5c5918885e0..ff4c0206976 100644
--- a/integration/feature/gen-idea/repo/extended/idea/mill_modules/helloworld.iml
+++ b/integration/feature/gen-idea/repo/extended/idea/mill_modules/helloworld.iml
@@ -11,6 +11,7 @@
+
diff --git a/integration/feature/gen-idea/repo/extended/idea/mill_modules/helloworld.subscala3.iml b/integration/feature/gen-idea/repo/extended/idea/mill_modules/helloworld.subscala3.iml
index d4e7d4f0ea8..89bb01efc43 100644
--- a/integration/feature/gen-idea/repo/extended/idea/mill_modules/helloworld.subscala3.iml
+++ b/integration/feature/gen-idea/repo/extended/idea/mill_modules/helloworld.subscala3.iml
@@ -8,6 +8,7 @@
+
diff --git a/integration/feature/gen-idea/repo/extended/idea/mill_modules/helloworld.test.iml b/integration/feature/gen-idea/repo/extended/idea/mill_modules/helloworld.test.iml
index 9320333ee26..dda57c36548 100644
--- a/integration/feature/gen-idea/repo/extended/idea/mill_modules/helloworld.test.iml
+++ b/integration/feature/gen-idea/repo/extended/idea/mill_modules/helloworld.test.iml
@@ -8,6 +8,7 @@
+
diff --git a/integration/feature/gen-idea/repo/extended/idea/mill_modules/mill-build.iml b/integration/feature/gen-idea/repo/extended/idea/mill_modules/mill-build.iml
index 089434db76a..39534426524 100644
--- a/integration/feature/gen-idea/repo/extended/idea/mill_modules/mill-build.iml
+++ b/integration/feature/gen-idea/repo/extended/idea/mill_modules/mill-build.iml
@@ -10,6 +10,7 @@
+
\ No newline at end of file
diff --git a/integration/feature/gen-idea/repo/hello-idea/build.sc b/integration/feature/gen-idea/repo/hello-idea/build.sc
index dba62aebefb..9fd44b6ac6e 100644
--- a/integration/feature/gen-idea/repo/hello-idea/build.sc
+++ b/integration/feature/gen-idea/repo/hello-idea/build.sc
@@ -20,7 +20,11 @@ trait HelloIdeaModule extends scalalib.ScalaModule {
}
}
-object HelloIdea extends HelloIdeaModule
+object HelloIdea extends HelloIdeaModule {
+ object scala3 extends HelloIdeaModule {
+ def scalaVersion = "3.3.1"
+ }
+}
object HiddenIdea extends HelloIdeaModule {
override def skipIdea = true
diff --git a/integration/feature/gen-idea/repo/hello-idea/idea/libraries/scala3_library_3_3_3_1_jar.xml b/integration/feature/gen-idea/repo/hello-idea/idea/libraries/scala3_library_3_3_3_1_jar.xml
new file mode 100644
index 00000000000..6f4355815f4
--- /dev/null
+++ b/integration/feature/gen-idea/repo/hello-idea/idea/libraries/scala3_library_3_3_3_1_jar.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/integration/feature/gen-idea/repo/hello-idea/idea/libraries/scala_SDK_2_12_5.xml b/integration/feature/gen-idea/repo/hello-idea/idea/libraries/scala_SDK_2_12_5.xml
new file mode 100644
index 00000000000..836347dd6ef
--- /dev/null
+++ b/integration/feature/gen-idea/repo/hello-idea/idea/libraries/scala_SDK_2_12_5.xml
@@ -0,0 +1,13 @@
+
+
+
+ Scala_2_12
+
+
+
+
+
+
+
+
+
diff --git a/integration/feature/gen-idea/repo/hello-idea/idea/libraries/scala_SDK_2_13_14.xml b/integration/feature/gen-idea/repo/hello-idea/idea/libraries/scala_SDK_2_13_14.xml
new file mode 100644
index 00000000000..121dfa9e373
--- /dev/null
+++ b/integration/feature/gen-idea/repo/hello-idea/idea/libraries/scala_SDK_2_13_14.xml
@@ -0,0 +1,15 @@
+
+
+
+ Scala_2_13
+
+
+
+
+
+
+
+
+
+
+
diff --git a/integration/feature/gen-idea/repo/hello-idea/idea/libraries/scala_SDK_3_3_1.xml b/integration/feature/gen-idea/repo/hello-idea/idea/libraries/scala_SDK_3_3_1.xml
new file mode 100644
index 00000000000..a7a1e60dc18
--- /dev/null
+++ b/integration/feature/gen-idea/repo/hello-idea/idea/libraries/scala_SDK_3_3_1.xml
@@ -0,0 +1,22 @@
+
+
+
+ Scala_3_3
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/integration/feature/gen-idea/repo/hello-idea/idea/libraries/scala_library_2_12_5_jar.xml b/integration/feature/gen-idea/repo/hello-idea/idea/libraries/scala_library_2_12_5_jar.xml
index 893b4133025..e8e9a9aa10f 100644
--- a/integration/feature/gen-idea/repo/hello-idea/idea/libraries/scala_library_2_12_5_jar.xml
+++ b/integration/feature/gen-idea/repo/hello-idea/idea/libraries/scala_library_2_12_5_jar.xml
@@ -1,14 +1,5 @@
-
-
- Scala_2_12
-
-
-
-
-
-
-
+
diff --git a/integration/feature/gen-idea/repo/hello-idea/idea/libraries/scala_library_2_13_14_jar.xml b/integration/feature/gen-idea/repo/hello-idea/idea/libraries/scala_library_2_13_14_jar.xml
new file mode 100644
index 00000000000..08e48b16ddd
--- /dev/null
+++ b/integration/feature/gen-idea/repo/hello-idea/idea/libraries/scala_library_2_13_14_jar.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/integration/feature/gen-idea/repo/hello-idea/idea/mill_modules/helloidea.iml b/integration/feature/gen-idea/repo/hello-idea/idea/mill_modules/helloidea.iml
index 8b91460b799..ee62537ae9e 100644
--- a/integration/feature/gen-idea/repo/hello-idea/idea/mill_modules/helloidea.iml
+++ b/integration/feature/gen-idea/repo/hello-idea/idea/mill_modules/helloidea.iml
@@ -8,6 +8,7 @@
+
\ No newline at end of file
diff --git a/integration/feature/gen-idea/repo/hello-idea/idea/mill_modules/helloidea.scala3.iml b/integration/feature/gen-idea/repo/hello-idea/idea/mill_modules/helloidea.scala3.iml
new file mode 100644
index 00000000000..3695d092361
--- /dev/null
+++ b/integration/feature/gen-idea/repo/hello-idea/idea/mill_modules/helloidea.scala3.iml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/integration/feature/gen-idea/repo/hello-idea/idea/mill_modules/helloidea.scala3.test.iml b/integration/feature/gen-idea/repo/hello-idea/idea/mill_modules/helloidea.scala3.test.iml
new file mode 100644
index 00000000000..f91b8b6dabe
--- /dev/null
+++ b/integration/feature/gen-idea/repo/hello-idea/idea/mill_modules/helloidea.scala3.test.iml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/integration/feature/gen-idea/repo/hello-idea/idea/mill_modules/helloidea.test.iml b/integration/feature/gen-idea/repo/hello-idea/idea/mill_modules/helloidea.test.iml
index b0920fbba37..9fddf089e8f 100644
--- a/integration/feature/gen-idea/repo/hello-idea/idea/mill_modules/helloidea.test.iml
+++ b/integration/feature/gen-idea/repo/hello-idea/idea/mill_modules/helloidea.test.iml
@@ -8,6 +8,7 @@
+
diff --git a/integration/feature/gen-idea/repo/hello-idea/idea/mill_modules/mill-build.iml b/integration/feature/gen-idea/repo/hello-idea/idea/mill_modules/mill-build.iml
index 781a179b34e..6e0e98d5c9a 100644
--- a/integration/feature/gen-idea/repo/hello-idea/idea/mill_modules/mill-build.iml
+++ b/integration/feature/gen-idea/repo/hello-idea/idea/mill_modules/mill-build.iml
@@ -8,6 +8,7 @@
+
\ No newline at end of file
diff --git a/integration/feature/gen-idea/repo/hello-idea/idea/modules.xml b/integration/feature/gen-idea/repo/hello-idea/idea/modules.xml
index d079cc48d82..d180def48a7 100644
--- a/integration/feature/gen-idea/repo/hello-idea/idea/modules.xml
+++ b/integration/feature/gen-idea/repo/hello-idea/idea/modules.xml
@@ -2,6 +2,8 @@
+
+