Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# initial format for 3.10.7
bee6f0547cf036a8007becefd500328e38b5d5e7
13 changes: 13 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,19 @@ on:
pull_request:

jobs:
formatting:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
submodules: false
- uses: coursier/setup-action@v2.0
with:
jvm: 8
apps: sbt
- run: sbt scalafmtCheckAll

test:
name: ${{ matrix.os }} ${{ matrix.PLUGIN }} group ${{ matrix.TEST_GROUP }}
runs-on: ${{ matrix.os }}
Expand Down
25 changes: 25 additions & 0 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
version = 3.10.7
align {
preset = none
}
docstrings {
style = Asterisk
blankFirstLine = keep
wrap = keep
}
indent {
defnSite = 2
infix.exemptScope = []
}
maxColumn = 120
newlines {
source = keep
avoidForSimpleOverflow = all
inInterpolation = avoid
}
rewrite {
trailingCommas.style = keep
}
runner {
dialect = scala213
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@ import dataclass.{data, since}
import coursier.cache.CacheDefaults
import coursier.params.rule.{Rule, RuleResolution}
import lmcoursier.credentials.Credentials
import lmcoursier.definitions.{Authentication, CacheLogger, CachePolicy, FromCoursier, Module, ModuleMatchers, Project, Reconciliation, Strict}
import sbt.librarymanagement.{CrossVersion, InclExclRule, ModuleDescriptorConfiguration, ModuleID, ModuleInfo, Resolver, UpdateConfiguration}
import lmcoursier.definitions.{
Authentication, CacheLogger, CachePolicy, FromCoursier, Module, ModuleMatchers, Project, Reconciliation, Strict
}
import sbt.librarymanagement.{
CrossVersion, InclExclRule, ModuleDescriptorConfiguration, ModuleID, ModuleInfo, Resolver, UpdateConfiguration
}
import xsbti.Logger

import scala.concurrent.duration.{Duration, FiniteDuration}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import dataclass._
optional: Boolean = false,
realmOpt: Option[String] = None,
@since("1.0")
headers: Seq[(String,String)] = Nil,
headers: Seq[(String, String)] = Nil,
@since("1.1")
httpsOnly: Boolean = true,
@since("1.2")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ import coursier.cache.{CacheDefaults, CachePolicy}
import coursier.util.Artifact
import coursier.internal.Typelevel
import lmcoursier.definitions.ToCoursier
import lmcoursier.internal.{ArtifactsParams, ArtifactsRun, CoursierModuleDescriptor, InterProjectRepository, ResolutionParams, ResolutionRun, Resolvers, SbtBootJars, UpdateParams, UpdateRun}
import lmcoursier.internal.{
ArtifactsParams, ArtifactsRun, CoursierModuleDescriptor, InterProjectRepository, ResolutionParams, ResolutionRun,
Resolvers, SbtBootJars, UpdateParams, UpdateRun
}
import lmcoursier.syntax._
import sbt.internal.librarymanagement.IvySbt
import sbt.librarymanagement._
Expand Down Expand Up @@ -71,7 +74,7 @@ class CoursierDependencyResolution(
ModuleID("lmcoursier", "lmcoursier", "0.1.0"),
ModuleInfo("protocol-handler")
)
.withDependencies(conf0.protocolHandlerDependencies.toVector)
.withDependencies(conf0.protocolHandlerDependencies.toVector)

val reportOrUnresolved = resolution.update(moduleDescriptor(fakeModule), configuration, uwconfig, log)

Expand Down Expand Up @@ -345,14 +348,14 @@ class CoursierDependencyResolution(
}

if (otherErrors.isEmpty) {
val r = new ResolveException(
downloadErrors.map(_.getMessage),
downloadErrors.map { err =>
ModuleID(err.module.organization.value, err.module.name.value, err.version)
.withExtraAttributes(err.module.attributes)
}
)
UnresolvedWarning(r, uwconfig)
val r = new ResolveException(
downloadErrors.map(_.getMessage),
downloadErrors.map { err =>
ModuleID(err.module.organization.value, err.module.name.value, err.version)
.withExtraAttributes(err.module.attributes)
}
)
UnresolvedWarning(r, uwconfig)
} else
throw ex
}
Expand All @@ -362,8 +365,10 @@ object CoursierDependencyResolution {
def apply(configuration: CoursierConfiguration): DependencyResolution =
DependencyResolution(new CoursierDependencyResolution(configuration))

def apply(configuration: CoursierConfiguration,
protocolHandlerConfiguration: Option[CoursierConfiguration]): DependencyResolution =
def apply(
configuration: CoursierConfiguration,
protocolHandlerConfiguration: Option[CoursierConfiguration]
): DependencyResolution =
DependencyResolution(
new CoursierDependencyResolution(
configuration,
Expand Down
7 changes: 5 additions & 2 deletions modules/lm-coursier/src/main/scala/lmcoursier/FromSbt.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package lmcoursier

import coursier.ivy.IvyXml.{mappings => ivyXmlMappings}
import lmcoursier.definitions.{Classifier, Configuration, Dependency, Extension, Info, Module, ModuleName, Organization, Project, Publication, Type}
import lmcoursier.definitions.{
Classifier, Configuration, Dependency, Extension, Info, Module, ModuleName, Organization, Project, Publication, Type
}
import sbt.internal.librarymanagement.mavenint.SbtPomExtraProperties
import sbt.librarymanagement.{Configuration => _, MavenRepository => _, _}

Expand Down Expand Up @@ -43,7 +45,8 @@ object FromSbt {

val fullName = sbtModuleIdName(module, scalaVersion, scalaBinaryVersion, optionalCrossVer)

val module0 = Module(Organization(module.organization), ModuleName(fullName), attributes(module.extraDependencyAttributes))
val module0 =
Module(Organization(module.organization), ModuleName(fullName), attributes(module.extraDependencyAttributes))
val version = module.revision

(module0, version)
Expand Down
11 changes: 8 additions & 3 deletions modules/lm-coursier/src/main/scala/lmcoursier/Inputs.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ object Inputs {
Configuration(from.value) -> Configuration(to.value)
}

def configExtendsSeq(configurations: Seq[sbt.librarymanagement.Configuration]): Seq[(Configuration, Seq[Configuration])] =
def configExtendsSeq(configurations: Seq[sbt.librarymanagement.Configuration])
: Seq[(Configuration, Seq[Configuration])] =
configurations
.map(cfg => Configuration(cfg.name) -> cfg.extendsConfigs.map(c => Configuration(c.name)))

Expand All @@ -26,10 +27,14 @@ object Inputs {
.toMap

@deprecated("Use coursierConfigurationsMap instead", "2.0.0-RC6-5")
def coursierConfigurations(configurations: Seq[sbt.librarymanagement.Configuration], shadedConfigOpt: Option[String] = None): Map[Configuration, Set[Configuration]] =
def coursierConfigurations(
configurations: Seq[sbt.librarymanagement.Configuration],
shadedConfigOpt: Option[String] = None
): Map[Configuration, Set[Configuration]] =
coursierConfigurationsMap(configurations)

def coursierConfigurationsMap(configurations: Seq[sbt.librarymanagement.Configuration]): Map[Configuration, Set[Configuration]] = {
def coursierConfigurationsMap(configurations: Seq[sbt.librarymanagement.Configuration])
: Map[Configuration, Set[Configuration]] = {

val configs0 = configExtendsSeq(configurations).toMap

Expand Down
8 changes: 6 additions & 2 deletions modules/lm-coursier/src/main/scala/lmcoursier/IvyXml.scala
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ object IvyXml {

val publicationElems = publications.map {
case (pub, configs) =>
val n = <artifact name={pub.name} type={pub.`type`.value} ext={pub.ext.value} conf={configs.map(_.value).mkString(",")} />
val n = <artifact name={pub.name} type={pub.`type`.value} ext={pub.ext.value} conf={
configs.map(_.value).mkString(",")
} />

if (pub.classifier.value.nonEmpty)
n % <x e:classifier={pub.classifier.value} />.attributes
Expand All @@ -95,7 +97,9 @@ object IvyXml {
<exclude org={org.value} module={name.value} name="*" type="*" ext="*" conf="" matcher="exact"/>
}

val n = <dependency org={dep.module.organization.value} name={dep.module.name.value} rev={dep.version} conf={s"${conf.value}->${dep.configuration.value}"}>
val n = <dependency org={dep.module.organization.value} name={dep.module.name.value} rev={dep.version} conf={
s"${conf.value}->${dep.configuration.value}"
}>
{excludes}
</dependency>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@ object Credentials {
DirectCredentials(host, username, password, realm)
def apply(host: String, username: String, password: String, realm: String): DirectCredentials =
DirectCredentials(host, username, password, Option(realm))
def apply(host: String, username: String, password: String, realm: Option[String], optional: Boolean): DirectCredentials =
def apply(
host: String,
username: String,
password: String,
realm: Option[String],
optional: Boolean
): DirectCredentials =
DirectCredentials(host, username, password, realm, optional, matchHost = false, httpsOnly = true)
def apply(host: String, username: String, password: String, realm: String, optional: Boolean): DirectCredentials =
DirectCredentials(host, username, password, Option(realm), optional, matchHost = false, httpsOnly = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,4 @@ object CachePolicy {
* Erases files already in cache.
*/
case object ForceDownload extends CachePolicy
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ object FromCoursier {
case coursier.cache.CachePolicy.FetchMissing => CachePolicy.FetchMissing
case coursier.cache.CachePolicy.ForceDownload => CachePolicy.ForceDownload
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ object ToCoursier {
case Reconciliation.SemVer => coursier.core.Reconciliation.SemVer
}

def reconciliation(rs: Vector[(ModuleMatchers, Reconciliation)]):
Vector[(coursier.util.ModuleMatchers, coursier.core.Reconciliation)] =
def reconciliation(rs: Vector[(ModuleMatchers, Reconciliation)])
: Vector[(coursier.util.ModuleMatchers, coursier.core.Reconciliation)] =
rs map { case (m, r) => (moduleMatchers(m), reconciliation(r)) }

def sameVersions(sv: Seq[Set[InclExclRule]]):
Seq[(coursier.params.rule.SameVersion, coursier.params.rule.RuleResolution)] =
def sameVersions(sv: Seq[Set[InclExclRule]])
: Seq[(coursier.params.rule.SameVersion, coursier.params.rule.RuleResolution)] =
sv.map { libs =>
val matchers = libs.map(rule => coursier.util.ModuleMatcher(module(rule.organization, rule.name)))
coursier.params.rule.SameVersion(matchers) -> coursier.params.rule.RuleResolution.TryResolve
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ object ArtifactsRun {
)
}

Lock.maybeSynchronized(needsLock = params.loggerOpt.nonEmpty || !RefreshLogger.defaultFallbackMode){
Lock.maybeSynchronized(needsLock = params.loggerOpt.nonEmpty || !RefreshLogger.defaultFallbackMode) {
result(params, coursierLogger)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ final case class InterProjectRepository(projects: Seq[Project]) extends Reposito
overrideClassifiers: Option[Seq[Classifier]]
) =
Nil
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,7 @@ object ResolutionRun {
if (attempt + 1 >= maxAttempts) {
log.error(s"Failed, maximum iterations ($maxAttempts) reached")
Task.point(Left(e))
}
else {
} else {
log.warn(s"Attempt ${attempt + 1} failed: $e")
Task.completeAfter(retryScheduler, waitOnError).flatMap { _ =>
retry(attempt + 1, waitOnError * 2)
Expand All @@ -151,8 +150,7 @@ object ResolutionRun {
if (attempt + 1 >= maxAttempts) {
log.error(s"Failed, maximum iterations ($maxAttempts) reached")
Task.fail(e)
}
else
} else
Task.completeAfter(retryScheduler, waitOnError).flatMap { _ =>
retry(attempt + 1, waitOnError * 2)
}
Expand Down Expand Up @@ -218,7 +216,7 @@ object ResolutionRun {
private[internal] def isTransientResolutionError(e: ResolutionError): Boolean =
e.errors.exists {
case err: CantDownloadModule => isTimeout(err) || isServerError(err)
case _ => false
case _ => false
}

private def isTimeout(err: CantDownloadModule): Boolean =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ object Resolvers {

private def mavenCompatibleBaseOpt(patterns: Patterns): Option[String] =
if (patterns.isMavenCompatible) {
//input : /Users/user/custom/repo/[organisation]/[module](_[scalaVersion])(_[sbtVersion])/[revision]/[artifact]-[revision](-[classifier]).[ext]
//output : /Users/user/custom/repo/
// input : /Users/user/custom/repo/[organisation]/[module](_[scalaVersion])(_[sbtVersion])/[revision]/[artifact]-[revision](-[classifier]).[ext]
// output : /Users/user/custom/repo/
def basePattern(pattern: String): String = pattern.takeWhile(c => c != '[' && c != '(')

val baseIvyPattern = basePattern(patterns.ivyPatterns.head)
Expand Down Expand Up @@ -50,9 +50,9 @@ object Resolvers {
case e: MalformedURLException =>
log.warn(
"Error parsing Maven repository base " +
root +
Option(e.getMessage).fold("")(" (" + _ + ")") +
", ignoring it"
root +
Option(e.getMessage).fold("")(" (" + _ + ")") +
", ignoring it"
)

None
Expand Down Expand Up @@ -82,8 +82,8 @@ object Resolvers {
mavenRepositoryOpt(r.root, log, authentication, classLoaders)

case r: FileRepository
if r.patterns.ivyPatterns.lengthCompare(1) == 0 &&
r.patterns.artifactPatterns.lengthCompare(1) == 0 =>
if r.patterns.ivyPatterns.lengthCompare(1) == 0 &&
r.patterns.artifactPatterns.lengthCompare(1) == 0 =>

val mavenCompatibleBaseOpt0 = mavenCompatibleBaseOpt(r.patterns)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ object SbtBootJars {
(mod, scalaVersion) -> jar
}
.toMap
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ class SbtCoursierCache {
// are cached
private val reportsCache = new ConcurrentHashMap[ReportKey, UpdateReport]


def resolutionOpt(key: ResolutionKey): Option[Map[Configuration, Resolution]] =
Option(resolutionsCache.get(key))
def putResolution(key: ResolutionKey, res: Map[Configuration, Resolution]): Unit =
Expand Down Expand Up @@ -59,7 +58,6 @@ object SbtCoursierCache {
includeSignatures: Boolean
)


// private[coursier]
val default = new SbtCoursierCache

Expand Down
Loading
Loading