Skip to content

Commit

Permalink
Merge pull request #478 from avently/master
Browse files Browse the repository at this point in the history
Added "offline" argument to prevent remote resolving of dependencies
  • Loading branch information
cbeust authored Mar 21, 2018
2 parents 2241323 + f1a0250 commit c6b180d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ class Args {
@Parameter(names = arrayOf("--noIncremental"), description = "Turn off incremental builds")
var noIncremental: Boolean = false

@Parameter(names = arrayOf("--offline"), description = "Don't try to download dependencies even if there is no cached version")
var offline: Boolean = false

@Parameter(names = arrayOf("--plugins"), description = "Comma-separated list of plug-in Maven id's")
var pluginIds: String? = null

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.beust.kobalt.maven.aether

import com.beust.kobalt.internal.KobaltSettings
import com.google.common.eventbus.EventBus
import com.beust.kobalt.Args
import org.eclipse.aether.DefaultRepositorySystemSession
import org.eclipse.aether.RepositorySystem
import org.eclipse.aether.repository.LocalRepository
Expand Down Expand Up @@ -32,8 +33,9 @@ object Booter {
// }

fun newRepositorySystemSession(system: RepositorySystem, repo: File, settings: KobaltSettings,
eventBus: EventBus): DefaultRepositorySystemSession {
args: Args, eventBus: EventBus): DefaultRepositorySystemSession {
val session = MavenRepositorySystemUtils.newSession(settings)
session.isOffline = args.offline

val localRepo = LocalRepository(repo.absolutePath)
session.localRepositoryManager = system.newLocalRepositoryManager(session, localRepo)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ class KobaltMavenResolver @Inject constructor(val settings: KobaltSettings,
fun create(id: String, optional: Boolean) = AetherDependency(DefaultArtifact(id), optional, args)

private val system = Booter.newRepositorySystem()
private val session = Booter.newRepositorySystemSession(system, localRepo.localRepo, settings, eventBus)
private val session = Booter.newRepositorySystemSession(system, localRepo.localRepo, settings, args, eventBus)

private fun createRepo(hostConfig: HostConfig) : RemoteRepository {
val builder = RemoteRepository.Builder(hostConfig.name, "default", hostConfig.url)
Expand Down

0 comments on commit c6b180d

Please sign in to comment.