@@ -139,20 +139,23 @@ class ExtractDependencies extends Phase {
139
139
ctx.sbtCallback.binaryDependency(file, binaryClassName, fromClassName, sourceFile, context)
140
140
141
141
def processExternalDependency (depFile : AbstractFile ) = {
142
-
143
- val binaryClassName = ctx.atPhase(ctx.flattenPhase) { implicit ctx =>
144
- if (dep.to.is(JavaDefined )) dep.to.fullName.stripModuleClassSuffix.toString
145
- else dep.to.fullName.toString
146
- }
142
+ def binaryClassName (classSegments : List [String ]) =
143
+ classSegments.mkString(" ." ).stripSuffix(" .class" )
147
144
148
145
depFile match {
149
146
case ze : ZipArchive # Entry => // The dependency comes from a JAR
150
147
for (zip <- ze.underlyingSource; zipFile <- Option (zip.file)) {
151
- binaryDependency(zipFile, binaryClassName)
148
+ val classSegments = io.File (ze.path).segments
149
+ binaryDependency(zipFile, binaryClassName(classSegments))
152
150
}
153
151
154
152
case pf : PlainFile => // The dependency comes from a class file
155
- binaryDependency(pf.file, binaryClassName)
153
+ val packages = dep.to.ownersIterator
154
+ .count(x => x.is(PackageClass ) && ! x.isEffectiveRoot)
155
+ // We can recover the fully qualified name of a classfile from
156
+ // its path
157
+ val classSegments = pf.givenPath.segments.takeRight(packages + 1 )
158
+ binaryDependency(pf.file, binaryClassName(classSegments))
156
159
157
160
case _ =>
158
161
ctx.warning(s " sbt-deps: Ignoring dependency $depFile of class ${depFile.getClass}} " )
0 commit comments