1
0
Fork 0
mirror of https://github.com/ethauvin/kobalt.git synced 2025-04-26 08:27:12 -07:00

Fix the NPE caused by null versions.

This commit is contained in:
Cedric Beust 2015-12-16 18:51:10 +04:00
parent 4fd276cc89
commit 6c36a7c227

View file

@ -26,30 +26,28 @@ public class DepFactory @Inject constructor(val localRepo: LocalRepo,
/**
* Parse the id and return the correct IClasspathDependency
*/
public fun create(id: String, executor: ExecutorService = defExecutor,
localFirst : Boolean = true) : IClasspathDependency {
public fun create(id: String, executor: ExecutorService = defExecutor, localFirst : Boolean = true)
: IClasspathDependency {
if (id.startsWith(FileDependency.PREFIX_FILE)) {
return FileDependency(id.substring(FileDependency.PREFIX_FILE.length))
} else {
val mavenId = MavenId.create(id)
var version = mavenId.version
var packaging = mavenId.packaging
var repoResult: RepoFinder.RepoResult?
if (mavenId.version != null) {
var localVersion: String? = mavenId.version
if (localFirst) localVersion = localRepo.findLocalVersion(mavenId.groupId, mavenId.artifactId, mavenId.packaging)
if (! localFirst || localVersion == null) {
val version = mavenId.version ?:
if (localFirst) {
localRepo.findLocalVersion(mavenId.groupId, mavenId.artifactId, mavenId.packaging)
} else {
repoResult = repoFinder.findCorrectRepo(id)
if (!repoResult.found) {
throw KobaltException("Couldn't resolve $id")
} else {
version = repoResult.version?.version
repoResult.version?.version
}
}
}
return MavenDependency(MavenId.create(mavenId.groupId, mavenId.artifactId, packaging, version!!),
return MavenDependency(MavenId.create(mavenId.groupId, mavenId.artifactId, packaging, version),
executor, localRepo, repoFinder, pomFactory, downloadManager)
}
}