mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 00:17:11 -07:00
Add -downloadSources.
This commit is contained in:
parent
79c01b1149
commit
1730e8de69
3 changed files with 22 additions and 3 deletions
|
@ -22,6 +22,10 @@ class Args {
|
||||||
@Parameter(names = arrayOf("--download"), description = "Force a download from the downloadUrl in the wrapper")
|
@Parameter(names = arrayOf("--download"), description = "Force a download from the downloadUrl in the wrapper")
|
||||||
var download: Boolean = false
|
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 " +
|
@Parameter(names = arrayOf("--dryRun"), description = "Display all the tasks that will get run without " +
|
||||||
"actually running them")
|
"actually running them")
|
||||||
var dryRun: Boolean = false
|
var dryRun: Boolean = false
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.beust.kobalt.maven.aether
|
package com.beust.kobalt.maven.aether
|
||||||
|
|
||||||
|
import com.beust.kobalt.Args
|
||||||
import com.beust.kobalt.api.Kobalt
|
import com.beust.kobalt.api.Kobalt
|
||||||
import com.beust.kobalt.internal.KobaltSettings
|
import com.beust.kobalt.internal.KobaltSettings
|
||||||
import com.beust.kobalt.internal.getProxy
|
import com.beust.kobalt.internal.getProxy
|
||||||
|
@ -21,6 +22,7 @@ import org.eclipse.aether.resolution.VersionRangeRequest
|
||||||
import org.eclipse.aether.resolution.VersionRangeResult
|
import org.eclipse.aether.resolution.VersionRangeResult
|
||||||
|
|
||||||
class KobaltMavenResolver @Inject constructor(val settings: KobaltSettings,
|
class KobaltMavenResolver @Inject constructor(val settings: KobaltSettings,
|
||||||
|
val args: Args,
|
||||||
localRepo: LocalRepo, eventBus: EventBus) {
|
localRepo: LocalRepo, eventBus: EventBus) {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
@ -101,7 +103,18 @@ class KobaltMavenResolver @Inject constructor(val settings: KobaltSettings,
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun createCollectRequest(id: String, scope: Scope? = null) = CollectRequest().apply {
|
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
|
repositories = kobaltRepositories
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,9 @@ package com.beust.kobalt
|
||||||
|
|
||||||
import com.beust.kobalt.api.KobaltContext
|
import com.beust.kobalt.api.KobaltContext
|
||||||
import com.beust.kobalt.app.MainModule
|
import com.beust.kobalt.app.MainModule
|
||||||
import com.beust.kobalt.internal.*
|
import com.beust.kobalt.internal.ILogger
|
||||||
|
import com.beust.kobalt.internal.KobaltSettings
|
||||||
|
import com.beust.kobalt.internal.KobaltSettingsXml
|
||||||
import com.beust.kobalt.maven.LocalRepo
|
import com.beust.kobalt.maven.LocalRepo
|
||||||
import com.beust.kobalt.maven.aether.KobaltMavenResolver
|
import com.beust.kobalt.maven.aether.KobaltMavenResolver
|
||||||
import com.beust.kobalt.misc.kobaltLog
|
import com.beust.kobalt.misc.kobaltLog
|
||||||
|
@ -24,7 +26,7 @@ class TestModule : MainModule(Args(), TEST_KOBALT_SETTINGS) {
|
||||||
val localRepo = TestLocalRepo()
|
val localRepo = TestLocalRepo()
|
||||||
bind(LocalRepo::class.java).toInstance(localRepo)
|
bind(LocalRepo::class.java).toInstance(localRepo)
|
||||||
// val localAether = Aether(LOCAL_CACHE, TEST_KOBALT_SETTINGS, EventBus())
|
// val localAether = Aether(LOCAL_CACHE, TEST_KOBALT_SETTINGS, EventBus())
|
||||||
val testResolver = KobaltMavenResolver(KobaltSettings(KobaltSettingsXml()), TestLocalRepo(), EventBus())
|
val testResolver = KobaltMavenResolver(KobaltSettings(KobaltSettingsXml()), Args(), TestLocalRepo(), EventBus())
|
||||||
bind(KobaltMavenResolver::class.java).to(testResolver)
|
bind(KobaltMavenResolver::class.java).to(testResolver)
|
||||||
bind(KobaltContext::class.java).toProvider(Provider<KobaltContext> {
|
bind(KobaltContext::class.java).toProvider(Provider<KobaltContext> {
|
||||||
KobaltContext(args).apply {
|
KobaltContext(args).apply {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue