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

Add -downloadSources.

This commit is contained in:
Cedric Beust 2017-03-30 13:29:25 -07:00
parent 79c01b1149
commit 1730e8de69
3 changed files with 22 additions and 3 deletions

View file

@ -22,6 +22,10 @@ class Args {
@Parameter(names = arrayOf("--download"), description = "Force a download from the downloadUrl in the wrapper")
var download: Boolean = false
@Parameter(names = arrayOf("--downloadSources"),
description = "Force a download of sources and javadocs when resolving dependencies")
var downloadSources: Boolean = false
@Parameter(names = arrayOf("--dryRun"), description = "Display all the tasks that will get run without " +
"actually running them")
var dryRun: Boolean = false

View file

@ -1,5 +1,6 @@
package com.beust.kobalt.maven.aether
import com.beust.kobalt.Args
import com.beust.kobalt.api.Kobalt
import com.beust.kobalt.internal.KobaltSettings
import com.beust.kobalt.internal.getProxy
@ -21,6 +22,7 @@ import org.eclipse.aether.resolution.VersionRangeRequest
import org.eclipse.aether.resolution.VersionRangeResult
class KobaltMavenResolver @Inject constructor(val settings: KobaltSettings,
val args: Args,
localRepo: LocalRepo, eventBus: EventBus) {
companion object {
@ -101,7 +103,18 @@ class KobaltMavenResolver @Inject constructor(val settings: KobaltSettings,
}
private fun createCollectRequest(id: String, scope: Scope? = null) = CollectRequest().apply {
root = Dependency(DefaultArtifact(MavenId.toKobaltId(id)), scope?.scope)
val allIds = arrayListOf(MavenId.toMavenId(id))
if (args.downloadSources) {
listOf("sources", "javadoc").forEach {
val artifact = DefaultArtifact(id)
val sourceArtifact = DefaultArtifact(artifact.groupId, artifact.artifactId, it, artifact.extension,
artifact.version)
allIds.add(sourceArtifact.toString())
}
}
dependencies = allIds.map { Dependency(DefaultArtifact(it), scope?.scope) }
root = Dependency(DefaultArtifact(MavenId.toMavenId(id)), scope?.scope)
repositories = kobaltRepositories
}
}