mirror of https://github.com/sbt/sbt.git
Merge pull request #400 from eed3si9n/wip/scalafix
Use dataclass-scalafix for code gen
This commit is contained in:
commit
9aa5887d6d
|
|
@ -4,6 +4,7 @@ target/
|
||||||
# Metals / bloop
|
# Metals / bloop
|
||||||
.metals/
|
.metals/
|
||||||
.bloop/
|
.bloop/
|
||||||
|
metals.sbt
|
||||||
|
|
||||||
# Intellij
|
# Intellij
|
||||||
.idea/
|
.idea/
|
||||||
|
|
|
||||||
104
build.sbt
104
build.sbt
|
|
@ -1,6 +1,8 @@
|
||||||
|
|
||||||
import Settings._
|
import Settings._
|
||||||
|
|
||||||
|
def dataclassScalafixV = "0.1.0-M3"
|
||||||
|
|
||||||
inThisBuild(List(
|
inThisBuild(List(
|
||||||
organization := "io.get-coursier",
|
organization := "io.get-coursier",
|
||||||
homepage := Some(url("https://github.com/coursier/sbt-coursier")),
|
homepage := Some(url("https://github.com/coursier/sbt-coursier")),
|
||||||
|
|
@ -12,12 +14,57 @@ inThisBuild(List(
|
||||||
"",
|
"",
|
||||||
url("https://github.com/alexarchambault")
|
url("https://github.com/alexarchambault")
|
||||||
)
|
)
|
||||||
)
|
),
|
||||||
|
semanticdbEnabled := true,
|
||||||
|
semanticdbVersion := "4.5.9",
|
||||||
|
scalafixDependencies += "net.hamnaberg" %% "dataclass-scalafix" % dataclassScalafixV
|
||||||
))
|
))
|
||||||
|
|
||||||
|
Global / excludeLintKeys += scriptedBufferLog
|
||||||
|
Global / excludeLintKeys += scriptedLaunchOpts
|
||||||
|
|
||||||
val coursierVersion0 = "2.1.0-M6-49-gff26f8e39"
|
val coursierVersion0 = "2.1.0-M6-49-gff26f8e39"
|
||||||
val lmVersion = "1.3.4"
|
|
||||||
val lm2_13Version = "1.5.0-M3"
|
def dataclassGen(data: Reference) = Def.taskDyn {
|
||||||
|
val root = (ThisBuild / baseDirectory).value.toURI.toString
|
||||||
|
val from = (data / Compile / sourceDirectory).value
|
||||||
|
val to = (Compile / sourceManaged).value
|
||||||
|
val outFrom = from.toURI.toString.stripSuffix("/").stripPrefix(root)
|
||||||
|
val outTo = to.toURI.toString.stripSuffix("/").stripPrefix(root)
|
||||||
|
(data / Compile / compile).value
|
||||||
|
Def.task {
|
||||||
|
(data / Compile / scalafix)
|
||||||
|
.toTask(s" --rules GenerateDataClass --out-from=$outFrom --out-to=$outTo")
|
||||||
|
.value
|
||||||
|
(to ** "*.scala").get
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def lmIvy = Def.setting {
|
||||||
|
"org.scala-sbt" %% "librarymanagement-ivy" % {
|
||||||
|
scalaBinaryVersion.value match {
|
||||||
|
case "2.12" => "1.3.4"
|
||||||
|
case "2.13" => "1.7.0"
|
||||||
|
case _ => "2.0.0-alpha2"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
lazy val preTest = taskKey[Unit]("prep steps before tests")
|
||||||
|
|
||||||
|
lazy val definitions = project
|
||||||
|
.in(file("modules/definitions"))
|
||||||
|
.disablePlugins(MimaPlugin)
|
||||||
|
.settings(
|
||||||
|
shared,
|
||||||
|
crossScalaVersions := Seq(scala212, scala213),
|
||||||
|
libraryDependencies ++= Seq(
|
||||||
|
"io.get-coursier" %% "coursier" % coursierVersion0,
|
||||||
|
"net.hamnaberg" %% "dataclass-annotation" % dataclassScalafixV % Provided,
|
||||||
|
lmIvy.value,
|
||||||
|
),
|
||||||
|
dontPublish,
|
||||||
|
)
|
||||||
|
|
||||||
lazy val `lm-coursier` = project
|
lazy val `lm-coursier` = project
|
||||||
.in(file("modules/lm-coursier"))
|
.in(file("modules/lm-coursier"))
|
||||||
|
|
@ -28,30 +75,25 @@ lazy val `lm-coursier` = project
|
||||||
Mima.lmCoursierFilters,
|
Mima.lmCoursierFilters,
|
||||||
libraryDependencies ++= Seq(
|
libraryDependencies ++= Seq(
|
||||||
"io.get-coursier" %% "coursier" % coursierVersion0,
|
"io.get-coursier" %% "coursier" % coursierVersion0,
|
||||||
"io.github.alexarchambault" %% "data-class" % "0.2.6" % Provided,
|
"net.hamnaberg" %% "dataclass-annotation" % dataclassScalafixV % Provided,
|
||||||
// We depend on librarymanagement-ivy rather than just
|
// We depend on librarymanagement-ivy rather than just
|
||||||
// librarymanagement-core to handle the ModuleDescriptor passed
|
// librarymanagement-core to handle the ModuleDescriptor passed
|
||||||
// to DependencyResolutionInterface.update, which is an
|
// to DependencyResolutionInterface.update, which is an
|
||||||
// IvySbt#Module (seems DependencyResolutionInterface.moduleDescriptor
|
// IvySbt#Module (seems DependencyResolutionInterface.moduleDescriptor
|
||||||
// is ignored).
|
// is ignored).
|
||||||
"org.scala-sbt" %% "librarymanagement-ivy" % {
|
lmIvy.value,
|
||||||
if (scalaBinaryVersion.value == "2.12") lmVersion
|
|
||||||
else lm2_13Version
|
|
||||||
},
|
|
||||||
"org.scalatest" %% "scalatest" % "3.2.13" % Test
|
"org.scalatest" %% "scalatest" % "3.2.13" % Test
|
||||||
),
|
),
|
||||||
Test / test := {
|
Test / exportedProducts := {
|
||||||
(publishLocal in customProtocolForTest212).value
|
(Test / preTest).value
|
||||||
(publishLocal in customProtocolForTest213).value
|
(Test / exportedProducts).value
|
||||||
(publishLocal in customProtocolJavaForTest).value
|
|
||||||
(Test / test).value
|
|
||||||
},
|
},
|
||||||
Test / testOnly := {
|
Test / preTest := {
|
||||||
(publishLocal in customProtocolForTest212).value
|
(customProtocolForTest212 / publishLocal).value
|
||||||
(publishLocal in customProtocolForTest213).value
|
(customProtocolForTest213 / publishLocal).value
|
||||||
(publishLocal in customProtocolJavaForTest).value
|
(customProtocolJavaForTest / publishLocal).value
|
||||||
(Test / testOnly).evaluated
|
},
|
||||||
}
|
Compile / sourceGenerators += dataclassGen(definitions).taskValue,
|
||||||
)
|
)
|
||||||
|
|
||||||
lazy val `lm-coursier-shaded` = project
|
lazy val `lm-coursier-shaded` = project
|
||||||
|
|
@ -63,7 +105,7 @@ lazy val `lm-coursier-shaded` = project
|
||||||
Mima.settings,
|
Mima.settings,
|
||||||
Mima.lmCoursierFilters,
|
Mima.lmCoursierFilters,
|
||||||
Mima.lmCoursierShadedFilters,
|
Mima.lmCoursierShadedFilters,
|
||||||
unmanagedSourceDirectories.in(Compile) := unmanagedSourceDirectories.in(Compile).in(`lm-coursier`).value,
|
Compile / sources := (`lm-coursier` / Compile / sources).value,
|
||||||
shadedModules += "io.get-coursier" %% "coursier",
|
shadedModules += "io.get-coursier" %% "coursier",
|
||||||
validNamespaces += "lmcoursier",
|
validNamespaces += "lmcoursier",
|
||||||
validEntries ++= Set(
|
validEntries ++= Set(
|
||||||
|
|
@ -97,13 +139,10 @@ lazy val `lm-coursier-shaded` = project
|
||||||
},
|
},
|
||||||
libraryDependencies ++= Seq(
|
libraryDependencies ++= Seq(
|
||||||
"io.get-coursier" %% "coursier" % coursierVersion0,
|
"io.get-coursier" %% "coursier" % coursierVersion0,
|
||||||
"io.github.alexarchambault" %% "data-class" % "0.2.6" % Provided,
|
"net.hamnaberg" %% "dataclass-annotation" % dataclassScalafixV % Provided,
|
||||||
"org.scala-lang.modules" %% "scala-collection-compat" % "2.8.1",
|
"org.scala-lang.modules" %% "scala-collection-compat" % "2.8.1",
|
||||||
"org.scala-lang.modules" %% "scala-xml" % "1.3.0", // depending on that one so that it doesn't get shaded
|
"org.scala-lang.modules" %% "scala-xml" % "1.3.0", // depending on that one so that it doesn't get shaded
|
||||||
"org.scala-sbt" %% "librarymanagement-ivy" % {
|
lmIvy.value,
|
||||||
if (scalaBinaryVersion.value == "2.12") lmVersion
|
|
||||||
else lm2_13Version
|
|
||||||
},
|
|
||||||
"org.scalatest" %% "scalatest" % "3.2.13" % Test
|
"org.scalatest" %% "scalatest" % "3.2.13" % Test
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
@ -126,7 +165,7 @@ lazy val `sbt-coursier-shared-shaded` = project
|
||||||
.settings(
|
.settings(
|
||||||
plugin,
|
plugin,
|
||||||
generatePropertyFile,
|
generatePropertyFile,
|
||||||
unmanagedSourceDirectories.in(Compile) := unmanagedSourceDirectories.in(Compile).in(`sbt-coursier-shared`).value
|
Compile / unmanagedSourceDirectories := (`sbt-coursier-shared` / Compile / unmanagedSourceDirectories).value
|
||||||
)
|
)
|
||||||
|
|
||||||
lazy val `sbt-lm-coursier` = project
|
lazy val `sbt-lm-coursier` = project
|
||||||
|
|
@ -136,14 +175,14 @@ lazy val `sbt-lm-coursier` = project
|
||||||
.dependsOn(`sbt-coursier-shared-shaded`)
|
.dependsOn(`sbt-coursier-shared-shaded`)
|
||||||
.settings(
|
.settings(
|
||||||
plugin,
|
plugin,
|
||||||
sbtTestDirectory := sbtTestDirectory.in(`sbt-coursier`).value,
|
sbtTestDirectory := (`sbt-coursier` / sbtTestDirectory).value,
|
||||||
scriptedDependencies := {
|
scriptedDependencies := {
|
||||||
scriptedDependencies.value
|
scriptedDependencies.value
|
||||||
|
|
||||||
// TODO Get those automatically
|
// TODO Get those automatically
|
||||||
// (but shouldn't scripted itself handle that…?)
|
// (but shouldn't scripted itself handle that…?)
|
||||||
publishLocal.in(`lm-coursier-shaded`).value
|
(`lm-coursier-shaded` / publishLocal).value
|
||||||
publishLocal.in(`sbt-coursier-shared-shaded`).value
|
(`sbt-coursier-shared-shaded` / publishLocal).value
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -159,8 +198,8 @@ lazy val `sbt-coursier` = project
|
||||||
|
|
||||||
// TODO Get dependency projects automatically
|
// TODO Get dependency projects automatically
|
||||||
// (but shouldn't scripted itself handle that…?)
|
// (but shouldn't scripted itself handle that…?)
|
||||||
publishLocal.in(`lm-coursier`).value
|
(`lm-coursier` / publishLocal).value
|
||||||
publishLocal.in(`sbt-coursier-shared`).value
|
(`sbt-coursier-shared` / publishLocal).value
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -200,6 +239,7 @@ lazy val `sbt-coursier-root` = project
|
||||||
.in(file("."))
|
.in(file("."))
|
||||||
.disablePlugins(MimaPlugin)
|
.disablePlugins(MimaPlugin)
|
||||||
.aggregate(
|
.aggregate(
|
||||||
|
definitions,
|
||||||
`lm-coursier`,
|
`lm-coursier`,
|
||||||
`lm-coursier-shaded`,
|
`lm-coursier-shaded`,
|
||||||
`sbt-coursier`,
|
`sbt-coursier`,
|
||||||
|
|
@ -209,6 +249,6 @@ lazy val `sbt-coursier-root` = project
|
||||||
)
|
)
|
||||||
.settings(
|
.settings(
|
||||||
shared,
|
shared,
|
||||||
skip.in(publish) := true
|
(publish / skip) := true
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,62 @@
|
||||||
|
package lmcoursier
|
||||||
|
|
||||||
|
import java.io.File
|
||||||
|
|
||||||
|
import dataclass.{ data, since }
|
||||||
|
import coursier.cache.CacheDefaults
|
||||||
|
import lmcoursier.credentials.Credentials
|
||||||
|
import lmcoursier.definitions.{Authentication, CacheLogger, CachePolicy, FromCoursier, Module, ModuleMatchers, Project, Reconciliation, Strict}
|
||||||
|
import sbt.librarymanagement.{Resolver, UpdateConfiguration, ModuleID, CrossVersion, ModuleInfo, ModuleDescriptorConfiguration}
|
||||||
|
import xsbti.Logger
|
||||||
|
|
||||||
|
import scala.concurrent.duration.Duration
|
||||||
|
import java.net.URL
|
||||||
|
import java.net.URLClassLoader
|
||||||
|
|
||||||
|
@data class CoursierConfiguration(
|
||||||
|
log: Option[Logger] = None,
|
||||||
|
resolvers: Vector[Resolver] = Resolver.defaults,
|
||||||
|
parallelDownloads: Int = 6,
|
||||||
|
maxIterations: Int = 100,
|
||||||
|
sbtScalaOrganization: Option[String] = None,
|
||||||
|
sbtScalaVersion: Option[String] = None,
|
||||||
|
sbtScalaJars: Vector[File] = Vector.empty,
|
||||||
|
interProjectDependencies: Vector[Project] = Vector.empty,
|
||||||
|
excludeDependencies: Vector[(String, String)] = Vector.empty,
|
||||||
|
fallbackDependencies: Vector[FallbackDependency] = Vector.empty,
|
||||||
|
autoScalaLibrary: Boolean = true,
|
||||||
|
hasClassifiers: Boolean = false,
|
||||||
|
classifiers: Vector[String] = Vector.empty,
|
||||||
|
mavenProfiles: Vector[String] = Vector.empty,
|
||||||
|
scalaOrganization: Option[String] = None,
|
||||||
|
scalaVersion: Option[String] = None,
|
||||||
|
authenticationByRepositoryId: Vector[(String, Authentication)] = Vector.empty,
|
||||||
|
credentials: Seq[Credentials] = Vector.empty,
|
||||||
|
logger: Option[CacheLogger] = None,
|
||||||
|
cache: Option[File] = None,
|
||||||
|
@since
|
||||||
|
ivyHome: Option[File] = None,
|
||||||
|
@since
|
||||||
|
followHttpToHttpsRedirections: Option[Boolean] = None,
|
||||||
|
@since
|
||||||
|
strict: Option[Strict] = None,
|
||||||
|
extraProjects: Vector[Project] = Vector.empty,
|
||||||
|
forceVersions: Vector[(Module, String)] = Vector.empty,
|
||||||
|
@since
|
||||||
|
reconciliation: Vector[(ModuleMatchers, Reconciliation)] = Vector.empty,
|
||||||
|
@since
|
||||||
|
classpathOrder: Boolean = true,
|
||||||
|
@since
|
||||||
|
verbosityLevel: Int = 0,
|
||||||
|
ttl: Option[Duration] = CacheDefaults.ttl,
|
||||||
|
checksums: Vector[Option[String]] = CacheDefaults.checksums.toVector,
|
||||||
|
cachePolicies: Vector[CachePolicy] = CacheDefaults.cachePolicies.toVector.map(FromCoursier.cachePolicy),
|
||||||
|
@since
|
||||||
|
missingOk: Boolean = false,
|
||||||
|
@since
|
||||||
|
sbtClassifiers: Boolean = false,
|
||||||
|
@since
|
||||||
|
providedInCompile: Boolean = false, // unused, kept for binary compatibility
|
||||||
|
@since
|
||||||
|
protocolHandlerDependencies: Seq[ModuleID] = Vector.empty,
|
||||||
|
)
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
package lmcoursier.credentials
|
||||||
|
|
||||||
|
import java.io.File
|
||||||
|
|
||||||
|
abstract class Credentials extends Serializable
|
||||||
|
|
||||||
|
object Credentials
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
package lmcoursier.credentials
|
||||||
|
|
||||||
|
import dataclass._
|
||||||
|
|
||||||
|
@data class DirectCredentials(
|
||||||
|
host: String = "",
|
||||||
|
username: String = "",
|
||||||
|
password: String = "",
|
||||||
|
@since("1.0")
|
||||||
|
realm: Option[String] = None,
|
||||||
|
@since("1.1")
|
||||||
|
optional: Boolean = true,
|
||||||
|
@since("1.2")
|
||||||
|
matchHost: Boolean = false,
|
||||||
|
@since("1.3")
|
||||||
|
httpsOnly: Boolean = true
|
||||||
|
) extends Credentials {
|
||||||
|
|
||||||
|
override def toString(): String = s"DirectCredentials(host=$host, username=$username)"
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
package lmcoursier.definitions
|
||||||
|
|
||||||
|
import dataclass._
|
||||||
|
|
||||||
|
@data class Authentication(
|
||||||
|
user: String,
|
||||||
|
password: String,
|
||||||
|
optional: Boolean = false,
|
||||||
|
realmOpt: Option[String] = None,
|
||||||
|
@since("1.0")
|
||||||
|
headers: Seq[(String,String)] = Nil,
|
||||||
|
@since("1.1")
|
||||||
|
httpsOnly: Boolean = true,
|
||||||
|
@since("1.2")
|
||||||
|
passOnRedirect: Boolean = false
|
||||||
|
) {
|
||||||
|
override def toString(): String =
|
||||||
|
s"Authentication(user=$user)"
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
../../../../../../lm-coursier/src/main/scala/lmcoursier/definitions/CacheLogger.scala
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
../../../../../../lm-coursier/src/main/scala/lmcoursier/definitions/CachePolicy.scala
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
../../../../../../lm-coursier/src/main/scala/lmcoursier/definitions/Definitions.scala
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
package lmcoursier.definitions
|
||||||
|
|
||||||
|
import dataclass.data
|
||||||
|
|
||||||
|
@data class Dependency(
|
||||||
|
module: Module,
|
||||||
|
version: String,
|
||||||
|
configuration: Configuration,
|
||||||
|
exclusions: Set[(Organization, ModuleName)],
|
||||||
|
publication: Publication,
|
||||||
|
optional: Boolean,
|
||||||
|
transitive: Boolean
|
||||||
|
)
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
../../../../../../lm-coursier/src/main/scala/lmcoursier/definitions/FromCoursier.scala
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
package lmcoursier.definitions
|
||||||
|
|
||||||
|
import dataclass.data
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param exclude Use "*" in either organization or name to match any.
|
||||||
|
* @param include Use "*" in either organization or name to match any.
|
||||||
|
*/
|
||||||
|
@data class ModuleMatchers(
|
||||||
|
exclude: Set[Module],
|
||||||
|
include: Set[Module],
|
||||||
|
includeByDefault: Boolean = true
|
||||||
|
)
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
package lmcoursier.definitions
|
||||||
|
|
||||||
|
import dataclass.data
|
||||||
|
|
||||||
|
@data class Publication(
|
||||||
|
name: String,
|
||||||
|
`type`: Type,
|
||||||
|
ext: Extension,
|
||||||
|
classifier: Classifier
|
||||||
|
)
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
../../../../../../lm-coursier/src/main/scala/lmcoursier/definitions/Reconciliation.scala
|
||||||
|
|
@ -9,9 +9,4 @@ import dataclass._
|
||||||
@since
|
@since
|
||||||
includeByDefault: Boolean = false,
|
includeByDefault: Boolean = false,
|
||||||
semVer: Boolean = false
|
semVer: Boolean = false
|
||||||
) {
|
)
|
||||||
def addInclude(include: (String, String)*): Strict =
|
|
||||||
withInclude(this.include ++ include)
|
|
||||||
def addExclude(exclude: (String, String)*): Strict =
|
|
||||||
withExclude(this.exclude ++ exclude)
|
|
||||||
}
|
|
||||||
|
|
@ -1,144 +0,0 @@
|
||||||
package lmcoursier
|
|
||||||
|
|
||||||
import java.io.File
|
|
||||||
|
|
||||||
import dataclass.data
|
|
||||||
import coursier.cache.CacheDefaults
|
|
||||||
import lmcoursier.credentials.Credentials
|
|
||||||
import lmcoursier.definitions.{Authentication, CacheLogger, CachePolicy, FromCoursier, Module, ModuleMatchers, Project, Reconciliation, Strict}
|
|
||||||
import sbt.librarymanagement.{Resolver, UpdateConfiguration, ModuleID, CrossVersion, ModuleInfo, ModuleDescriptorConfiguration}
|
|
||||||
import xsbti.Logger
|
|
||||||
|
|
||||||
import scala.concurrent.duration.Duration
|
|
||||||
import java.net.URL
|
|
||||||
import java.net.URLClassLoader
|
|
||||||
|
|
||||||
@data class CoursierConfiguration(
|
|
||||||
log: Option[Logger] = None,
|
|
||||||
resolvers: Vector[Resolver] = Resolver.defaults,
|
|
||||||
parallelDownloads: Int = 6,
|
|
||||||
maxIterations: Int = 100,
|
|
||||||
sbtScalaOrganization: Option[String] = None,
|
|
||||||
sbtScalaVersion: Option[String] = None,
|
|
||||||
sbtScalaJars: Vector[File] = Vector.empty,
|
|
||||||
interProjectDependencies: Vector[Project] = Vector.empty,
|
|
||||||
excludeDependencies: Vector[(String, String)] = Vector.empty,
|
|
||||||
fallbackDependencies: Vector[FallbackDependency] = Vector.empty,
|
|
||||||
autoScalaLibrary: Boolean = true,
|
|
||||||
hasClassifiers: Boolean = false,
|
|
||||||
classifiers: Vector[String] = Vector.empty,
|
|
||||||
mavenProfiles: Vector[String] = Vector.empty,
|
|
||||||
scalaOrganization: Option[String] = None,
|
|
||||||
scalaVersion: Option[String] = None,
|
|
||||||
authenticationByRepositoryId: Vector[(String, Authentication)] = Vector.empty,
|
|
||||||
credentials: Seq[Credentials] = Vector.empty,
|
|
||||||
logger: Option[CacheLogger] = None,
|
|
||||||
cache: Option[File] = None,
|
|
||||||
@since
|
|
||||||
ivyHome: Option[File] = None,
|
|
||||||
@since
|
|
||||||
followHttpToHttpsRedirections: Option[Boolean] = None,
|
|
||||||
@since
|
|
||||||
strict: Option[Strict] = None,
|
|
||||||
extraProjects: Vector[Project] = Vector.empty,
|
|
||||||
forceVersions: Vector[(Module, String)] = Vector.empty,
|
|
||||||
@since
|
|
||||||
reconciliation: Vector[(ModuleMatchers, Reconciliation)] = Vector.empty,
|
|
||||||
@since
|
|
||||||
classpathOrder: Boolean = true,
|
|
||||||
@since
|
|
||||||
verbosityLevel: Int = 0,
|
|
||||||
ttl: Option[Duration] = CacheDefaults.ttl,
|
|
||||||
checksums: Vector[Option[String]] = CacheDefaults.checksums.toVector,
|
|
||||||
cachePolicies: Vector[CachePolicy] = CacheDefaults.cachePolicies.toVector.map(FromCoursier.cachePolicy),
|
|
||||||
@since
|
|
||||||
missingOk: Boolean = false,
|
|
||||||
@since
|
|
||||||
sbtClassifiers: Boolean = false,
|
|
||||||
@since
|
|
||||||
providedInCompile: Boolean = false, // unused, kept for binary compatibility
|
|
||||||
@since
|
|
||||||
protocolHandlerDependencies: Seq[ModuleID] = Vector.empty,
|
|
||||||
) {
|
|
||||||
|
|
||||||
def withLog(log: Logger): CoursierConfiguration =
|
|
||||||
withLog(Option(log))
|
|
||||||
def withSbtScalaOrganization(sbtScalaOrganization: String): CoursierConfiguration =
|
|
||||||
withSbtScalaOrganization(Option(sbtScalaOrganization))
|
|
||||||
def withSbtScalaVersion(sbtScalaVersion: String): CoursierConfiguration =
|
|
||||||
withSbtScalaVersion(Option(sbtScalaVersion))
|
|
||||||
def withScalaOrganization(scalaOrganization: String): CoursierConfiguration =
|
|
||||||
withScalaOrganization(Option(scalaOrganization))
|
|
||||||
def withScalaVersion(scalaVersion: String): CoursierConfiguration =
|
|
||||||
withScalaVersion(Option(scalaVersion))
|
|
||||||
def withLogger(logger: CacheLogger): CoursierConfiguration =
|
|
||||||
withLogger(Option(logger))
|
|
||||||
def withCache(cache: File): CoursierConfiguration =
|
|
||||||
withCache(Option(cache))
|
|
||||||
def withIvyHome(ivyHome: File): CoursierConfiguration =
|
|
||||||
withIvyHome(Option(ivyHome))
|
|
||||||
def withFollowHttpToHttpsRedirections(followHttpToHttpsRedirections: Boolean): CoursierConfiguration =
|
|
||||||
withFollowHttpToHttpsRedirections(Some(followHttpToHttpsRedirections))
|
|
||||||
def withFollowHttpToHttpsRedirections(): CoursierConfiguration =
|
|
||||||
withFollowHttpToHttpsRedirections(Some(true))
|
|
||||||
def withStrict(strict: Strict): CoursierConfiguration =
|
|
||||||
withStrict(Some(strict))
|
|
||||||
def withTtl(ttl: Duration): CoursierConfiguration =
|
|
||||||
withTtl(Some(ttl))
|
|
||||||
def addRepositoryAuthentication(repositoryId: String, authentication: Authentication): CoursierConfiguration =
|
|
||||||
withAuthenticationByRepositoryId(authenticationByRepositoryId :+ (repositoryId, authentication))
|
|
||||||
|
|
||||||
def withUpdateConfiguration(conf: UpdateConfiguration): CoursierConfiguration =
|
|
||||||
withMissingOk(conf.missingOk)
|
|
||||||
}
|
|
||||||
|
|
||||||
object CoursierConfiguration {
|
|
||||||
|
|
||||||
@deprecated("Legacy cache location support was dropped, this method does nothing.", "2.0.0-RC6-10")
|
|
||||||
def checkLegacyCache(): Unit = ()
|
|
||||||
|
|
||||||
def apply(
|
|
||||||
log: Logger,
|
|
||||||
resolvers: Vector[Resolver],
|
|
||||||
parallelDownloads: Int,
|
|
||||||
maxIterations: Int,
|
|
||||||
sbtScalaOrganization: String,
|
|
||||||
sbtScalaVersion: String,
|
|
||||||
sbtScalaJars: Vector[File],
|
|
||||||
interProjectDependencies: Vector[Project],
|
|
||||||
excludeDependencies: Vector[(String, String)],
|
|
||||||
fallbackDependencies: Vector[FallbackDependency],
|
|
||||||
autoScalaLibrary: Boolean,
|
|
||||||
hasClassifiers: Boolean,
|
|
||||||
classifiers: Vector[String],
|
|
||||||
mavenProfiles: Vector[String],
|
|
||||||
scalaOrganization: String,
|
|
||||||
scalaVersion: String,
|
|
||||||
authenticationByRepositoryId: Vector[(String, Authentication)],
|
|
||||||
credentials: Seq[Credentials],
|
|
||||||
logger: CacheLogger,
|
|
||||||
cache: File
|
|
||||||
): CoursierConfiguration =
|
|
||||||
CoursierConfiguration(
|
|
||||||
Option(log),
|
|
||||||
resolvers,
|
|
||||||
parallelDownloads,
|
|
||||||
maxIterations,
|
|
||||||
Option(sbtScalaOrganization),
|
|
||||||
Option(sbtScalaVersion),
|
|
||||||
sbtScalaJars,
|
|
||||||
interProjectDependencies,
|
|
||||||
excludeDependencies,
|
|
||||||
fallbackDependencies,
|
|
||||||
autoScalaLibrary,
|
|
||||||
hasClassifiers,
|
|
||||||
classifiers,
|
|
||||||
mavenProfiles,
|
|
||||||
Option(scalaOrganization),
|
|
||||||
Option(scalaVersion),
|
|
||||||
authenticationByRepositoryId,
|
|
||||||
credentials,
|
|
||||||
Option(logger),
|
|
||||||
Option(cache)
|
|
||||||
) /* no need to touch this 'apply'; @data above is doing the hard work */
|
|
||||||
}
|
|
||||||
|
|
@ -10,6 +10,7 @@ import coursier.util.Artifact
|
||||||
import coursier.internal.Typelevel
|
import coursier.internal.Typelevel
|
||||||
import lmcoursier.definitions.ToCoursier
|
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.internal.librarymanagement.IvySbt
|
||||||
import sbt.librarymanagement._
|
import sbt.librarymanagement._
|
||||||
import sbt.util.Logger
|
import sbt.util.Logger
|
||||||
|
|
|
||||||
|
|
@ -5,13 +5,17 @@ import java.io.File
|
||||||
abstract class Credentials extends Serializable
|
abstract class Credentials extends Serializable
|
||||||
|
|
||||||
object Credentials {
|
object Credentials {
|
||||||
|
|
||||||
def apply(): DirectCredentials = DirectCredentials()
|
def apply(): DirectCredentials = DirectCredentials()
|
||||||
def apply(host: String, username: String, password: String): DirectCredentials = DirectCredentials(host, username, password)
|
def apply(host: String, username: String, password: String): DirectCredentials =
|
||||||
def apply(host: String, username: String, password: String, realm: Option[String]): DirectCredentials = DirectCredentials(host, username, password, realm)
|
DirectCredentials(host, username, password)
|
||||||
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]): DirectCredentials =
|
||||||
def apply(host: String, username: String, password: String, realm: Option[String], optional: Boolean): DirectCredentials = DirectCredentials(host, username, password, realm, optional)
|
DirectCredentials(host, username, password, realm)
|
||||||
def apply(host: String, username: String, password: String, realm: String, optional: Boolean): DirectCredentials = DirectCredentials(host, username, password, Option(realm), optional)
|
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 =
|
||||||
|
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)
|
||||||
|
|
||||||
def apply(f: File): FileCredentials =
|
def apply(f: File): FileCredentials =
|
||||||
FileCredentials(f.getAbsolutePath)
|
FileCredentials(f.getAbsolutePath)
|
||||||
|
|
|
||||||
|
|
@ -1,30 +0,0 @@
|
||||||
package lmcoursier.credentials
|
|
||||||
|
|
||||||
import dataclass._
|
|
||||||
|
|
||||||
@data class DirectCredentials(
|
|
||||||
host: String = "",
|
|
||||||
username: String = "",
|
|
||||||
password: String = "",
|
|
||||||
@since
|
|
||||||
realm: Option[String] = None,
|
|
||||||
@since
|
|
||||||
optional: Boolean = true,
|
|
||||||
@since
|
|
||||||
matchHost: Boolean = false,
|
|
||||||
httpsOnly: Boolean = true
|
|
||||||
) extends Credentials {
|
|
||||||
|
|
||||||
def withRealm(realm: String): DirectCredentials =
|
|
||||||
withRealm(Option(realm))
|
|
||||||
|
|
||||||
override def toString(): String =
|
|
||||||
withPassword("****")
|
|
||||||
.productIterator
|
|
||||||
.mkString("DirectCredentials(", ", ", ")")
|
|
||||||
}
|
|
||||||
|
|
||||||
object DirectCredentials {
|
|
||||||
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: String, optional: Boolean): DirectCredentials = DirectCredentials(host, username, password, Option(realm), optional)
|
|
||||||
}
|
|
||||||
|
|
@ -1,30 +0,0 @@
|
||||||
package lmcoursier.definitions
|
|
||||||
|
|
||||||
import dataclass._
|
|
||||||
|
|
||||||
@data class Authentication(
|
|
||||||
user: String,
|
|
||||||
password: String,
|
|
||||||
optional: Boolean = false,
|
|
||||||
realmOpt: Option[String] = None,
|
|
||||||
@since
|
|
||||||
headers: Seq[(String,String)] = Nil,
|
|
||||||
httpsOnly: Boolean = true,
|
|
||||||
passOnRedirect: Boolean = false
|
|
||||||
) {
|
|
||||||
override def toString(): String =
|
|
||||||
withPassword("****")
|
|
||||||
.withHeaders(
|
|
||||||
headers.map {
|
|
||||||
case (k, v) => (k, "****")
|
|
||||||
}
|
|
||||||
)
|
|
||||||
.productIterator
|
|
||||||
.mkString("Authentication(", ", ", ")")
|
|
||||||
}
|
|
||||||
|
|
||||||
object Authentication {
|
|
||||||
|
|
||||||
def apply(headers: Seq[(String, String)]): Authentication =
|
|
||||||
Authentication("", "").withHeaders(headers)
|
|
||||||
}
|
|
||||||
|
|
@ -6,7 +6,7 @@ object CachePolicy {
|
||||||
/* NOTE: the following comments are copied from coursier.cache.CachePolicy for the benefit of users within an IDE
|
/* NOTE: the following comments are copied from coursier.cache.CachePolicy for the benefit of users within an IDE
|
||||||
that reads the javadocs. Please keep in sync from the original ADT.
|
that reads the javadocs. Please keep in sync from the original ADT.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** Only pick local files, possibly from the cache. Don't try to download anything. */
|
/** Only pick local files, possibly from the cache. Don't try to download anything. */
|
||||||
case object LocalOnly extends CachePolicy
|
case object LocalOnly extends CachePolicy
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,42 +0,0 @@
|
||||||
package lmcoursier.definitions
|
|
||||||
|
|
||||||
import dataclass.data
|
|
||||||
|
|
||||||
@data class Dependency(
|
|
||||||
module: Module,
|
|
||||||
version: String,
|
|
||||||
configuration: Configuration,
|
|
||||||
exclusions: Set[(Organization, ModuleName)],
|
|
||||||
publication: Publication,
|
|
||||||
optional: Boolean,
|
|
||||||
transitive: Boolean
|
|
||||||
) {
|
|
||||||
def attributes: Attributes = publication.attributes
|
|
||||||
def withAttributes(attributes: Attributes): Dependency =
|
|
||||||
withPublication(
|
|
||||||
publication
|
|
||||||
.withType(attributes.`type`)
|
|
||||||
.withClassifier(attributes.classifier)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
object Dependency {
|
|
||||||
def apply(
|
|
||||||
module: Module,
|
|
||||||
version: String,
|
|
||||||
configuration: Configuration,
|
|
||||||
exclusions: Set[(Organization, ModuleName)],
|
|
||||||
attributes: Attributes,
|
|
||||||
optional: Boolean,
|
|
||||||
transitive: Boolean
|
|
||||||
): Dependency =
|
|
||||||
Dependency(
|
|
||||||
module,
|
|
||||||
version,
|
|
||||||
configuration,
|
|
||||||
exclusions,
|
|
||||||
Publication("", attributes.`type`, Extension(""), attributes.classifier),
|
|
||||||
optional,
|
|
||||||
transitive
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
@ -1,22 +0,0 @@
|
||||||
package lmcoursier.definitions
|
|
||||||
|
|
||||||
import dataclass.data
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param exclude Use "*" in either organization or name to match any.
|
|
||||||
* @param include Use "*" in either organization or name to match any.
|
|
||||||
*/
|
|
||||||
@data class ModuleMatchers(
|
|
||||||
exclude: Set[Module],
|
|
||||||
include: Set[Module],
|
|
||||||
includeByDefault: Boolean = true
|
|
||||||
)
|
|
||||||
|
|
||||||
object ModuleMatchers {
|
|
||||||
def all: ModuleMatchers =
|
|
||||||
ModuleMatchers(Set.empty, Set.empty)
|
|
||||||
def only(organization: String, moduleName: String): ModuleMatchers =
|
|
||||||
ModuleMatchers(Set.empty, Set(Module(Organization(organization), ModuleName(moduleName), Map())), includeByDefault = false)
|
|
||||||
def only(mod: Module): ModuleMatchers =
|
|
||||||
ModuleMatchers(Set.empty, Set(mod), includeByDefault = false)
|
|
||||||
}
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
package lmcoursier.definitions
|
|
||||||
|
|
||||||
import dataclass.data
|
|
||||||
|
|
||||||
@data class Publication(
|
|
||||||
name: String,
|
|
||||||
`type`: Type,
|
|
||||||
ext: Extension,
|
|
||||||
classifier: Classifier
|
|
||||||
) {
|
|
||||||
def attributes: Attributes =
|
|
||||||
Attributes(`type`, classifier)
|
|
||||||
def withAttributes(attributes: Attributes): Publication =
|
|
||||||
withType(attributes.`type`)
|
|
||||||
.withClassifier(attributes.classifier)
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,185 @@
|
||||||
|
package lmcoursier
|
||||||
|
|
||||||
|
import coursier.cache.CacheDefaults
|
||||||
|
import lmcoursier.credentials._
|
||||||
|
import lmcoursier.definitions._
|
||||||
|
import sbt.librarymanagement.{Resolver, UpdateConfiguration, ModuleID, CrossVersion, ModuleInfo, ModuleDescriptorConfiguration}
|
||||||
|
import xsbti.Logger
|
||||||
|
|
||||||
|
import scala.concurrent.duration.Duration
|
||||||
|
import java.io.File
|
||||||
|
import java.net.URL
|
||||||
|
import java.net.URLClassLoader
|
||||||
|
|
||||||
|
package object syntax {
|
||||||
|
implicit class CoursierConfigurationModule(value: CoursierConfiguration.type) {
|
||||||
|
@deprecated("Legacy cache location support was dropped, this method does nothing.", "2.0.0-RC6-10")
|
||||||
|
def checkLegacyCache(): Unit = ()
|
||||||
|
|
||||||
|
def apply(
|
||||||
|
log: Logger,
|
||||||
|
resolvers: Vector[Resolver],
|
||||||
|
parallelDownloads: Int,
|
||||||
|
maxIterations: Int,
|
||||||
|
sbtScalaOrganization: String,
|
||||||
|
sbtScalaVersion: String,
|
||||||
|
sbtScalaJars: Vector[File],
|
||||||
|
interProjectDependencies: Vector[Project],
|
||||||
|
excludeDependencies: Vector[(String, String)],
|
||||||
|
fallbackDependencies: Vector[FallbackDependency],
|
||||||
|
autoScalaLibrary: Boolean,
|
||||||
|
hasClassifiers: Boolean,
|
||||||
|
classifiers: Vector[String],
|
||||||
|
mavenProfiles: Vector[String],
|
||||||
|
scalaOrganization: String,
|
||||||
|
scalaVersion: String,
|
||||||
|
authenticationByRepositoryId: Vector[(String, Authentication)],
|
||||||
|
credentials: Seq[Credentials],
|
||||||
|
logger: CacheLogger,
|
||||||
|
cache: File
|
||||||
|
): CoursierConfiguration =
|
||||||
|
CoursierConfiguration(
|
||||||
|
Option(log),
|
||||||
|
resolvers,
|
||||||
|
parallelDownloads,
|
||||||
|
maxIterations,
|
||||||
|
Option(sbtScalaOrganization),
|
||||||
|
Option(sbtScalaVersion),
|
||||||
|
sbtScalaJars,
|
||||||
|
interProjectDependencies,
|
||||||
|
excludeDependencies,
|
||||||
|
fallbackDependencies,
|
||||||
|
autoScalaLibrary,
|
||||||
|
hasClassifiers,
|
||||||
|
classifiers,
|
||||||
|
mavenProfiles,
|
||||||
|
Option(scalaOrganization),
|
||||||
|
Option(scalaVersion),
|
||||||
|
authenticationByRepositoryId,
|
||||||
|
credentials,
|
||||||
|
Option(logger),
|
||||||
|
Option(cache),
|
||||||
|
ivyHome = None,
|
||||||
|
followHttpToHttpsRedirections = None,
|
||||||
|
strict = None,
|
||||||
|
extraProjects = Vector.empty,
|
||||||
|
forceVersions = Vector.empty,
|
||||||
|
reconciliation = Vector.empty,
|
||||||
|
classpathOrder = true,
|
||||||
|
verbosityLevel = 0,
|
||||||
|
ttl = CacheDefaults.ttl,
|
||||||
|
checksums = CacheDefaults.checksums.toVector,
|
||||||
|
cachePolicies = CacheDefaults.cachePolicies.toVector.map(FromCoursier.cachePolicy),
|
||||||
|
missingOk = false,
|
||||||
|
sbtClassifiers = false,
|
||||||
|
providedInCompile = false,
|
||||||
|
protocolHandlerDependencies = Vector.empty,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
implicit class CoursierConfigurationOp(value: CoursierConfiguration) {
|
||||||
|
def withLog(log: Logger): CoursierConfiguration =
|
||||||
|
value.withLog(Option(log))
|
||||||
|
def withSbtScalaOrganization(sbtScalaOrganization: String): CoursierConfiguration =
|
||||||
|
value.withSbtScalaOrganization(Option(sbtScalaOrganization))
|
||||||
|
def withSbtScalaVersion(sbtScalaVersion: String): CoursierConfiguration =
|
||||||
|
value.withSbtScalaVersion(Option(sbtScalaVersion))
|
||||||
|
def withScalaOrganization(scalaOrganization: String): CoursierConfiguration =
|
||||||
|
value.withScalaOrganization(Option(scalaOrganization))
|
||||||
|
def withScalaVersion(scalaVersion: String): CoursierConfiguration =
|
||||||
|
value.withScalaVersion(Option(scalaVersion))
|
||||||
|
def withLogger(logger: CacheLogger): CoursierConfiguration =
|
||||||
|
value.withLogger(Option(logger))
|
||||||
|
def withCache(cache: File): CoursierConfiguration =
|
||||||
|
value.withCache(Option(cache))
|
||||||
|
def withIvyHome(ivyHome: File): CoursierConfiguration =
|
||||||
|
value.withIvyHome(Option(ivyHome))
|
||||||
|
def withFollowHttpToHttpsRedirections(followHttpToHttpsRedirections: Boolean): CoursierConfiguration =
|
||||||
|
value.withFollowHttpToHttpsRedirections(Some(followHttpToHttpsRedirections))
|
||||||
|
def withFollowHttpToHttpsRedirections(): CoursierConfiguration =
|
||||||
|
value.withFollowHttpToHttpsRedirections(Some(true))
|
||||||
|
def withStrict(strict: Strict): CoursierConfiguration =
|
||||||
|
value.withStrict(Some(strict))
|
||||||
|
def withTtl(ttl: Duration): CoursierConfiguration =
|
||||||
|
value.withTtl(Some(ttl))
|
||||||
|
def addRepositoryAuthentication(repositoryId: String, authentication: Authentication): CoursierConfiguration =
|
||||||
|
value.withAuthenticationByRepositoryId(value.authenticationByRepositoryId :+ (repositoryId, authentication))
|
||||||
|
|
||||||
|
def withUpdateConfiguration(conf: UpdateConfiguration): CoursierConfiguration =
|
||||||
|
value.withMissingOk(conf.missingOk)
|
||||||
|
}
|
||||||
|
|
||||||
|
implicit class PublicationOp(value: Publication) {
|
||||||
|
def attributes: Attributes =
|
||||||
|
Attributes(value.`type`, value.classifier)
|
||||||
|
|
||||||
|
def withAttributes(attributes: Attributes): Publication =
|
||||||
|
value.withType(attributes.`type`)
|
||||||
|
.withClassifier(attributes.classifier)
|
||||||
|
}
|
||||||
|
|
||||||
|
implicit class DependencyModule(value: Dependency.type) {
|
||||||
|
def apply(
|
||||||
|
module: Module,
|
||||||
|
version: String,
|
||||||
|
configuration: Configuration,
|
||||||
|
exclusions: Set[(Organization, ModuleName)],
|
||||||
|
attributes: Attributes,
|
||||||
|
optional: Boolean,
|
||||||
|
transitive: Boolean
|
||||||
|
): Dependency =
|
||||||
|
Dependency(
|
||||||
|
module,
|
||||||
|
version,
|
||||||
|
configuration,
|
||||||
|
exclusions,
|
||||||
|
Publication("", attributes.`type`, Extension(""), attributes.classifier),
|
||||||
|
optional,
|
||||||
|
transitive
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
implicit class DependencyOp(value: Dependency) {
|
||||||
|
def attributes: Attributes = value.publication.attributes
|
||||||
|
|
||||||
|
def withAttributes(attributes: Attributes): Dependency =
|
||||||
|
value.withPublication(
|
||||||
|
value.publication
|
||||||
|
.withType(attributes.`type`)
|
||||||
|
.withClassifier(attributes.classifier)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
implicit class ModuleMatchersModule(value: ModuleMatchers.type) {
|
||||||
|
def all: ModuleMatchers =
|
||||||
|
ModuleMatchers(Set.empty, Set.empty)
|
||||||
|
def only(organization: String, moduleName: String): ModuleMatchers =
|
||||||
|
ModuleMatchers(Set.empty, Set(Module(Organization(organization), ModuleName(moduleName), Map())), includeByDefault = false)
|
||||||
|
def only(mod: Module): ModuleMatchers =
|
||||||
|
ModuleMatchers(Set.empty, Set(mod), includeByDefault = false)
|
||||||
|
}
|
||||||
|
|
||||||
|
implicit class StrictOp(value: Strict) {
|
||||||
|
def addInclude(include: (String, String)*): Strict =
|
||||||
|
value.withInclude(value.include ++ include)
|
||||||
|
def addExclude(exclude: (String, String)*): Strict =
|
||||||
|
value.withExclude(value.exclude ++ exclude)
|
||||||
|
}
|
||||||
|
|
||||||
|
implicit class AuthenticationModule(value: Authentication.type) {
|
||||||
|
def apply(headers: Seq[(String, String)]): Authentication =
|
||||||
|
Authentication("", "").withHeaders(headers)
|
||||||
|
}
|
||||||
|
|
||||||
|
implicit class DirectCredentialsModule(value: DirectCredentials.type) {
|
||||||
|
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: String, optional: Boolean): DirectCredentials =
|
||||||
|
DirectCredentials(host, username, password, Option(realm))
|
||||||
|
}
|
||||||
|
|
||||||
|
implicit class DirectCredentialsOp(value: DirectCredentials) {
|
||||||
|
def withRealm(realm: String): DirectCredentials =
|
||||||
|
value.withRealm(Option(realm))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -7,6 +7,7 @@ import lmcoursier.credentials.Credentials
|
||||||
import lmcoursier.{CoursierDependencyResolution, FallbackDependency}
|
import lmcoursier.{CoursierDependencyResolution, FallbackDependency}
|
||||||
import lmcoursier.definitions.{CacheLogger, Configuration, Project, Publication}
|
import lmcoursier.definitions.{CacheLogger, Configuration, Project, Publication}
|
||||||
import lmcoursier.internal.SbtCoursierCache
|
import lmcoursier.internal.SbtCoursierCache
|
||||||
|
import lmcoursier.syntax._
|
||||||
import sbt.{AutoPlugin, Classpaths, Compile, Setting, TaskKey, Test, settingKey, taskKey}
|
import sbt.{AutoPlugin, Classpaths, Compile, Setting, TaskKey, Test, settingKey, taskKey}
|
||||||
import sbt.Keys._
|
import sbt.Keys._
|
||||||
import sbt.librarymanagement.DependencyBuilders.OrganizationArtifactName
|
import sbt.librarymanagement.DependencyBuilders.OrganizationArtifactName
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package coursier.sbtlmcoursier
|
||||||
|
|
||||||
import lmcoursier.definitions.{Authentication, ModuleMatchers, Reconciliation}
|
import lmcoursier.definitions.{Authentication, ModuleMatchers, Reconciliation}
|
||||||
import lmcoursier.{CoursierConfiguration, CoursierDependencyResolution, Inputs}
|
import lmcoursier.{CoursierConfiguration, CoursierDependencyResolution, Inputs}
|
||||||
|
import lmcoursier.syntax._
|
||||||
import coursier.sbtcoursiershared.InputsTasks.{credentialsTask, strictTask}
|
import coursier.sbtcoursiershared.InputsTasks.{credentialsTask, strictTask}
|
||||||
import coursier.sbtcoursiershared.{InputsTasks, SbtCoursierShared}
|
import coursier.sbtcoursiershared.{InputsTasks, SbtCoursierShared}
|
||||||
import sbt.{AutoPlugin, Classpaths, Def, Setting, Task, taskKey}
|
import sbt.{AutoPlugin, Classpaths, Def, Setting, Task, taskKey}
|
||||||
|
|
|
||||||
|
|
@ -48,8 +48,8 @@ object Settings {
|
||||||
val prop = sys.props.getOrElse("publish.javadoc", "").toLowerCase(Locale.ROOT)
|
val prop = sys.props.getOrElse("publish.javadoc", "").toLowerCase(Locale.ROOT)
|
||||||
if (prop == "0" || prop == "false")
|
if (prop == "0" || prop == "false")
|
||||||
Seq(
|
Seq(
|
||||||
sources in (Compile, doc) := Seq.empty,
|
Compile / doc / sources := Seq.empty,
|
||||||
publishArtifact in (Compile, packageDoc) := false
|
Compile / packageDoc / publishArtifact := false
|
||||||
)
|
)
|
||||||
else
|
else
|
||||||
Nil
|
Nil
|
||||||
|
|
@ -69,14 +69,14 @@ object Settings {
|
||||||
),
|
),
|
||||||
scriptedBufferLog := false,
|
scriptedBufferLog := false,
|
||||||
sbtPlugin := true,
|
sbtPlugin := true,
|
||||||
sbtVersion.in(pluginCrossBuild) := targetSbtVersion
|
pluginCrossBuild / sbtVersion := targetSbtVersion
|
||||||
)
|
)
|
||||||
|
|
||||||
lazy val generatePropertyFile =
|
lazy val generatePropertyFile =
|
||||||
resourceGenerators.in(Compile) += Def.task {
|
Compile / resourceGenerators += Def.task {
|
||||||
import sys.process._
|
import sys.process._
|
||||||
|
|
||||||
val dir = classDirectory.in(Compile).value / "coursier"
|
val dir = (Compile / classDirectory).value / "coursier"
|
||||||
val ver = version.value
|
val ver = version.value
|
||||||
|
|
||||||
val f = dir / "sbtcoursier.properties"
|
val f = dir / "sbtcoursier.properties"
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.10")
|
addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.10")
|
||||||
addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "1.1.0")
|
addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "1.1.0")
|
||||||
addSbtPlugin("io.get-coursier" % "sbt-shading" % "2.0.1")
|
addSbtPlugin("io.get-coursier" % "sbt-shading" % "2.0.1")
|
||||||
|
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.34")
|
||||||
|
|
||||||
libraryDependencies += "org.scala-sbt" %% "scripted-plugin" % sbtVersion.value
|
libraryDependencies += "org.scala-sbt" %% "scripted-plugin" % sbtVersion.value
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue