Skip to content

Commit

Permalink
Fix sources jar search logic. (#479)
Browse files Browse the repository at this point in the history
  • Loading branch information
artem-zinnatullin authored and kageiit committed Jul 21, 2017
1 parent 1099d38 commit e770458
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
Binary file added app/aars/rxscreenshotdetector-1.2.0-sources.jar
Binary file not shown.
File renamed without changes.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ repositories {

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile(name: 'rxscreenshotdetector-release', ext: 'aar')
compile(name: 'rxscreenshotdetector-1.2.0', ext: 'aar')
compile deps.external.rxjava
compile deps.external.rxandroid
compile deps.external.rxPermissions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,20 @@ class DependencyCache {
File sourcesJar = new File(dependency.depFile.parentFile, sourcesJarName)

if (!sourcesJar.exists()) {
def sourceJars = rootProject.fileTree(
dir: dependency.depFile.parentFile.parentFile.absolutePath,
includes: ["**/${sourcesJarName}"]) as List
if (sourceJars.size() == 1) {
sourcesJar = sourceJars[0]
} else if (sourceJars.size() > 1) {
throw new IllegalStateException("Found multiple source jars: ${sourceJars} for ${dependency}")
if (dependency.isLocal) {
// Try to use sources jar right next to the jar itself.
sourcesJar = new File(dependency.depFile.parentFile, sourcesJarName)
} else {
// Most likely jar is in Gradle/Maven cache directory, try to find sources jar in "jar/../..".
def sourceJars = rootProject.fileTree(
dir: dependency.depFile.parentFile.parentFile.absolutePath,
includes: ["**/${sourcesJarName}"]) as List

if (sourceJars.size() == 1) {
sourcesJar = sourceJars[0]
} else if (sourceJars.size() > 1) {
throw new IllegalStateException("Found multiple source jars: ${sourceJars} for ${dependency}")
}
}
}
if (sourcesJar.exists()) {
Expand Down

0 comments on commit e770458

Please sign in to comment.