mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 08:27:12 -07:00
Refactor some downloadSources code.
This commit is contained in:
parent
1c27b9f1e4
commit
bb2eb19876
2 changed files with 15 additions and 23 deletions
|
@ -26,33 +26,24 @@ class AetherDependency(val artifact: Artifact, override val optional: Boolean =
|
|||
private fun toId(a: Artifact) = a.toString()
|
||||
|
||||
override val jarFile: Future<File>
|
||||
get() =
|
||||
if (artifact.file != null) {
|
||||
get() {
|
||||
resolveSourcesIfNeeded()
|
||||
return if (artifact.file != null) {
|
||||
CompletedFuture(artifact.file)
|
||||
} else {
|
||||
resolveSourcesIfNeeded()
|
||||
val td = aether.resolve(artifact)
|
||||
CompletedFuture(td.root.artifact.file)
|
||||
}
|
||||
}
|
||||
|
||||
private fun resolveSourcesIfNeeded() {
|
||||
if (args?.downloadSources ?: false) {
|
||||
artifact.toSourcesArtifact().let { sourcesArtifact ->
|
||||
if (sourcesArtifact.file == null) {
|
||||
listOf(artifact.toSourcesArtifact(), artifact.toJavaDocArtifact()).forEach { artifact ->
|
||||
if (artifact.file == null) {
|
||||
try {
|
||||
aether.resolve(sourcesArtifact)
|
||||
aether.resolve(artifact)
|
||||
} catch(e: DependencyResolutionException) {
|
||||
//do nothing
|
||||
}
|
||||
}
|
||||
}
|
||||
artifact.toJavaDocArtifact().let { javadocArtifact ->
|
||||
if (javadocArtifact.file == null) {
|
||||
try {
|
||||
aether.resolve(javadocArtifact)
|
||||
} catch(e: DependencyResolutionException) {
|
||||
//do nothing
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,7 +47,8 @@ class GetDependencyGraphHandler : WebSocketListener {
|
|||
}
|
||||
|
||||
private fun findProfiles(map: Map<String, List<String>>) = map[PARAMETER_PROFILES]?.getOrNull(0)
|
||||
private fun findDownloadSources(map: Map<String, List<String>>) = map[PARAMETER_DOWNLOAD_SOURCES]?.getOrNull(0)?.toBoolean() ?: false
|
||||
private fun findDownloadSources(map: Map<String, List<String>>) = map[PARAMETER_DOWNLOAD_SOURCES]
|
||||
?.getOrNull(0)?.toBoolean() ?: false
|
||||
|
||||
private fun findBuildFile(map: Map<String, List<String>>) : BuildSources? {
|
||||
val projectRoot = map[PARAMETER_PROJECT_ROOT]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue