@@ -1178,24 +1178,45 @@ object Build {
11781178 },
11791179 )
11801180
1181- lazy val `scala3-repl-embedded ` = project.in(file(" repl-embedded" ))
1181+ lazy val `scala3-repl-shaded ` = project.in(file(" repl-embedded" ))
11821182 .dependsOn(`scala3-repl`)
1183- .settings(publishSettings )
1183+ .enablePlugins(sbtassembly. AssemblyPlugin )
11841184 .settings(
1185- name := " scala3-repl-embedded " ,
1186- moduleName := " scala3-repl-embedded " ,
1185+ name := " scala3-repl-shaded " ,
1186+ moduleName := " scala3-repl-shaded " ,
11871187 version := dottyVersion,
11881188 versionScheme := Some (" semver-spec" ),
11891189 scalaVersion := referenceVersion,
11901190 crossPaths := true ,
11911191 autoScalaLibrary := false ,
1192+ // Expose assembly as packageBin for cross-project reference
1193+ Compile / packageBin := assembly.value,
11921194 // Source directories
11931195 Compile / unmanagedSourceDirectories := Seq (baseDirectory.value / " src" ),
1196+ // Configure scalaInstance to use the bootstrapped compiler
1197+ scalaInstance := {
1198+ val scalaLibrary = (`scala-library-bootstrapped` / Compile / packageBin).value
1199+ val tastyCore = (`tasty-core-bootstrapped-new` / Compile / packageBin).value
1200+ val scala3Interfaces = (`scala3-interfaces` / Compile / packageBin).value
1201+ val scala3Compiler = (`scala3-compiler-bootstrapped-new` / Compile / packageBin).value
1202+ val externalCompilerDeps = (`scala3-compiler-bootstrapped-new` / Compile / externalDependencyClasspath).value.map(_.data).toSet
1203+
1204+ Defaults .makeScalaInstance(
1205+ dottyVersion,
1206+ libraryJars = Array (scalaLibrary),
1207+ allCompilerJars = Seq (tastyCore, scala3Interfaces, scala3Compiler) ++ externalCompilerDeps,
1208+ allDocJars = Seq .empty,
1209+ state.value,
1210+ scalaInstanceTopLoader.value
1211+ )
1212+ },
11941213 // Assembly configuration for shading
1195- assembly / assemblyJarName := s " scala3-repl-embedded - ${version.value}.jar " ,
1214+ assembly / assemblyJarName := s " scala3-repl-shaded - ${version.value}.jar " ,
11961215 assembly / mainClass := Some (" scala.tools.repl.EmbeddedReplMain" ),
11971216 // Shading rules: relocate specific packages to dotty.tools.repl.shaded, except scala.*, java.*, javax.*
1217+ // Keep org.jline unshaded (needs to access native terminal libraries)
11981218 assembly / assemblyShadeRules := Seq (
1219+ ShadeRule .rename(" org.jline.**" -> " org.jline.@1" ).inAll,
11991220 ShadeRule .rename(" dotty.**" -> " dotty.tools.repl.shaded.dotty.@1" ).inAll,
12001221 ShadeRule .rename(" org.**" -> " dotty.tools.repl.shaded.org.@1" ).inAll,
12011222 ShadeRule .rename(" com.**" -> " dotty.tools.repl.shaded.com.@1" ).inAll,
@@ -1219,18 +1240,49 @@ object Build {
12191240 },
12201241 // Don't run tests for assembly
12211242 assembly / test := {},
1222- // Publishing configuration: publish the assembly jar instead of regular jar
1223- Compile / packageBin := assembly.value,
1243+ // Exclude scala-library and jline from assembly (users provide them on classpath)
1244+ assembly / assemblyExcludedJars := {
1245+ val cp = (assembly / fullClasspath).value
1246+ cp.filter { jar =>
1247+ val name = jar.data.getName
1248+ name.startsWith(" scala-library" ) || name.startsWith(" scala3-library" ) || name.startsWith(" jline" )
1249+ }
1250+ },
1251+ // Don't publish scala3-repl-shaded - it's an internal build artifact
1252+ publish / skip := true ,
1253+ publishLocal / skip := true ,
1254+ // Make assembly jar depend on compile
1255+ assembly := (assembly dependsOn (Compile / compile)).value,
1256+ )
1257+
1258+ lazy val `scala3-repl-embedded` = project.in(file(" repl-embedded-publish" ))
1259+ .dependsOn(`scala-library-bootstrapped`)
1260+ .settings(publishSettings)
1261+ .settings(
1262+ name := " scala3-repl-embedded" ,
1263+ moduleName := " scala3-repl-embedded" ,
1264+ version := dottyVersion,
1265+ versionScheme := Some (" semver-spec" ),
1266+ scalaVersion := referenceVersion,
1267+ crossPaths := true ,
1268+ libraryDependencies ++= Seq (
1269+ " org.jline" % " jline-reader" % " 3.29.0" ,
1270+ " org.jline" % " jline-terminal" % " 3.29.0" ,
1271+ " org.jline" % " jline-terminal-jni" % " 3.29.0" ,
1272+ ),
1273+ // No source files in this project - just publishes the shaded jar
1274+ Compile / unmanagedSourceDirectories := Seq .empty,
1275+ // Use the shaded assembly jar as our packageBin
1276+ Compile / packageBin := (`scala3-repl-shaded` / Compile / packageBin).value,
12241277 Compile / packageBin / artifact := {
12251278 val art = (Compile / packageBin / artifact).value
12261279 art.withClassifier(None )
12271280 },
1281+ // Publish sources from scala3-repl-shaded
12281282 Compile / packageDoc / publishArtifact := false ,
12291283 Compile / packageSrc / publishArtifact := true ,
12301284 Test / publishArtifact := false ,
12311285 publish / skip := false ,
1232- // Make assembly jar depend on packageBin in Compile scope
1233- assembly := (assembly dependsOn (Compile / compile)).value,
12341286 )
12351287
12361288 // ==============================================================================================
0 commit comments