@@ -221,13 +221,19 @@ lazy val compiler = configureAsSubproject(project)
221
221
streams.value.cacheDirectory) ++
222
222
(mappings in Compile in packageBin in LocalProject (" interactive" )).value ++
223
223
(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,
225
227
includeFilter in unmanagedResources in Compile :=
226
228
" *.tmpl" | " *.xml" | " *.js" | " *.css" | " *.html" | " *.properties" | " *.swf" |
227
229
" *.png" | " *.gif" | " *.gif" | " *.txt" ,
228
230
scalacOptions in Compile in doc ++= Seq (
229
231
" -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)
231
237
)
232
238
.dependsOn(library, reflect)
233
239
@@ -288,7 +294,10 @@ lazy val replJlineEmbedded = Project("repl-jline-embedded", file(".") / "target"
288
294
)
289
295
val outdir = (classDirectory in Compile ).value
290
296
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" )
292
301
)
293
302
.dependsOn(replJline)
294
303
@@ -614,4 +623,14 @@ lazy val mkBinImpl: Def.Initialize[Task[Seq[File]]] = Def.task {
614
623
mkBin(" scalap" , " scala.tools.scalap.Main" , (fullClasspath in Compile in scalap).value)
615
624
}
616
625
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
+
617
636
buildDirectory in ThisBuild := (baseDirectory in ThisBuild ).value / " build-sbt"
0 commit comments