From f92c3f59f9046248917916f6400b12b9017cb85b Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Sat, 13 Feb 2016 09:46:11 -0800 Subject: [PATCH] Fix #127. --- .../maven/dependency/MavenDependency.kt | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/dependency/MavenDependency.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/dependency/MavenDependency.kt index d990fc42..1f4212a8 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/dependency/MavenDependency.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/dependency/MavenDependency.kt @@ -45,11 +45,28 @@ class MavenDependency @Inject constructor( pomFile = CompletedFuture(pom) } else { val repoResult = repoFinder.findCorrectRepo(mavenId.toId) + + fun toSuffix(name: String, suffix: String = "") : String { + val dot = name.lastIndexOf(".") + return name.substring(0, dot) + suffix + name.substring(dot) + } + + fun download(url: String, fileName: String, suffix: String = "") : Future { + val localPath = localRepo.toFullPath(toSuffix(fileName, suffix)) + return downloadManager.download(HostConfig(toSuffix(url, suffix)), localPath, executor) + } + if (repoResult.found) { jarFile = if (repoResult.archiveUrl != null) { - val path = localRepo.toFullPath(repoResult.path!!) - downloadManager.download(HostConfig(url = repoResult.archiveUrl), path, executor) + val result = download(repoResult.archiveUrl, repoResult.path!!) + if (downloadSources) { + download(repoResult.archiveUrl, repoResult.path, "-sources") + } + if (downloadJavadocs) { + download(repoResult.archiveUrl, repoResult.path, "-javadoc") + } + result } else { CompletedFuture(File("nonexistentFile")) // will be filtered out }