mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 16:28:12 -07:00
Fix the NPE caused by null versions.
This commit is contained in:
parent
4fd276cc89
commit
6c36a7c227
1 changed files with 8 additions and 10 deletions
|
@ -26,30 +26,28 @@ public class DepFactory @Inject constructor(val localRepo: LocalRepo,
|
||||||
/**
|
/**
|
||||||
* Parse the id and return the correct IClasspathDependency
|
* Parse the id and return the correct IClasspathDependency
|
||||||
*/
|
*/
|
||||||
public fun create(id: String, executor: ExecutorService = defExecutor,
|
public fun create(id: String, executor: ExecutorService = defExecutor, localFirst : Boolean = true)
|
||||||
localFirst : Boolean = true) : IClasspathDependency {
|
: IClasspathDependency {
|
||||||
if (id.startsWith(FileDependency.PREFIX_FILE)) {
|
if (id.startsWith(FileDependency.PREFIX_FILE)) {
|
||||||
return FileDependency(id.substring(FileDependency.PREFIX_FILE.length))
|
return FileDependency(id.substring(FileDependency.PREFIX_FILE.length))
|
||||||
} else {
|
} else {
|
||||||
val mavenId = MavenId.create(id)
|
val mavenId = MavenId.create(id)
|
||||||
var version = mavenId.version
|
|
||||||
var packaging = mavenId.packaging
|
var packaging = mavenId.packaging
|
||||||
var repoResult: RepoFinder.RepoResult?
|
var repoResult: RepoFinder.RepoResult?
|
||||||
|
|
||||||
if (mavenId.version != null) {
|
val version = mavenId.version ?:
|
||||||
var localVersion: String? = mavenId.version
|
if (localFirst) {
|
||||||
if (localFirst) localVersion = localRepo.findLocalVersion(mavenId.groupId, mavenId.artifactId, mavenId.packaging)
|
localRepo.findLocalVersion(mavenId.groupId, mavenId.artifactId, mavenId.packaging)
|
||||||
if (! localFirst || localVersion == null) {
|
} else {
|
||||||
repoResult = repoFinder.findCorrectRepo(id)
|
repoResult = repoFinder.findCorrectRepo(id)
|
||||||
if (!repoResult.found) {
|
if (!repoResult.found) {
|
||||||
throw KobaltException("Couldn't resolve $id")
|
throw KobaltException("Couldn't resolve $id")
|
||||||
} else {
|
} 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)
|
executor, localRepo, repoFinder, pomFactory, downloadManager)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue