diff --git a/TODO b/TODO index 63e1e2ef..35b5b160 100644 --- a/TODO +++ b/TODO @@ -1,5 +1,8 @@ To do: +- Link kobalt to JCenter +- --update +- --resolve - ProjectGenerator: support migration from pom.xml (starting with dependencies) - Generate .idea and other IDEA files - Make files appear in download list automatically on bintray (undocumented API) @@ -22,6 +25,7 @@ To do: Done: +- Support .pom pointing to other deps (and no jars) - provided scope - --dryRun - --init: import dependencies from pom.xml diff --git a/kobalt/wrapper/kobalt-wrapper.jar b/kobalt/wrapper/kobalt-wrapper.jar index 03c34295..4c3c9b4b 100644 Binary files a/kobalt/wrapper/kobalt-wrapper.jar and b/kobalt/wrapper/kobalt-wrapper.jar differ diff --git a/kobalt/wrapper/kobalt-wrapper.properties b/kobalt/wrapper/kobalt-wrapper.properties index d9b4c097..5a3e80e4 100644 --- a/kobalt/wrapper/kobalt-wrapper.properties +++ b/kobalt/wrapper/kobalt-wrapper.properties @@ -1 +1 @@ -kobalt.version=0.148 +kobalt.version=0.151 \ No newline at end of file diff --git a/src/main/kotlin/com/beust/kobalt/maven/DependencyManager.kt b/src/main/kotlin/com/beust/kobalt/maven/DependencyManager.kt index bf709c40..b0553f33 100644 --- a/src/main/kotlin/com/beust/kobalt/maven/DependencyManager.kt +++ b/src/main/kotlin/com/beust/kobalt/maven/DependencyManager.kt @@ -24,7 +24,8 @@ public class DependencyManager @Inject constructor(val executors: KobaltExecutor } val result2 = reorderDependencies(result).filter { - // Only keep existent files (nonexistent files are probably optional dependencies) + // Only keep existent files (nonexistent files are probably optional dependencies or parent poms + // that point to other poms but don't have a jar file themselves) it.jarFile.get().exists() } diff --git a/src/main/kotlin/com/beust/kobalt/maven/MavenDependency.kt b/src/main/kotlin/com/beust/kobalt/maven/MavenDependency.kt index 64532afb..c7b34342 100644 --- a/src/main/kotlin/com/beust/kobalt/maven/MavenDependency.kt +++ b/src/main/kotlin/com/beust/kobalt/maven/MavenDependency.kt @@ -32,8 +32,12 @@ public class MavenDependency @Inject constructor(override @Assisted("groupId") v } else { val repoResult = repoFinder.findCorrectRepo(toId(groupId, artifactId, version)) if (repoResult.found) { - jarFile = downloadManager.download(repoResult.repoUrl + toJarFile(repoResult), jar.absolutePath, - executor) + jarFile = + if (repoResult.hasJar) { + downloadManager.download(repoResult.repoUrl + toJarFile(repoResult), jar.absolutePath, executor) + } else { + CompletedFuture(File("nonexistentFile")) // will be filtered out + } pomFile = downloadManager.download(repoResult.repoUrl + toPomFile(repoResult), pom.absolutePath, executor) } else { diff --git a/src/main/kotlin/com/beust/kobalt/maven/RepoFinder.kt b/src/main/kotlin/com/beust/kobalt/maven/RepoFinder.kt index 7559e173..c1a8d5a9 100644 --- a/src/main/kotlin/com/beust/kobalt/maven/RepoFinder.kt +++ b/src/main/kotlin/com/beust/kobalt/maven/RepoFinder.kt @@ -7,6 +7,7 @@ import com.beust.kobalt.misc.Strings import com.google.common.cache.CacheBuilder import com.google.common.cache.CacheLoader import com.google.common.cache.LoadingCache +import java.io.File import java.util.concurrent.Callable import java.util.concurrent.ExecutorCompletionService import java.util.concurrent.TimeUnit @@ -24,7 +25,7 @@ public class RepoFinder @Inject constructor(val http: Http, val executors: Kobal return FOUND_REPOS.get(id) } - data class RepoResult(val repoUrl: String, val found: Boolean, val version: String, + data class RepoResult(val repoUrl: String, val found: Boolean, val version: String, val hasJar: Boolean = true, val snapshotVersion: String = "") private val FOUND_REPOS: LoadingCache = CacheBuilder.newBuilder() @@ -83,16 +84,26 @@ public class RepoFinder @Inject constructor(val http: Http, val executors: Kobal val dep = SimpleDep(c[0], c[1], c[2]) val snapshotVersion = findSnapshotVersion(dep.toMetadataXmlPath(false), repoUrl) if (snapshotVersion != null) { - return RepoResult(repoUrl, true, c[2], snapshotVersion) + return RepoResult(repoUrl, true, c[2], true /* hasJar, potential bug here */, snapshotVersion) } else { return RepoResult(repoUrl, false, "") } } else { val dep = SimpleDep(c[0], c[1], c[2]) - val url = repoUrl + "/" + dep.toJarFile(dep.version) - val body = http.get(url) - log(2, "Result for ${repoUrl} for ${id}: ${body.code == 200}") - return RepoResult(repoUrl, body.code == 200, dep.version) + // Try to find the jar file + val urlJar = repoUrl + dep.toJarFile(dep.version) + val hasJar = http.get(urlJar).code == 200 + + val found = + if (! hasJar) { + // No jar, try to find the directory + val url = repoUrl + File(dep.toJarFile(dep.version)).parentFile.path + http.get(url).code == 200 + } else { + true + } + log(2, "Result for $repoUrl for $id: $found") + return RepoResult(repoUrl, found, dep.version, hasJar) } } } diff --git a/src/main/resources/kobalt.properties b/src/main/resources/kobalt.properties index afd8368a..5a3e80e4 100644 --- a/src/main/resources/kobalt.properties +++ b/src/main/resources/kobalt.properties @@ -1 +1 @@ -kobalt.version=0.148 \ No newline at end of file +kobalt.version=0.151 \ No newline at end of file