From 27922a32569103f0e0ea8703a446d997623acfe4 Mon Sep 17 00:00:00 2001 From: Mark Harrah Date: Wed, 31 Mar 2010 22:33:42 -0400 Subject: [PATCH] In component compiler, only consider files from jars with sources. This avoids including dependencies in generated jars. --- compile/ComponentCompiler.scala | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/compile/ComponentCompiler.scala b/compile/ComponentCompiler.scala index 582c2eaf2..495988f76 100644 --- a/compile/ComponentCompiler.scala +++ b/compile/ComponentCompiler.scala @@ -39,10 +39,13 @@ class ComponentCompiler(compiler: RawCompiler, manager: ComponentManager) * any resources from the source jars into a final jar.*/ private def compileSources(sourceJars: Iterable[File], targetJar: File, id: String) { + val isSource = (f: File) => isSourceName(f.getName) + def keepIfSource(files: Set[File]): Set[File] = if(files.exists(isSource)) files else Set() + import Paths._ withTemporaryDirectory { dir => - val extractedSources = (Set[File]() /: sourceJars) { (extracted, sourceJar)=> extracted ++ unzip(sourceJar, dir) } - val (sourceFiles, resources) = extractedSources.partition(_.getName.endsWith(".scala")) + val extractedSources = (Set[File]() /: sourceJars) { (extracted, sourceJar)=> extracted ++ keepIfSource(unzip(sourceJar, dir)) } + val (sourceFiles, resources) = extractedSources.partition(isSource) withTemporaryDirectory { outputDirectory => val xsbtiJars = manager.files(xsbtiID)(IfMissing.Fail) manager.log.info("'" + id + "' not yet compiled for Scala " + compiler.scalaInstance.actualVersion + ". Compiling...") @@ -58,4 +61,5 @@ class ComponentCompiler(compiler: RawCompiler, manager: ComponentManager) } } } + private def isSourceName(name: String): Boolean = name.endsWith(".scala") || name.endsWith(".java") } \ No newline at end of file