Skip to content

Commit

Permalink
Merge pull request #9 from TangramFlex/update/scalafmt-core-2.5.3
Browse files Browse the repository at this point in the history
Update scalafmt-core to 2.5.3
  • Loading branch information
listba authored Jan 19, 2023
2 parents 4b2e1f6 + 52db413 commit 4d42eef
Show file tree
Hide file tree
Showing 5 changed files with 204 additions and 119 deletions.
2 changes: 2 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Scala Steward: Reformat with scalafmt 2.5.3
30bed714ec3cf492505003855b036ea69fb4add5
2 changes: 1 addition & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = 2.5.1
version = 2.5.3
align.preset = more
maxColumn = 80
docstrings = "ScalaDoc"
46 changes: 28 additions & 18 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,24 +1,34 @@


inThisBuild(List(
organization := "io.github.tangramflex",
homepage := Some(url("https://github.com/TangramFlex/sbt-gitlab")),
versionScheme := Some("early-semver"),
licenses := List("Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0")),
description := "publishing and dependency resolution for gitlab both private and hosted using header auth",
developers :=
Developer("gilandose", "Richard Gilmore", "richard.gilmore gmail com", url("http://gilcloud.com/"))
:: Developer("listba", "Ben List", "benjamin.list tangramflex com", url("https://github.com/listba/"))
:: Nil,
sonatypeCredentialHost := "s01.oss.sonatype.org",
sonatypeRepository := "https://s01.oss.sonatype.org/service/local",
))

inThisBuild(
List(
organization := "io.github.tangramflex",
homepage := Some(url("https://github.com/TangramFlex/sbt-gitlab")),
versionScheme := Some("early-semver"),
licenses := List(
"Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0")
),
description := "publishing and dependency resolution for gitlab both private and hosted using header auth",
developers :=
Developer(
"gilandose",
"Richard Gilmore",
"richard.gilmore gmail com",
url("http://gilcloud.com/")
)
:: Developer(
"listba",
"Ben List",
"benjamin.list tangramflex com",
url("https://github.com/listba/")
)
:: Nil,
sonatypeCredentialHost := "s01.oss.sonatype.org",
sonatypeRepository := "https://s01.oss.sonatype.org/service/local"
)
)

lazy val root = (project in file("."))
.enablePlugins(SbtPlugin)
.settings(
name := "sbt-gitlab",
console / initialCommands := "import io.github.tangramflex.sbt.gitlab._",
console / initialCommands := "import io.github.tangramflex.sbt.gitlab._"
)

26 changes: 16 additions & 10 deletions src/main/scala/io/github/tangramflex/sbt/gitlab/GitlabPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,20 @@ package io.github.tangramflex.sbt.gitlab
import lmcoursier.definitions.Authentication
import lmcoursier.CoursierConfiguration
import org.apache.ivy.util.url.{URLHandler, URLHandlerDispatcher, URLHandlerRegistry}

import sbt.Keys.*
import sbt.*

import scala.util.Try

object GitlabPlugin extends AutoPlugin {


lazy val headerAuthHandler =
taskKey[Unit]("perform auth using header credentials")

// Not sure we have any reason to expose this
private val gitlabResolvers = settingKey[Seq[MavenRepository]]("List of gitlab Maven repositories")
private val gitlabResolvers =
settingKey[Seq[MavenRepository]]("List of gitlab Maven repositories")
// This plugin will load automatically
override def trigger: PluginTrigger = allRequirements

Expand All @@ -32,10 +33,13 @@ object GitlabPlugin extends AutoPlugin {
}
import autoImport._

def gitlabUrlHandlerDispatcher(gitlabDomain: String, creds: GitlabCredentials): URLHandlerDispatcher =
def gitlabUrlHandlerDispatcher(
gitlabDomain: String,
creds: GitlabCredentials
): URLHandlerDispatcher =
new URLHandlerDispatcher {
Seq("http", "https") foreach {
super.setDownloader(_, GitlabUrlHandler(gitlabDomain,creds))
super.setDownloader(_, GitlabUrlHandler(gitlabDomain, creds))
}
override def setDownloader(
protocol: String,
Expand All @@ -52,7 +56,7 @@ object GitlabPlugin extends AutoPlugin {
Credentials
.allDirect(credentials.value.filter {
case f: FileCredentials => f.path.exists()
case _ => true
case _ => true
})
.find(_.realm == "gitlab")
.map(GitlabCredentials.apply)
Expand All @@ -76,7 +80,7 @@ object GitlabPlugin extends AutoPlugin {
}
}

val gitLabProjectSettings : Seq[Def.Setting[_]] =
val gitLabProjectSettings: Seq[Def.Setting[_]] =
Seq(
publishMavenStyle := true,
gitlabDomain := sys.env.getOrElse("CI_SERVER_HOST", "gitlab.com"),
Expand All @@ -92,7 +96,7 @@ object GitlabPlugin extends AutoPlugin {
.map(GitlabCredentials("Job-Token", _))
},
headerAuthHandler := {
gitlabCredentialsHandler.value.map{ creds =>
gitlabCredentialsHandler.value.map { creds =>
val dispatcher = gitlabUrlHandlerDispatcher(gitlabDomain.value, creds)
URLHandlerRegistry.setDefault(dispatcher)
}
Expand All @@ -104,8 +108,8 @@ object GitlabPlugin extends AutoPlugin {
.value,
// Add in resolvers for project and group id's for domain
gitlabResolvers := Seq(
gitlabProjectId.value.map(pid => projectRepo(gitlabDomain.value,pid)),
gitlabGroupId.value.map(gid => groupRepo(gitlabDomain.value,gid))
gitlabProjectId.value.map(pid => projectRepo(gitlabDomain.value, pid)),
gitlabGroupId.value.map(gid => groupRepo(gitlabDomain.value, gid))
).flatten,
resolvers ++= gitlabResolvers.value,
// Adds Coursier repository Authentication for each gitlabResolver
Expand All @@ -115,6 +119,8 @@ object GitlabPlugin extends AutoPlugin {
publish := publish.dependsOn(headerAuthHandler).value,
// If no publish location is specified then publish to the project id (if set)
// Note: The project ID should always be set automatically with a gitlab ci pipeline via the CI_PROJECT_ID
publishTo := (ThisProject / publishTo).value.orElse ( gitlabProjectId.value.map(pid => projectRepo(gitlabDomain.value,pid)) )
publishTo := (ThisProject / publishTo).value.orElse(
gitlabProjectId.value.map(pid => projectRepo(gitlabDomain.value, pid))
)
)
}
Loading

0 comments on commit 4d42eef

Please sign in to comment.