diff --git a/librarymanagement/src/main/contraband/librarymanagement.json b/librarymanagement/src/main/contraband/librarymanagement.json index 2880c89e1..50035dd53 100644 --- a/librarymanagement/src/main/contraband/librarymanagement.json +++ b/librarymanagement/src/main/contraband/librarymanagement.json @@ -524,6 +524,7 @@ "target": "Scala", "type": "interface", "doc": "sbt interface for an Ivy ssh-based repository (ssh and sftp). Requires the Jsch library..", + "parents": "sbt.librarymanagement.SshBasedRepositoryExtra", "fields": [ { "name": "connection", "type": "sbt.librarymanagement.SshConnection" } ], @@ -534,6 +535,7 @@ "target": "Scala", "type": "record", "doc": "sbt interface for an Ivy repository over ssh. More convenient construction is done using Resolver.ssh.", + "parents": "sbt.librarymanagement.SshRepositoryExtra", "fields": [ { "name": "publishPermissions", "type": "String?" } ], @@ -552,6 +554,7 @@ "target": "Scala", "type": "record", "doc": "sbt interface for an Ivy repository over sftp. More convenient construction is done using Resolver.sftp.", + "parents": "sbt.librarymanagement.SftpRepositoryExtra", "extra": [ "def this(name: String, connection: sbt.librarymanagement.SshConnection, patterns: sbt.librarymanagement.Patterns) = ", " this(name, patterns, connection)" diff --git a/librarymanagement/src/main/scala/sbt/librarymanagement/ResolverExtra.scala b/librarymanagement/src/main/scala/sbt/librarymanagement/ResolverExtra.scala index ce939a1ce..b772e0840 100644 --- a/librarymanagement/src/main/scala/sbt/librarymanagement/ResolverExtra.scala +++ b/librarymanagement/src/main/scala/sbt/librarymanagement/ResolverExtra.scala @@ -41,6 +41,48 @@ abstract class PatternsFunctions { } } +trait SshBasedRepositoryExtra { + /** The object representing the configured ssh connection for this repository. */ + def connection: SshConnection + + type RepositoryType <: SshBasedRepository + protected def copy(connection: SshConnection): RepositoryType + private def copy(authentication: SshAuthentication): RepositoryType = + copy(connection withAuthentication authentication) + + /** Configures this to use the specified user name and password when connecting to the remote repository. */ + def as(user: String, password: String): RepositoryType = as(user, Some(password)) + def as(user: String): RepositoryType = as(user, None) + def as(user: String, password: Option[String]): RepositoryType = copy(PasswordAuthentication(user, password)) + + /** Configures this to use the specified keyfile and password for the keyfile when connecting to the remote repository. */ + def as(user: String, keyfile: File): RepositoryType = as(user, keyfile, None) + def as(user: String, keyfile: File, password: String): RepositoryType = as(user, keyfile, Some(password)) + + def as(user: String, keyfile: File, password: Option[String]): RepositoryType = + copy(KeyFileAuthentication(user, keyfile, password)) +} + +trait SshRepositoryExtra extends SshBasedRepositoryExtra { + def name: String + def patterns: sbt.librarymanagement.Patterns + def publishPermissions: Option[String] + + type RepositoryType = SshRepository + + protected def copy(connection: SshConnection): SshRepository = + SshRepository(name, connection, patterns, publishPermissions) +} + +trait SftpRepositoryExtra extends SshBasedRepositoryExtra { + def name: String + def patterns: sbt.librarymanagement.Patterns + + type RepositoryType = SftpRepository + + protected def copy(connection: SshConnection): SftpRepository = SftpRepository(name, connection, patterns) +} + /** A repository that conforms to sbt launcher's interface */ private[sbt] class FakeRepository(resolver: DependencyResolver) extends xsbti.Repository { def rawRepository = new RawRepository(resolver)