@@ -221,13 +221,19 @@ lazy val compiler = configureAsSubproject(project)
221221 streams.value.cacheDirectory) ++
222222 (mappings in Compile in packageBin in LocalProject (" interactive" )).value ++
223223 (mappings in Compile in packageBin in LocalProject (" scaladoc" )).value ++
224- (mappings in Compile in packageBin in LocalProject (" repl" )).value,
224+ (mappings in Compile in packageBin in LocalProject (" repl" )).value ++
225+ (mappings in Compile in packageBin in LocalProject (" repl-jline" )).value.filter(_._2 != " repl-jline.properties" ) ++
226+ (mappings in Compile in packageBin in LocalProject (" repl-jline-embedded" )).value,
225227 includeFilter in unmanagedResources in Compile :=
226228 " *.tmpl" | " *.xml" | " *.js" | " *.css" | " *.html" | " *.properties" | " *.swf" |
227229 " *.png" | " *.gif" | " *.gif" | " *.txt" ,
228230 scalacOptions in Compile in doc ++= Seq (
229231 " -doc-root-content" , (sourceDirectory in Compile ).value + " /rootdoc.txt"
230- )
232+ ),
233+ // Generate the ScriptEngineFactory service definition. The ant build does this when building
234+ // the JAR but sbt has no support for it and it is easier to do as a resource generator:
235+ generateServiceProviderResources(" javax.script.ScriptEngineFactory" -> " scala.tools.nsc.interpreter.IMain$Factory" ),
236+ managedResourceDirectories in Compile := Seq ((resourceManaged in Compile ).value)
231237 )
232238 .dependsOn(library, reflect)
233239
@@ -288,7 +294,10 @@ lazy val replJlineEmbedded = Project("repl-jline-embedded", file(".") / "target"
288294 )
289295 val outdir = (classDirectory in Compile ).value
290296 JarJar (inputs, outdir, config)
291- })
297+ }),
298+ // Exclude repl-jline-embedded.properties from JAR
299+ mappings in (Compile , packageBin) :=
300+ (mappings in (Compile , packageBin)).value.filter(_._2 != " repl-jline-embedded.properties" )
292301 )
293302 .dependsOn(replJline)
294303
@@ -614,4 +623,14 @@ lazy val mkBinImpl: Def.Initialize[Task[Seq[File]]] = Def.task {
614623 mkBin(" scalap" , " scala.tools.scalap.Main" , (fullClasspath in Compile in scalap).value)
615624}
616625
626+ /** Generate service provider definition files under META-INF/services */
627+ def generateServiceProviderResources (services : (String , String )* ): Setting [_] =
628+ resourceGenerators in Compile += Def .task {
629+ services.map { case (k, v) =>
630+ val f = (resourceManaged in Compile ).value / " META-INF/services" / k
631+ IO .write(f, v + " \n " )
632+ f
633+ }
634+ }.taskValue
635+
617636buildDirectory in ThisBuild := (baseDirectory in ThisBuild ).value / " build-sbt"
0 commit comments