diff --git a/src/main/scala/sbt/Analysis.scala b/src/main/scala/sbt/Analysis.scala
index 4498fd800..898249b26 100644
--- a/src/main/scala/sbt/Analysis.scala
+++ b/src/main/scala/sbt/Analysis.scala
@@ -95,6 +95,11 @@ sealed class BasicAnalysis(analysisPath: Path, projectPath: Path, log: Logger) e
def addSourceDependency(on: Path, from: Path) = add(on, from, sourceDependencyMap)
def addExternalDependency(on: File, from: Path) = add(on.getAbsoluteFile, from, externalDependencyMap)
+ def addProductDependency(on: Path, from: Path) =
+ {
+ for( (source, _) <- productMap.find(_._2.contains(on)) )
+ addSourceDependency(source, from)
+ }
def addProduct(source: Path, file: Path) = add(source, file, productMap)
def addSource(source: Path) =
{
diff --git a/src/main/scala/sbt/AnalysisCallback.scala b/src/main/scala/sbt/AnalysisCallback.scala
index e20d9190b..3578c8942 100644
--- a/src/main/scala/sbt/AnalysisCallback.scala
+++ b/src/main/scala/sbt/AnalysisCallback.scala
@@ -45,6 +45,12 @@ trait AnalysisCallback extends NotNull
/** Called to indicate that the source file sourcePath depends on the class file
* classFile.*/
def classDependency(classFile: File, sourcePath: Path): Unit
+ /** Called to indicate that the source file sourcePath depends on the class file
+ * classFile that is a product of some source. This differs from classDependency
+ * because it is really a sourceDependency. The source corresponding to classFile
+ * was not incuded in the compilation so the plugin doesn't know what the source is though. It
+ * only knows that the class file came from the output directory.*/
+ def productDependency(classFile: Path, sourcePath: Path): Unit
/** Called to indicate that the source file sourcePath produces a class file at
* modulePath.*/
def generatedClass(sourcePath: Path, modulePath: Path): Unit
@@ -58,36 +64,30 @@ abstract class BasicAnalysisCallback[A <: BasicCompileAnalysis](val basePath: Pa
{
def superclassNotFound(superclassName: String) {}
- def beginSource(sourcePath: Path)
- {
+ def beginSource(sourcePath: Path): Unit =
analysis.addSource(sourcePath)
- }
- def sourceDependency(dependsOnPath: Path, sourcePath: Path)
- {
+
+ def sourceDependency(dependsOnPath: Path, sourcePath: Path): Unit =
analysis.addSourceDependency(dependsOnPath, sourcePath)
- }
- def jarDependency(jarFile: File, sourcePath: Path)
- {
+
+ def jarDependency(jarFile: File, sourcePath: Path): Unit =
analysis.addExternalDependency(jarFile, sourcePath)
- }
- def classDependency(classFile: File, sourcePath: Path)
- {
+
+ def classDependency(classFile: File, sourcePath: Path): Unit =
analysis.addExternalDependency(classFile, sourcePath)
- }
- def generatedClass(sourcePath: Path, modulePath: Path)
- {
+
+ def productDependency(classFile: Path, sourcePath: Path): Unit =
+ analysis.addProductDependency(classFile, sourcePath)
+
+ def generatedClass(sourcePath: Path, modulePath: Path): Unit =
analysis.addProduct(sourcePath, modulePath)
- }
- def endSource(sourcePath: Path)
- {
+
+ def endSource(sourcePath: Path): Unit =
analysis.removeSelfDependency(sourcePath)
- }
}
abstract class BasicCompileAnalysisCallback(basePath: Path, superclassNames: Iterable[String], analysis: CompileAnalysis)
extends BasicAnalysisCallback(basePath, superclassNames, analysis)
{
- def foundApplication(sourcePath: Path, className: String)
- {
+ def foundApplication(sourcePath: Path, className: String): Unit =
analysis.addApplication(sourcePath, className)
- }
}
\ No newline at end of file
diff --git a/src/main/scala/sbt/Analyzer.scala b/src/main/scala/sbt/Analyzer.scala
index 3e45d804a..b1e8a0462 100644
--- a/src/main/scala/sbt/Analyzer.scala
+++ b/src/main/scala/sbt/Analyzer.scala
@@ -119,9 +119,13 @@ class Analyzer(val global: Global) extends Plugin
case ze: ZipArchive#Entry => callback.jarDependency(new File(ze.getArchive.getName), sourcePath)
case pf: PlainFile =>
{
- // ignore dependencies in the output directory: these are handled by source dependencies
- if(Path.relativize(outputPath, pf.file).isEmpty)
- callback.classDependency(pf.file, sourcePath)
+ Path.relativize(outputPath, pf.file) match
+ {
+ case None => // dependency is a class file outside of the output directory
+ callback.classDependency(pf.file, sourcePath)
+ case Some(relativeToOutput) => // dependency is a product of a source not included in this compilation
+ callback.productDependency(relativeToOutput, sourcePath)
+ }
}
case _ => ()
}
@@ -182,6 +186,14 @@ class Analyzer(val global: Global) extends Plugin
val entry = classPath.root.find(name, false)
if (entry ne null)
Some(entry.classFile)
+ else if(isTopLevelModule(sym))
+ {
+ val linked = sym.linkedClassOfModule
+ if(linked == NoSymbol)
+ None
+ else
+ classFile(linked)
+ }
else
None
}