mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-25 16:07:12 -07:00
Support parent poms.
This commit is contained in:
parent
34c630883c
commit
d4c51cb6ba
7 changed files with 31 additions and 11 deletions
4
TODO
4
TODO
|
@ -1,5 +1,8 @@
|
||||||
To do:
|
To do:
|
||||||
|
|
||||||
|
- Link kobalt to JCenter
|
||||||
|
- --update
|
||||||
|
- --resolve <dep>
|
||||||
- ProjectGenerator: support migration from pom.xml (starting with dependencies)
|
- ProjectGenerator: support migration from pom.xml (starting with dependencies)
|
||||||
- Generate .idea and other IDEA files
|
- Generate .idea and other IDEA files
|
||||||
- Make files appear in download list automatically on bintray (undocumented API)
|
- Make files appear in download list automatically on bintray (undocumented API)
|
||||||
|
@ -22,6 +25,7 @@ To do:
|
||||||
|
|
||||||
Done:
|
Done:
|
||||||
|
|
||||||
|
- Support .pom pointing to other deps (and no jars)
|
||||||
- provided scope
|
- provided scope
|
||||||
- --dryRun
|
- --dryRun
|
||||||
- --init: import dependencies from pom.xml
|
- --init: import dependencies from pom.xml
|
||||||
|
|
Binary file not shown.
|
@ -1 +1 @@
|
||||||
kobalt.version=0.148
|
kobalt.version=0.151
|
|
@ -24,7 +24,8 @@ public class DependencyManager @Inject constructor(val executors: KobaltExecutor
|
||||||
}
|
}
|
||||||
|
|
||||||
val result2 = reorderDependencies(result).filter {
|
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()
|
it.jarFile.get().exists()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,8 +32,12 @@ public class MavenDependency @Inject constructor(override @Assisted("groupId") v
|
||||||
} else {
|
} else {
|
||||||
val repoResult = repoFinder.findCorrectRepo(toId(groupId, artifactId, version))
|
val repoResult = repoFinder.findCorrectRepo(toId(groupId, artifactId, version))
|
||||||
if (repoResult.found) {
|
if (repoResult.found) {
|
||||||
jarFile = downloadManager.download(repoResult.repoUrl + toJarFile(repoResult), jar.absolutePath,
|
jarFile =
|
||||||
executor)
|
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,
|
pomFile = downloadManager.download(repoResult.repoUrl + toPomFile(repoResult), pom.absolutePath,
|
||||||
executor)
|
executor)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -7,6 +7,7 @@ import com.beust.kobalt.misc.Strings
|
||||||
import com.google.common.cache.CacheBuilder
|
import com.google.common.cache.CacheBuilder
|
||||||
import com.google.common.cache.CacheLoader
|
import com.google.common.cache.CacheLoader
|
||||||
import com.google.common.cache.LoadingCache
|
import com.google.common.cache.LoadingCache
|
||||||
|
import java.io.File
|
||||||
import java.util.concurrent.Callable
|
import java.util.concurrent.Callable
|
||||||
import java.util.concurrent.ExecutorCompletionService
|
import java.util.concurrent.ExecutorCompletionService
|
||||||
import java.util.concurrent.TimeUnit
|
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)
|
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 = "")
|
val snapshotVersion: String = "")
|
||||||
|
|
||||||
private val FOUND_REPOS: LoadingCache<String, RepoResult> = CacheBuilder.newBuilder()
|
private val FOUND_REPOS: LoadingCache<String, RepoResult> = 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 dep = SimpleDep(c[0], c[1], c[2])
|
||||||
val snapshotVersion = findSnapshotVersion(dep.toMetadataXmlPath(false), repoUrl)
|
val snapshotVersion = findSnapshotVersion(dep.toMetadataXmlPath(false), repoUrl)
|
||||||
if (snapshotVersion != null) {
|
if (snapshotVersion != null) {
|
||||||
return RepoResult(repoUrl, true, c[2], snapshotVersion)
|
return RepoResult(repoUrl, true, c[2], true /* hasJar, potential bug here */, snapshotVersion)
|
||||||
} else {
|
} else {
|
||||||
return RepoResult(repoUrl, false, "")
|
return RepoResult(repoUrl, false, "")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
val dep = SimpleDep(c[0], c[1], c[2])
|
val dep = SimpleDep(c[0], c[1], c[2])
|
||||||
val url = repoUrl + "/" + dep.toJarFile(dep.version)
|
// Try to find the jar file
|
||||||
val body = http.get(url)
|
val urlJar = repoUrl + dep.toJarFile(dep.version)
|
||||||
log(2, "Result for ${repoUrl} for ${id}: ${body.code == 200}")
|
val hasJar = http.get(urlJar).code == 200
|
||||||
return RepoResult(repoUrl, body.code == 200, dep.version)
|
|
||||||
|
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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
kobalt.version=0.148
|
kobalt.version=0.151
|
Loading…
Add table
Add a link
Reference in a new issue