From ce2544d776db5f9888833a1b6e53fd366dc16935 Mon Sep 17 00:00:00 2001 From: Alexandre Archambault Date: Fri, 18 Oct 2019 13:39:03 +0200 Subject: [PATCH] Use data-class in lm-coursier (#152) --- build.sbt | 6 +- .../src/main/contraband/authentication.json | 33 - .../src/main/contraband/datetime.json | 37 -- .../src/main/contraband/dependency.json | 48 -- .../src/main/contraband/developer.json | 25 - .../main/contraband/fallback-dependency.json | 29 - .../lm-coursier/src/main/contraband/info.json | 33 - .../src/main/contraband/module.json | 56 -- .../src/main/contraband/project.json | 45 -- .../src/main/contraband/publication.json | 33 - .../lmcoursier/CoursierConfiguration.scala | 585 ++---------------- .../scala/lmcoursier/FallbackDependency.scala | 55 +- .../credentials/DirectCredentials.scala | 76 +-- .../credentials/FileCredentials.scala | 36 +- .../lmcoursier/definitions/Attributes.scala | 37 +- .../definitions/Authentication.scala | 56 +- .../lmcoursier/definitions/DateTime.scala | 62 +- .../lmcoursier/definitions/Dependency.scala | 89 ++- .../lmcoursier/definitions/Developer.scala | 47 +- .../scala/lmcoursier/definitions/Info.scala | 57 +- .../scala/lmcoursier/definitions/Module.scala | 46 +- .../definitions/ModuleMatchers.scala | 53 +- .../lmcoursier/definitions/Project.scala | 72 +-- .../lmcoursier/definitions/Publication.scala | 57 +- .../definitions/Reconciliation.scala | 2 + .../scala/lmcoursier/definitions/Strict.scala | 57 +- project/Settings.scala | 15 +- project/plugins.sbt | 16 +- 28 files changed, 263 insertions(+), 1500 deletions(-) delete mode 100644 modules/lm-coursier/src/main/contraband/authentication.json delete mode 100644 modules/lm-coursier/src/main/contraband/datetime.json delete mode 100644 modules/lm-coursier/src/main/contraband/dependency.json delete mode 100644 modules/lm-coursier/src/main/contraband/developer.json delete mode 100644 modules/lm-coursier/src/main/contraband/fallback-dependency.json delete mode 100644 modules/lm-coursier/src/main/contraband/info.json delete mode 100644 modules/lm-coursier/src/main/contraband/module.json delete mode 100644 modules/lm-coursier/src/main/contraband/project.json delete mode 100644 modules/lm-coursier/src/main/contraband/publication.json diff --git a/build.sbt b/build.sbt index 9341c72f4..64dcae6f3 100644 --- a/build.sbt +++ b/build.sbt @@ -18,7 +18,6 @@ inThisBuild(List( val coursierVersion0 = "2.0.0-RC4-1" lazy val `lm-coursier` = project - .enablePlugins(ContrabandPlugin) .in(file("modules/lm-coursier")) .settings( shared, @@ -26,6 +25,7 @@ lazy val `lm-coursier` = project Mima.lmCoursierFilters, libraryDependencies ++= Seq( "io.get-coursier" %% "coursier" % coursierVersion0, + "io.github.alexarchambault" %% "data-class" % "0.2.0" % Provided, // We depend on librarymanagement-ivy rather than just // librarymanagement-core to handle the ModuleDescriptor passed // to DependencyResolutionInterface.update, which is an @@ -33,8 +33,7 @@ lazy val `lm-coursier` = project // is ignored). "org.scala-sbt" %% "librarymanagement-ivy" % "1.2.4", "org.scalatest" %% "scalatest" % "3.0.8" % Test - ), - Compile / generateContrabands / sourceManaged := baseDirectory.value / "src" / "main" / "scala", + ) ) lazy val `lm-coursier-shaded` = project @@ -57,6 +56,7 @@ lazy val `lm-coursier-shaded` = project ), libraryDependencies ++= Seq( "io.get-coursier" %% "coursier" % coursierVersion0 % "shaded", + "io.github.alexarchambault" %% "data-class" % "0.2.0" % Provided, "org.scala-lang.modules" %% "scala-xml" % "1.2.0", // depending on that one so that it doesn't get shaded "org.scala-sbt" %% "librarymanagement-ivy" % "1.2.4", "org.scalatest" %% "scalatest" % "3.0.8" % Test diff --git a/modules/lm-coursier/src/main/contraband/authentication.json b/modules/lm-coursier/src/main/contraband/authentication.json deleted file mode 100644 index 9f77a0ccb..000000000 --- a/modules/lm-coursier/src/main/contraband/authentication.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "types": [ - { - "name": "Authentication", - "namespace": "lmcoursier.definitions", - "target": "Scala", - "parents": [], - "type": "record", - "fields": [ - { - "name": "user", - "type": "String" - }, - { - "name": "password", - "type": "String" - }, - { - "name": "optional", - "type": "Boolean", - "default": "false", - "since": "1.0.0" - }, - { - "name": "realmOpt", - "type": "Option[String]", - "default": "None", - "since": "1.0.0" - } - ] - } - ] -} diff --git a/modules/lm-coursier/src/main/contraband/datetime.json b/modules/lm-coursier/src/main/contraband/datetime.json deleted file mode 100644 index 464bdf293..000000000 --- a/modules/lm-coursier/src/main/contraband/datetime.json +++ /dev/null @@ -1,37 +0,0 @@ -{ - "types": [ - { - "name": "DateTime", - "namespace": "lmcoursier.definitions", - "target": "Scala", - "parents": [], - "type": "record", - "fields": [ - { - "name": "year", - "type": "Int" - }, - { - "name": "month", - "type": "Int" - }, - { - "name": "day", - "type": "Int" - }, - { - "name": "hour", - "type": "Int" - }, - { - "name": "minute", - "type": "Int" - }, - { - "name": "second", - "type": "Int" - } - ] - } - ] -} diff --git a/modules/lm-coursier/src/main/contraband/dependency.json b/modules/lm-coursier/src/main/contraband/dependency.json deleted file mode 100644 index a53feeebf..000000000 --- a/modules/lm-coursier/src/main/contraband/dependency.json +++ /dev/null @@ -1,48 +0,0 @@ -{ - "types": [ - { - "name": "Dependency", - "namespace": "lmcoursier.definitions", - "target": "Scala", - "parents": [], - "type": "record", - "fields": [ - { - "name": "module", - "type": "Module" - }, - { - "name": "version", - "type": "String" - }, - { - "name": "configuration", - "type": "Configuration" - }, - { - "name": "exclusions", - "type": "Set[(Organization, ModuleName)]" - }, - { - "name": "publication", - "type": "Publication" - }, - { - "name": "optional", - "type": "Boolean" - }, - { - "name": "transitive", - "type": "Boolean" - } - ], - "extra": [ - "def attributes: Attributes = publication.attributes", - "def withAttributes(attributes: Attributes): Dependency = withPublication(publication.withType(attributes.`type`).withClassifier(attributes.classifier))" - ], - "extraCompanion": [ - "def apply(module: Module, version: String, configuration: Configuration, exclusions: Set[(Organization, ModuleName)], attributes: Attributes, optional: Boolean, transitive: Boolean): Dependency = new Dependency(module, version, configuration, exclusions, Publication(\"\", attributes.`type`, Extension(\"\"), attributes.classifier), optional, transitive)" - ] - } - ] -} diff --git a/modules/lm-coursier/src/main/contraband/developer.json b/modules/lm-coursier/src/main/contraband/developer.json deleted file mode 100644 index e4d98806a..000000000 --- a/modules/lm-coursier/src/main/contraband/developer.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "types": [ - { - "name": "Developer", - "namespace": "lmcoursier.definitions", - "target": "Scala", - "parents": [], - "type": "record", - "fields": [ - { - "name": "id", - "type": "String" - }, - { - "name": "name", - "type": "String" - }, - { - "name": "url", - "type": "String" - } - ] - } - ] -} diff --git a/modules/lm-coursier/src/main/contraband/fallback-dependency.json b/modules/lm-coursier/src/main/contraband/fallback-dependency.json deleted file mode 100644 index 4f50f58d6..000000000 --- a/modules/lm-coursier/src/main/contraband/fallback-dependency.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "types": [ - { - "name": "FallbackDependency", - "namespace": "lmcoursier", - "target": "Scala", - "parents": [], - "type": "record", - "fields": [ - { - "name": "module", - "type": "lmcoursier.definitions.Module" - }, - { - "name": "version", - "type": "String" - }, - { - "name": "url", - "type": "java.net.URL" - }, - { - "name": "changing", - "type": "Boolean" - } - ] - } - ] -} diff --git a/modules/lm-coursier/src/main/contraband/info.json b/modules/lm-coursier/src/main/contraband/info.json deleted file mode 100644 index b4fabf126..000000000 --- a/modules/lm-coursier/src/main/contraband/info.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "types": [ - { - "name": "Info", - "namespace": "lmcoursier.definitions", - "target": "Scala", - "parents": [], - "type": "record", - "fields": [ - { - "name": "description", - "type": "String" - }, - { - "name": "homePage", - "type": "String" - }, - { - "name": "licenses", - "type": "Seq[(String, Option[String])]" - }, - { - "name": "developers", - "type": "Seq[Developer]" - }, - { - "name": "publication", - "type": "Option[DateTime]" - } - ] - } - ] -} diff --git a/modules/lm-coursier/src/main/contraband/module.json b/modules/lm-coursier/src/main/contraband/module.json deleted file mode 100644 index a53095667..000000000 --- a/modules/lm-coursier/src/main/contraband/module.json +++ /dev/null @@ -1,56 +0,0 @@ -{ - "types": [ - { - "name": "Module", - "namespace": "lmcoursier.definitions", - "target": "Scala", - "parents": [], - "type": "record", - "fields": [ - { - "name": "organization", - "type": "Organization" - }, - { - "name": "name", - "type": "ModuleName" - }, - { - "name": "attributes", - "type": "Map[String, String]" - } - ] - }, - - { - "name": "ModuleMatchers", - "namespace": "lmcoursier.definitions", - "target": "Scala", - "parents": [], - "type": "record", - "fields": [ - { - "name": "exclude", - "type": "Set[lmcoursier.definitions.Module]", - "doc": "Use \"*\" in either organization or name to match any." - }, - { - "name": "include", - "type": "Set[lmcoursier.definitions.Module]", - "doc": "Use \"*\" in either organization or name to match any." - }, - { - "name": "includeByDefault", - "type": "Boolean", - "default": "true", - "since": "2.0.0-RC4" - } - ], - "extraCompanion": [ - "/** ModuleMatchers that matches to any modules. */", - "def all: ModuleMatchers = ModuleMatchers(Set.empty, Set.empty)", - "def only(mod: Module): ModuleMatchers = ModuleMatchers(Set.empty, Set(mod), includeByDefault = false)" - ] - } - ] -} diff --git a/modules/lm-coursier/src/main/contraband/project.json b/modules/lm-coursier/src/main/contraband/project.json deleted file mode 100644 index 014c1e946..000000000 --- a/modules/lm-coursier/src/main/contraband/project.json +++ /dev/null @@ -1,45 +0,0 @@ -{ - "types": [ - { - "name": "Project", - "namespace": "lmcoursier.definitions", - "target": "Scala", - "parents": [], - "type": "record", - "fields": [ - { - "name": "module", - "type": "Module" - }, - { - "name": "version", - "type": "String" - }, - { - "name": "dependencies", - "type": "Seq[(Configuration, Dependency)]" - }, - { - "name": "configurations", - "type": "Map[Configuration, Seq[Configuration]]" - }, - { - "name": "properties", - "type": "Seq[(String, String)]" - }, - { - "name": "packagingOpt", - "type": "Option[Type]" - }, - { - "name": "publications", - "type": "Seq[(Configuration, Publication)]" - }, - { - "name": "info", - "type": "Info" - } - ] - } - ] -} diff --git a/modules/lm-coursier/src/main/contraband/publication.json b/modules/lm-coursier/src/main/contraband/publication.json deleted file mode 100644 index c0f365bc2..000000000 --- a/modules/lm-coursier/src/main/contraband/publication.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "types": [ - { - "name": "Publication", - "namespace": "lmcoursier.definitions", - "target": "Scala", - "parents": [], - "type": "record", - "fields": [ - { - "name": "name", - "type": "String" - }, - { - "name": "type", - "type": "Type" - }, - { - "name": "ext", - "type": "Extension" - }, - { - "name": "classifier", - "type": "Classifier" - } - ], - "extra": [ - "def attributes: Attributes = Attributes(`type`, classifier)", - "def withAttributes(attributes: Attributes): Publication = withType(attributes.`type`).withClassifier(attributes.classifier)" - ] - } - ] -} diff --git a/modules/lm-coursier/src/main/scala/lmcoursier/CoursierConfiguration.scala b/modules/lm-coursier/src/main/scala/lmcoursier/CoursierConfiguration.scala index 19ff8c918..93ddc9b67 100644 --- a/modules/lm-coursier/src/main/scala/lmcoursier/CoursierConfiguration.scala +++ b/modules/lm-coursier/src/main/scala/lmcoursier/CoursierConfiguration.scala @@ -1,553 +1,100 @@ -/** - * This code USED TO BE generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. - */ - -// DO EDIT MANUALLY from now on package lmcoursier import java.io.File +import dataclass.data import lmcoursier.credentials.Credentials import lmcoursier.definitions.{Authentication, CacheLogger, Module, ModuleMatchers, Project, Reconciliation, Strict} import sbt.librarymanagement.Resolver import xsbti.Logger -final class CoursierConfiguration private ( - val log: Option[Logger], - val resolvers: Vector[Resolver], - val parallelDownloads: Int, - val maxIterations: Int, - val sbtScalaOrganization: Option[String], - val sbtScalaVersion: Option[String], - val sbtScalaJars: Vector[File], - val interProjectDependencies: Vector[Project], - val excludeDependencies: Vector[(String, String)], - val fallbackDependencies: Vector[FallbackDependency], - val autoScalaLibrary: Boolean, - val hasClassifiers: Boolean, - val classifiers: Vector[String], - val mavenProfiles: Vector[String], - val scalaOrganization: Option[String], - val scalaVersion: Option[String], - val authenticationByRepositoryId: Vector[(String, Authentication)], - val credentials: Seq[Credentials], - val logger: Option[CacheLogger], - val cache: Option[File], - val ivyHome: Option[File], - val followHttpToHttpsRedirections: Option[Boolean], - val strict: Option[Strict], - val extraProjects: Vector[Project], - val forceVersions: Vector[(Module, String)], - val reconciliation: Vector[(ModuleMatchers, Reconciliation)] -) extends Serializable { - - private def this() = - this( - None, - Resolver.defaults, - 6, - 100, - None, - None, - Vector.empty, - Vector.empty, - Vector.empty, - Vector.empty, - true, - false, - Vector.empty, - Vector.empty, - None, - None, - Vector.empty, - Vector.empty, - None, - None, - None, - None, - None, - Vector.empty, - Vector.empty, - Vector.empty - ) - - def this( - log: Option[Logger], - resolvers: Vector[Resolver], - parallelDownloads: Int, - maxIterations: Int, - sbtScalaOrganization: Option[String], - sbtScalaVersion: Option[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: Option[String], - scalaVersion: Option[String], - authenticationByRepositoryId: Vector[(String, Authentication)], - credentials: Seq[Credentials], - logger: Option[CacheLogger], - cache: Option[File], - ivyHome: Option[File], - followHttpToHttpsRedirections: Option[Boolean] - ) = - this( - log, - resolvers, - parallelDownloads, - maxIterations, - sbtScalaOrganization, - sbtScalaVersion, - sbtScalaJars, - interProjectDependencies, - excludeDependencies, - fallbackDependencies, - autoScalaLibrary, - hasClassifiers, - classifiers, - mavenProfiles, - scalaOrganization, - scalaVersion, - authenticationByRepositoryId, - credentials, - logger, - cache, - ivyHome, - followHttpToHttpsRedirections, - None, - Vector.empty, - Vector.empty, - Vector.empty - ) - - def this( - log: Option[Logger], - resolvers: Vector[Resolver], - parallelDownloads: Int, - maxIterations: Int, - sbtScalaOrganization: Option[String], - sbtScalaVersion: Option[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: Option[String], - scalaVersion: Option[String], - authenticationByRepositoryId: Vector[(String, Authentication)], - credentials: Seq[Credentials], - logger: Option[CacheLogger], - cache: Option[File], - ivyHome: Option[File], - followHttpToHttpsRedirections: Option[Boolean], - strict: Option[Strict], - extraProjects: Vector[Project], - forceVersions: Vector[(Module, String)], - ) = - this( - log, - resolvers, - parallelDownloads, - maxIterations, - sbtScalaOrganization, - sbtScalaVersion, - sbtScalaJars, - interProjectDependencies, - excludeDependencies, - fallbackDependencies, - autoScalaLibrary, - hasClassifiers, - classifiers, - mavenProfiles, - scalaOrganization, - scalaVersion, - authenticationByRepositoryId, - credentials, - logger, - cache, - ivyHome, - followHttpToHttpsRedirections, - strict, - extraProjects, - forceVersions, - Vector.empty - ) - - override def equals(o: Any): Boolean = - o match { - case other: CoursierConfiguration => - log == other.log && - resolvers == other.resolvers && - parallelDownloads == other.parallelDownloads && - maxIterations == other.maxIterations && - sbtScalaOrganization == other.sbtScalaOrganization && - sbtScalaVersion == other.sbtScalaVersion && - sbtScalaJars == other.sbtScalaJars && - interProjectDependencies == other.interProjectDependencies && - excludeDependencies == other.excludeDependencies && - fallbackDependencies == other.fallbackDependencies && - autoScalaLibrary == other.autoScalaLibrary && - hasClassifiers == other.hasClassifiers && - classifiers == other.classifiers && - mavenProfiles == other.mavenProfiles && - scalaOrganization == other.scalaOrganization && - scalaVersion == other.scalaVersion && - authenticationByRepositoryId == other.authenticationByRepositoryId && - credentials == other.credentials && - logger == other.logger && - cache == other.cache && - ivyHome == other.ivyHome && - followHttpToHttpsRedirections == other.followHttpToHttpsRedirections && - strict == other.strict && - extraProjects == other.extraProjects && - forceVersions == other.forceVersions && - reconciliation == other.reconciliation - case _ => false - } - - override def hashCode: Int = { - var code = 37 * (17 + "lmcoursier.CoursierConfiguration".##) - code = 37 * (code + log.##) - code = 37 * (code + resolvers.##) - code = 37 * (code + parallelDownloads.##) - code = 37 * (code + maxIterations.##) - code = 37 * (code + sbtScalaOrganization.##) - code = 37 * (code + sbtScalaVersion.##) - code = 37 * (code + sbtScalaJars.##) - code = 37 * (code + interProjectDependencies.##) - code = 37 * (code + excludeDependencies.##) - code = 37 * (code + fallbackDependencies.##) - code = 37 * (code + autoScalaLibrary.##) - code = 37 * (code + hasClassifiers.##) - code = 37 * (code + classifiers.##) - code = 37 * (code + mavenProfiles.##) - code = 37 * (code + scalaOrganization.##) - code = 37 * (code + scalaVersion.##) - code = 37 * (code + authenticationByRepositoryId.##) - code = 37 * (code + credentials.##) - code = 37 * (code + logger.##) - code = 37 * (code + cache.##) - code = 37 * (code + ivyHome.##) - code = 37 * (code + followHttpToHttpsRedirections.##) - code = 37 * (code + strict.##) - code = 37 * (code + extraProjects.##) - code = 37 * (code + forceVersions.##) - code = 37 * (code + reconciliation.##) - code - } - - override def toString: String = - s"CoursierConfiguration($log, $resolvers, $parallelDownloads, $maxIterations, $sbtScalaOrganization, $sbtScalaVersion, $sbtScalaJars, $interProjectDependencies, $excludeDependencies, $fallbackDependencies, $autoScalaLibrary, $hasClassifiers, $classifiers, $mavenProfiles, $scalaOrganization, $scalaVersion, $authenticationByRepositoryId, $credentials, $logger, $cache, $ivyHome, $followHttpToHttpsRedirections, $strict, $extraProjects, $forceVersions)" - - private[this] def copy( - log: Option[Logger] = log, - resolvers: Vector[Resolver] = resolvers, - parallelDownloads: Int = parallelDownloads, - maxIterations: Int = maxIterations, - sbtScalaOrganization: Option[String] = sbtScalaOrganization, - sbtScalaVersion: Option[String] = sbtScalaVersion, - sbtScalaJars: Vector[File] = sbtScalaJars, - interProjectDependencies: Vector[Project] = interProjectDependencies, - excludeDependencies: Vector[(String, String)] = excludeDependencies, - fallbackDependencies: Vector[FallbackDependency] = fallbackDependencies, - autoScalaLibrary: Boolean = autoScalaLibrary, - hasClassifiers: Boolean = hasClassifiers, - classifiers: Vector[String] = classifiers, - mavenProfiles: Vector[String] = mavenProfiles, - scalaOrganization: Option[String] = scalaOrganization, - scalaVersion: Option[String] = scalaVersion, - authenticationByRepositoryId: Vector[(String, Authentication)] = authenticationByRepositoryId, - credentials: Seq[Credentials] = credentials, - logger: Option[CacheLogger] = logger, - cache: Option[File] = cache, - ivyHome: Option[File] = ivyHome, - followHttpToHttpsRedirections: Option[Boolean] = followHttpToHttpsRedirections, - strict: Option[Strict] = strict, - extraProjects: Vector[Project] = extraProjects, - forceVersions: Vector[(Module, String)] = forceVersions, - reconciliation: Vector[(ModuleMatchers, Reconciliation)] = reconciliation - ): CoursierConfiguration = - new CoursierConfiguration( - log, - resolvers, - parallelDownloads, - maxIterations, - sbtScalaOrganization, - sbtScalaVersion, - sbtScalaJars, - interProjectDependencies, - excludeDependencies, - fallbackDependencies, - autoScalaLibrary, - hasClassifiers, - classifiers, - mavenProfiles, - scalaOrganization, - scalaVersion, - authenticationByRepositoryId, - credentials, - logger, - cache, - ivyHome, - followHttpToHttpsRedirections, - strict, - extraProjects, - forceVersions, - reconciliation - ) - - def withLog(log: Option[Logger]): CoursierConfiguration = - copy(log = log) +@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 +) { def withLog(log: Logger): CoursierConfiguration = - copy(log = Option(log)) - - def withResolvers(resolvers: Vector[Resolver]): CoursierConfiguration = - copy(resolvers = resolvers) - - def withParallelDownloads(parallelDownloads: Int): CoursierConfiguration = - copy(parallelDownloads = parallelDownloads) - - def withMaxIterations(maxIterations: Int): CoursierConfiguration = - copy(maxIterations = maxIterations) - - def withSbtScalaOrganization(sbtScalaOrganization: Option[String]): CoursierConfiguration = - copy(sbtScalaOrganization = sbtScalaOrganization) - + withLog(Option(log)) def withSbtScalaOrganization(sbtScalaOrganization: String): CoursierConfiguration = - copy(sbtScalaOrganization = Option(sbtScalaOrganization)) - - def withSbtScalaVersion(sbtScalaVersion: Option[String]): CoursierConfiguration = - copy(sbtScalaVersion = sbtScalaVersion) - + withSbtScalaOrganization(Option(sbtScalaOrganization)) def withSbtScalaVersion(sbtScalaVersion: String): CoursierConfiguration = - copy(sbtScalaVersion = Option(sbtScalaVersion)) - - def withSbtScalaJars(sbtScalaJars: Vector[File]): CoursierConfiguration = - copy(sbtScalaJars = sbtScalaJars) - - def withInterProjectDependencies(interProjectDependencies: Vector[Project]): CoursierConfiguration = - copy(interProjectDependencies = interProjectDependencies) - - def withExcludeDependencies(excludeDependencies: Vector[(String, String)]): CoursierConfiguration = - copy(excludeDependencies = excludeDependencies) - - def withFallbackDependencies(fallbackDependencies: Vector[FallbackDependency]): CoursierConfiguration = - copy(fallbackDependencies = fallbackDependencies) - - def withAutoScalaLibrary(autoScalaLibrary: Boolean): CoursierConfiguration = - copy(autoScalaLibrary = autoScalaLibrary) - - def withHasClassifiers(hasClassifiers: Boolean): CoursierConfiguration = - copy(hasClassifiers = hasClassifiers) - - def withClassifiers(classifiers: Vector[String]): CoursierConfiguration = - copy(classifiers = classifiers) - - def withMavenProfiles(mavenProfiles: Vector[String]): CoursierConfiguration = - copy(mavenProfiles = mavenProfiles) - - def withScalaOrganization(scalaOrganization: Option[String]): CoursierConfiguration = - copy(scalaOrganization = scalaOrganization) - + withSbtScalaVersion(Option(sbtScalaVersion)) def withScalaOrganization(scalaOrganization: String): CoursierConfiguration = - copy(scalaOrganization = Option(scalaOrganization)) - - def withScalaVersion(scalaVersion: Option[String]): CoursierConfiguration = - copy(scalaVersion = scalaVersion) - + withScalaOrganization(Option(scalaOrganization)) def withScalaVersion(scalaVersion: String): CoursierConfiguration = - copy(scalaVersion = Option(scalaVersion)) - - def withAuthenticationByRepositoryId(authenticationByRepositoryId: Vector[(String, Authentication)]): CoursierConfiguration = - copy(authenticationByRepositoryId = authenticationByRepositoryId) - - def withCredentials(credentials: Seq[Credentials]): CoursierConfiguration = - copy(credentials = credentials) - - def withLogger(logger: Option[CacheLogger]): CoursierConfiguration = - copy(logger = logger) - + withScalaVersion(Option(scalaVersion)) def withLogger(logger: CacheLogger): CoursierConfiguration = - copy(logger = Option(logger)) - - def withCache(cache: Option[File]): CoursierConfiguration = - copy(cache = cache) - + withLogger(Option(logger)) def withCache(cache: File): CoursierConfiguration = - copy(cache = Option(cache)) - - def withIvyHome(ivyHomeOpt: Option[File]): CoursierConfiguration = - copy(ivyHome = ivyHomeOpt) + withCache(Option(cache)) def withIvyHome(ivyHome: File): CoursierConfiguration = - copy(ivyHome = Option(ivyHome)) - - def withFollowHttpToHttpsRedirections(followHttpToHttpsRedirectionsOpt: Option[Boolean]): CoursierConfiguration = - copy(followHttpToHttpsRedirections = followHttpToHttpsRedirectionsOpt) + withIvyHome(Option(ivyHome)) def withFollowHttpToHttpsRedirections(followHttpToHttpsRedirections: Boolean): CoursierConfiguration = - copy(followHttpToHttpsRedirections = Some(followHttpToHttpsRedirections)) + withFollowHttpToHttpsRedirections(Some(followHttpToHttpsRedirections)) def withFollowHttpToHttpsRedirections(): CoursierConfiguration = - copy(followHttpToHttpsRedirections = Some(true)) - + withFollowHttpToHttpsRedirections(Some(true)) def withStrict(strict: Strict): CoursierConfiguration = - copy(strict = Some(strict)) - def withStrict(strictOpt: Option[Strict]): CoursierConfiguration = - copy(strict = strictOpt) - - def withExtraProjects(extraProjects: Vector[Project]): CoursierConfiguration = - copy(extraProjects = extraProjects) - - def withForceVersions(forceVersions: Vector[(Module, String)]): CoursierConfiguration = - copy(forceVersions = forceVersions) - - def withReconciliation(reconciliation: Vector[(ModuleMatchers, Reconciliation)]): CoursierConfiguration = - copy(reconciliation = reconciliation) + withStrict(Some(strict)) } object CoursierConfiguration { - - def apply(): CoursierConfiguration = - new CoursierConfiguration() - - def apply( - log: Option[Logger], - resolvers: Vector[Resolver], - parallelDownloads: Int, - maxIterations: Int, - sbtScalaOrganization: Option[String], - sbtScalaVersion: Option[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: Option[String], - scalaVersion: Option[String], - authenticationByRepositoryId: Vector[(String, Authentication)], - credentials: Seq[Credentials], - logger: Option[CacheLogger], - cache: Option[File] - ): CoursierConfiguration = - new CoursierConfiguration( - log, - resolvers, - parallelDownloads, - maxIterations, - sbtScalaOrganization, - sbtScalaVersion, - sbtScalaJars, - interProjectDependencies, - excludeDependencies, - fallbackDependencies, - autoScalaLibrary, - hasClassifiers, - classifiers, - mavenProfiles, - scalaOrganization, - scalaVersion, - authenticationByRepositoryId, - credentials, - logger, - cache, - None, - None, - None, - Vector.empty, - Vector.empty, - Vector.empty - ) - def apply( log: Logger, resolvers: Vector[Resolver], - parallelDownloads: Int, - maxIterations: Int, - sbtScalaOrganization: String, - sbtScalaVersion: String, + parallelDownloads: Int, + maxIterations: Int, + sbtScalaOrganization: String, + sbtScalaVersion: String, sbtScalaJars: Vector[File], interProjectDependencies: Vector[Project], - excludeDependencies: Vector[(String, String)], + excludeDependencies: Vector[(String, String)], fallbackDependencies: Vector[FallbackDependency], - autoScalaLibrary: Boolean, - hasClassifiers: Boolean, - classifiers: Vector[String], - mavenProfiles: Vector[String], - scalaOrganization: String, - scalaVersion: String, + 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 = - new 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), - None, - None, - None, - Vector.empty, - Vector.empty, - Vector.empty - ) - - def apply( - log: Option[Logger], - resolvers: Vector[Resolver], - parallelDownloads: Int, - maxIterations: Int, - sbtScalaOrganization: Option[String], - sbtScalaVersion: Option[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: Option[String], - scalaVersion: Option[String], - authenticationByRepositoryId: Vector[(String, Authentication)], - credentials: Seq[Credentials], - logger: Option[CacheLogger], - cache: Option[File], - ivyHome: Option[File] - ): CoursierConfiguration = - new CoursierConfiguration( - log, + CoursierConfiguration( + Option(log), resolvers, parallelDownloads, maxIterations, - sbtScalaOrganization, - sbtScalaVersion, + Option(sbtScalaOrganization), + Option(sbtScalaVersion), sbtScalaJars, interProjectDependencies, excludeDependencies, @@ -556,17 +103,11 @@ object CoursierConfiguration { hasClassifiers, classifiers, mavenProfiles, - scalaOrganization, - scalaVersion, + Option(scalaOrganization), + Option(scalaVersion), authenticationByRepositoryId, credentials, - logger, - cache, - ivyHome, - None, - None, - Vector.empty, - Vector.empty, - Vector.empty + Option(logger), + Option(cache), ) } diff --git a/modules/lm-coursier/src/main/scala/lmcoursier/FallbackDependency.scala b/modules/lm-coursier/src/main/scala/lmcoursier/FallbackDependency.scala index b3c3e2d3f..8bd239b89 100644 --- a/modules/lm-coursier/src/main/scala/lmcoursier/FallbackDependency.scala +++ b/modules/lm-coursier/src/main/scala/lmcoursier/FallbackDependency.scala @@ -1,44 +1,13 @@ -/** - * This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. - */ - -// DO NOT EDIT MANUALLY package lmcoursier -final class FallbackDependency private ( - val module: lmcoursier.definitions.Module, - val version: String, - val url: java.net.URL, - val changing: Boolean) extends Serializable { - - - - override def equals(o: Any): Boolean = o match { - case x: FallbackDependency => (this.module == x.module) && (this.version == x.version) && (this.url == x.url) && (this.changing == x.changing) - case _ => false - } - override def hashCode: Int = { - 37 * (37 * (37 * (37 * (37 * (17 + "lmcoursier.FallbackDependency".##) + module.##) + version.##) + url.##) + changing.##) - } - override def toString: String = { - "FallbackDependency(" + module + ", " + version + ", " + url + ", " + changing + ")" - } - private[this] def copy(module: lmcoursier.definitions.Module = module, version: String = version, url: java.net.URL = url, changing: Boolean = changing): FallbackDependency = { - new FallbackDependency(module, version, url, changing) - } - def withModule(module: lmcoursier.definitions.Module): FallbackDependency = { - copy(module = module) - } - def withVersion(version: String): FallbackDependency = { - copy(version = version) - } - def withUrl(url: java.net.URL): FallbackDependency = { - copy(url = url) - } - def withChanging(changing: Boolean): FallbackDependency = { - copy(changing = changing) - } -} -object FallbackDependency { - - def apply(module: lmcoursier.definitions.Module, version: String, url: java.net.URL, changing: Boolean): FallbackDependency = new FallbackDependency(module, version, url, changing) -} + +import java.net.URL + +import dataclass.data +import lmcoursier.definitions.Module + +@data class FallbackDependency( + module: Module, + version: String, + url: URL, + changing: Boolean +) diff --git a/modules/lm-coursier/src/main/scala/lmcoursier/credentials/DirectCredentials.scala b/modules/lm-coursier/src/main/scala/lmcoursier/credentials/DirectCredentials.scala index d18b1bfe5..fa93f8bd1 100644 --- a/modules/lm-coursier/src/main/scala/lmcoursier/credentials/DirectCredentials.scala +++ b/modules/lm-coursier/src/main/scala/lmcoursier/credentials/DirectCredentials.scala @@ -1,62 +1,30 @@ package lmcoursier.credentials -final class DirectCredentials private( - val host: String, - val username: String, - val password: String, - val realm: Option[String], - val optional: Boolean, - val matchHost: Boolean, - val httpsOnly: Boolean +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 { - private def this() = this("", "", "", None, true, false, true) - private def this(host: String, username: String, password: String) = this(host, username, password, None, true, false, true) - private def this(host: String, username: String, password: String, realm: Option[String]) = this(host, username, password, realm, true, false, true) - private def this(host: String, username: String, password: String, realm: Option[String], optional: Boolean) = this(host, username, password, realm, optional, false, true) + def withRealm(realm: String): DirectCredentials = + withRealm(Option(realm)) - override def equals(o: Any): Boolean = o match { - case x: DirectCredentials => (this.host == x.host) && (this.username == x.username) && (this.password == x.password) && (this.realm == x.realm) && (this.optional == x.optional) && (this.matchHost == x.matchHost) && (this.httpsOnly == x.httpsOnly) - case _ => false - } - override def hashCode: Int = { - 37 * (37 * (37 * (37 * (37 * (37 * (37 * (37 * (17 + "lmcoursier.credentials.DirectCredentials".##) + host.##) + username.##) + password.##) + realm.##) + optional.##) + matchHost.##) + httpsOnly.##) - } - override def toString: String = { - "Credentials(" + host + ", " + username + ", " + "****" + ", " + realm + ", " + optional + ", " + matchHost + ", " + httpsOnly + ")" - } - private[this] def copy(host: String = host, username: String = username, password: String = password, realm: Option[String] = realm, optional: Boolean = optional, matchHost: Boolean = matchHost, httpsOnly: Boolean = httpsOnly): DirectCredentials = { - new DirectCredentials(host, username, password, realm, optional, matchHost, httpsOnly) - } - def withHost(host: String): DirectCredentials = { - copy(host = host) - } - def withUsername(username: String): DirectCredentials = { - copy(username = username) - } - def withPassword(password: String): DirectCredentials = { - copy(password = password) - } - def withRealm(realm: Option[String]): DirectCredentials = { - copy(realm = realm) - } - def withRealm(realm: String): DirectCredentials = { - copy(realm = Option(realm)) - } - def withOptional(optional: Boolean): DirectCredentials = { - copy(optional = optional) - } - def withMatchHost(matchHost: Boolean): DirectCredentials = - copy(matchHost = matchHost) - def withHttpsOnly(httpsOnly: Boolean): DirectCredentials = - copy(httpsOnly = httpsOnly) + override def toString(): String = + withPassword("****") + .productIterator + .mkString("DirectCredentials(", ", ", ")") } + object DirectCredentials { - - def apply(): DirectCredentials = new DirectCredentials() - def apply(host: String, username: String, password: String): DirectCredentials = new DirectCredentials(host, username, password) - def apply(host: String, username: String, password: String, realm: Option[String]): DirectCredentials = new DirectCredentials(host, username, password, realm) - def apply(host: String, username: String, password: String, realm: String): DirectCredentials = new DirectCredentials(host, username, password, Option(realm)) - def apply(host: String, username: String, password: String, realm: Option[String], optional: Boolean): DirectCredentials = new DirectCredentials(host, username, password, realm, optional) - def apply(host: String, username: String, password: String, realm: String, optional: Boolean): DirectCredentials = new 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: String, optional: Boolean): DirectCredentials = DirectCredentials(host, username, password, Option(realm), optional) } diff --git a/modules/lm-coursier/src/main/scala/lmcoursier/credentials/FileCredentials.scala b/modules/lm-coursier/src/main/scala/lmcoursier/credentials/FileCredentials.scala index 073bb9690..94a7b161b 100644 --- a/modules/lm-coursier/src/main/scala/lmcoursier/credentials/FileCredentials.scala +++ b/modules/lm-coursier/src/main/scala/lmcoursier/credentials/FileCredentials.scala @@ -1,34 +1,8 @@ package lmcoursier.credentials -final class FileCredentials private( - val path: String, - val optional: Boolean -) extends Credentials { +import dataclass.data - private def this(path: String) = this(path, true) - - override def equals(o: Any): Boolean = o match { - case x: FileCredentials => (this.path == x.path) && (this.optional == x.optional) - case _ => false - } - override def hashCode: Int = { - 37 * (37 * (37 * (17 + "lmcoursier.credentials.CredentialFile".##) + path.##) + optional.##) - } - override def toString: String = { - "CredentialFile(" + path + ", " + optional + ")" - } - private[this] def copy(path: String = path, optional: Boolean = optional): FileCredentials = { - new FileCredentials(path, optional) - } - def withPath(path: String): FileCredentials = { - copy(path = path) - } - def withOptional(optional: Boolean): FileCredentials = { - copy(optional = optional) - } -} -object FileCredentials { - - def apply(path: String): FileCredentials = new FileCredentials(path) - def apply(path: String, optional: Boolean): FileCredentials = new FileCredentials(path, optional) -} +@data class FileCredentials( + path: String, + optional: Boolean = true +) extends Credentials diff --git a/modules/lm-coursier/src/main/scala/lmcoursier/definitions/Attributes.scala b/modules/lm-coursier/src/main/scala/lmcoursier/definitions/Attributes.scala index 2daf0c1d1..331ba878d 100644 --- a/modules/lm-coursier/src/main/scala/lmcoursier/definitions/Attributes.scala +++ b/modules/lm-coursier/src/main/scala/lmcoursier/definitions/Attributes.scala @@ -1,35 +1,8 @@ package lmcoursier.definitions -final class Attributes private ( - val `type`: Type, - val classifier: Classifier -) { +import dataclass.data - override def equals(obj: Any): Boolean = - obj match { - case other: Attributes => - `type` == other.`type` && classifier == other.classifier - case _ => false - } - override def hashCode(): Int = - 37 * (37 * (37 * (17 + "lmcoursier.definitions.Attributes".##) + `type`.##) + classifier.##) - override def toString: String = - s"Attributes(${`type`}, $classifier)" - - private def copy( - `type`: Type = `type`, - classifier: Classifier = classifier - ): Attributes = - new Attributes(`type`, classifier) - - def withType(`type`: Type): Attributes = - copy(`type` = `type`) - def withClassifier(classifier: Classifier): Attributes = - copy(classifier = classifier) - -} - -object Attributes { - def apply(`type`: Type, classifier: Classifier): Attributes = - new Attributes(`type`, classifier) -} +@data class Attributes( + `type`: Type, + classifier: Classifier +) diff --git a/modules/lm-coursier/src/main/scala/lmcoursier/definitions/Authentication.scala b/modules/lm-coursier/src/main/scala/lmcoursier/definitions/Authentication.scala index 0aa6a3256..264b1ff5f 100644 --- a/modules/lm-coursier/src/main/scala/lmcoursier/definitions/Authentication.scala +++ b/modules/lm-coursier/src/main/scala/lmcoursier/definitions/Authentication.scala @@ -1,45 +1,15 @@ -/** - * This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. - */ - -// DO NOT EDIT MANUALLY package lmcoursier.definitions -final class Authentication private ( - val user: String, - val password: String, - val optional: Boolean, - val realmOpt: Option[String]) extends Serializable { - - private def this(user: String, password: String) = this(user, password, false, None) - - override def equals(o: Any): Boolean = o match { - case x: Authentication => (this.user == x.user) && (this.password == x.password) && (this.optional == x.optional) && (this.realmOpt == x.realmOpt) - case _ => false - } - override def hashCode: Int = { - 37 * (37 * (37 * (37 * (37 * (17 + "lmcoursier.definitions.Authentication".##) + user.##) + password.##) + optional.##) + realmOpt.##) - } - override def toString: String = { - "Authentication(" + user + ", " + password + ", " + optional + ", " + realmOpt + ")" - } - private[this] def copy(user: String = user, password: String = password, optional: Boolean = optional, realmOpt: Option[String] = realmOpt): Authentication = { - new Authentication(user, password, optional, realmOpt) - } - def withUser(user: String): Authentication = { - copy(user = user) - } - def withPassword(password: String): Authentication = { - copy(password = password) - } - def withOptional(optional: Boolean): Authentication = { - copy(optional = optional) - } - def withRealmOpt(realmOpt: Option[String]): Authentication = { - copy(realmOpt = realmOpt) - } -} -object Authentication { - - def apply(user: String, password: String): Authentication = new Authentication(user, password) - def apply(user: String, password: String, optional: Boolean, realmOpt: Option[String]): Authentication = new Authentication(user, password, optional, realmOpt) + +import dataclass.data + +@data class Authentication( + user: String, + password: String, + optional: Boolean = false, + realmOpt: Option[String] = None +) { + override def toString(): String = + withPassword("****") + .productIterator + .mkString("Authentication(", ", ", ")") } diff --git a/modules/lm-coursier/src/main/scala/lmcoursier/definitions/DateTime.scala b/modules/lm-coursier/src/main/scala/lmcoursier/definitions/DateTime.scala index 9ed52f54e..4507c2888 100644 --- a/modules/lm-coursier/src/main/scala/lmcoursier/definitions/DateTime.scala +++ b/modules/lm-coursier/src/main/scala/lmcoursier/definitions/DateTime.scala @@ -1,52 +1,12 @@ -/** - * This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. - */ - -// DO NOT EDIT MANUALLY package lmcoursier.definitions -final class DateTime private ( - val year: Int, - val month: Int, - val day: Int, - val hour: Int, - val minute: Int, - val second: Int) extends Serializable { - - - - override def equals(o: Any): Boolean = o match { - case x: DateTime => (this.year == x.year) && (this.month == x.month) && (this.day == x.day) && (this.hour == x.hour) && (this.minute == x.minute) && (this.second == x.second) - case _ => false - } - override def hashCode: Int = { - 37 * (37 * (37 * (37 * (37 * (37 * (37 * (17 + "lmcoursier.definitions.DateTime".##) + year.##) + month.##) + day.##) + hour.##) + minute.##) + second.##) - } - override def toString: String = { - "DateTime(" + year + ", " + month + ", " + day + ", " + hour + ", " + minute + ", " + second + ")" - } - private[this] def copy(year: Int = year, month: Int = month, day: Int = day, hour: Int = hour, minute: Int = minute, second: Int = second): DateTime = { - new DateTime(year, month, day, hour, minute, second) - } - def withYear(year: Int): DateTime = { - copy(year = year) - } - def withMonth(month: Int): DateTime = { - copy(month = month) - } - def withDay(day: Int): DateTime = { - copy(day = day) - } - def withHour(hour: Int): DateTime = { - copy(hour = hour) - } - def withMinute(minute: Int): DateTime = { - copy(minute = minute) - } - def withSecond(second: Int): DateTime = { - copy(second = second) - } -} -object DateTime { - - def apply(year: Int, month: Int, day: Int, hour: Int, minute: Int, second: Int): DateTime = new DateTime(year, month, day, hour, minute, second) -} + +import dataclass.data + +@data class DateTime( + year: Int, + month: Int, + day: Int, + hour: Int, + minute: Int, + second: Int +) diff --git a/modules/lm-coursier/src/main/scala/lmcoursier/definitions/Dependency.scala b/modules/lm-coursier/src/main/scala/lmcoursier/definitions/Dependency.scala index e9c6a2262..5021aadce 100644 --- a/modules/lm-coursier/src/main/scala/lmcoursier/definitions/Dependency.scala +++ b/modules/lm-coursier/src/main/scala/lmcoursier/definitions/Dependency.scala @@ -1,57 +1,42 @@ -/** - * This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. - */ - -// DO NOT EDIT MANUALLY package lmcoursier.definitions -final class Dependency private ( - val module: Module, - val version: String, - val configuration: Configuration, - val exclusions: Set[(Organization, ModuleName)], - val publication: Publication, - val optional: Boolean, - val transitive: Boolean) extends Serializable { + +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)) - - - override def equals(o: Any): Boolean = o match { - case x: Dependency => (this.module == x.module) && (this.version == x.version) && (this.configuration == x.configuration) && (this.exclusions == x.exclusions) && (this.publication == x.publication) && (this.optional == x.optional) && (this.transitive == x.transitive) - case _ => false - } - override def hashCode: Int = { - 37 * (37 * (37 * (37 * (37 * (37 * (37 * (37 * (17 + "lmcoursier.definitions.Dependency".##) + module.##) + version.##) + configuration.##) + exclusions.##) + publication.##) + optional.##) + transitive.##) - } - override def toString: String = { - "Dependency(" + module + ", " + version + ", " + configuration + ", " + exclusions + ", " + publication + ", " + optional + ", " + transitive + ")" - } - private[this] def copy(module: Module = module, version: String = version, configuration: Configuration = configuration, exclusions: Set[(Organization, ModuleName)] = exclusions, publication: Publication = publication, optional: Boolean = optional, transitive: Boolean = transitive): Dependency = { - new Dependency(module, version, configuration, exclusions, publication, optional, transitive) - } - def withModule(module: Module): Dependency = { - copy(module = module) - } - def withVersion(version: String): Dependency = { - copy(version = version) - } - def withConfiguration(configuration: Configuration): Dependency = { - copy(configuration = configuration) - } - def withExclusions(exclusions: Set[(Organization, ModuleName)]): Dependency = { - copy(exclusions = exclusions) - } - def withPublication(publication: Publication): Dependency = { - copy(publication = publication) - } - def withOptional(optional: Boolean): Dependency = { - copy(optional = optional) - } - def withTransitive(transitive: Boolean): Dependency = { - copy(transitive = transitive) - } + 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 = new Dependency(module, version, configuration, exclusions, Publication("", attributes.`type`, Extension(""), attributes.classifier), optional, transitive) - def apply(module: Module, version: String, configuration: Configuration, exclusions: Set[(Organization, ModuleName)], publication: Publication, optional: Boolean, transitive: Boolean): Dependency = new Dependency(module, version, configuration, exclusions, publication, optional, transitive) + 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 + ) } diff --git a/modules/lm-coursier/src/main/scala/lmcoursier/definitions/Developer.scala b/modules/lm-coursier/src/main/scala/lmcoursier/definitions/Developer.scala index 7aeaea870..759be7424 100644 --- a/modules/lm-coursier/src/main/scala/lmcoursier/definitions/Developer.scala +++ b/modules/lm-coursier/src/main/scala/lmcoursier/definitions/Developer.scala @@ -1,40 +1,9 @@ -/** - * This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. - */ - -// DO NOT EDIT MANUALLY package lmcoursier.definitions -final class Developer private ( - val id: String, - val name: String, - val url: String) extends Serializable { - - - - override def equals(o: Any): Boolean = o match { - case x: Developer => (this.id == x.id) && (this.name == x.name) && (this.url == x.url) - case _ => false - } - override def hashCode: Int = { - 37 * (37 * (37 * (37 * (17 + "lmcoursier.definitions.Developer".##) + id.##) + name.##) + url.##) - } - override def toString: String = { - "Developer(" + id + ", " + name + ", " + url + ")" - } - private[this] def copy(id: String = id, name: String = name, url: String = url): Developer = { - new Developer(id, name, url) - } - def withId(id: String): Developer = { - copy(id = id) - } - def withName(name: String): Developer = { - copy(name = name) - } - def withUrl(url: String): Developer = { - copy(url = url) - } -} -object Developer { - - def apply(id: String, name: String, url: String): Developer = new Developer(id, name, url) -} + +import dataclass.data + +@data class Developer( + id: String, + name: String, + url: String +) diff --git a/modules/lm-coursier/src/main/scala/lmcoursier/definitions/Info.scala b/modules/lm-coursier/src/main/scala/lmcoursier/definitions/Info.scala index 94bdabb37..51704a4c7 100644 --- a/modules/lm-coursier/src/main/scala/lmcoursier/definitions/Info.scala +++ b/modules/lm-coursier/src/main/scala/lmcoursier/definitions/Info.scala @@ -1,48 +1,11 @@ -/** - * This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. - */ - -// DO NOT EDIT MANUALLY package lmcoursier.definitions -final class Info private ( - val description: String, - val homePage: String, - val licenses: Seq[(String, Option[String])], - val developers: Seq[Developer], - val publication: Option[DateTime]) extends Serializable { - - - - override def equals(o: Any): Boolean = o match { - case x: Info => (this.description == x.description) && (this.homePage == x.homePage) && (this.licenses == x.licenses) && (this.developers == x.developers) && (this.publication == x.publication) - case _ => false - } - override def hashCode: Int = { - 37 * (37 * (37 * (37 * (37 * (37 * (17 + "lmcoursier.definitions.Info".##) + description.##) + homePage.##) + licenses.##) + developers.##) + publication.##) - } - override def toString: String = { - "Info(" + description + ", " + homePage + ", " + licenses + ", " + developers + ", " + publication + ")" - } - private[this] def copy(description: String = description, homePage: String = homePage, licenses: Seq[(String, Option[String])] = licenses, developers: Seq[Developer] = developers, publication: Option[DateTime] = publication): Info = { - new Info(description, homePage, licenses, developers, publication) - } - def withDescription(description: String): Info = { - copy(description = description) - } - def withHomePage(homePage: String): Info = { - copy(homePage = homePage) - } - def withLicenses(licenses: Seq[(String, Option[String])]): Info = { - copy(licenses = licenses) - } - def withDevelopers(developers: Seq[Developer]): Info = { - copy(developers = developers) - } - def withPublication(publication: Option[DateTime]): Info = { - copy(publication = publication) - } -} -object Info { - - def apply(description: String, homePage: String, licenses: Seq[(String, Option[String])], developers: Seq[Developer], publication: Option[DateTime]): Info = new Info(description, homePage, licenses, developers, publication) -} + +import dataclass.data + +@data class Info( + description: String, + homePage: String, + licenses: Seq[(String, Option[String])], + developers: Seq[Developer], + publication: Option[DateTime] +) diff --git a/modules/lm-coursier/src/main/scala/lmcoursier/definitions/Module.scala b/modules/lm-coursier/src/main/scala/lmcoursier/definitions/Module.scala index a843f9a0a..dfca023fd 100644 --- a/modules/lm-coursier/src/main/scala/lmcoursier/definitions/Module.scala +++ b/modules/lm-coursier/src/main/scala/lmcoursier/definitions/Module.scala @@ -1,40 +1,8 @@ -/** - * This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. - */ - -// DO NOT EDIT MANUALLY package lmcoursier.definitions -final class Module private ( - val organization: Organization, - val name: ModuleName, - val attributes: Map[String, String]) extends Serializable { - - - - override def equals(o: Any): Boolean = o match { - case x: Module => (this.organization == x.organization) && (this.name == x.name) && (this.attributes == x.attributes) - case _ => false - } - override def hashCode: Int = { - 37 * (37 * (37 * (37 * (17 + "lmcoursier.definitions.Module".##) + organization.##) + name.##) + attributes.##) - } - override def toString: String = { - "Module(" + organization + ", " + name + ", " + attributes + ")" - } - private[this] def copy(organization: Organization = organization, name: ModuleName = name, attributes: Map[String, String] = attributes): Module = { - new Module(organization, name, attributes) - } - def withOrganization(organization: Organization): Module = { - copy(organization = organization) - } - def withName(name: ModuleName): Module = { - copy(name = name) - } - def withAttributes(attributes: Map[String, String]): Module = { - copy(attributes = attributes) - } -} -object Module { - - def apply(organization: Organization, name: ModuleName, attributes: Map[String, String]): Module = new Module(organization, name, attributes) -} +import dataclass.data + +@data class Module( + organization: Organization, + name: ModuleName, + attributes: Map[String, String] +) diff --git a/modules/lm-coursier/src/main/scala/lmcoursier/definitions/ModuleMatchers.scala b/modules/lm-coursier/src/main/scala/lmcoursier/definitions/ModuleMatchers.scala index 2cdf51de8..9cb8e7f34 100644 --- a/modules/lm-coursier/src/main/scala/lmcoursier/definitions/ModuleMatchers.scala +++ b/modules/lm-coursier/src/main/scala/lmcoursier/definitions/ModuleMatchers.scala @@ -1,47 +1,20 @@ -/** - * This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. - */ - -// DO NOT EDIT MANUALLY 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. */ -final class ModuleMatchers private ( - val exclude: Set[lmcoursier.definitions.Module], - val include: Set[lmcoursier.definitions.Module], - val includeByDefault: Boolean) extends Serializable { - - private def this(exclude: Set[lmcoursier.definitions.Module], include: Set[lmcoursier.definitions.Module]) = this(exclude, include, true) - - override def equals(o: Any): Boolean = o match { - case x: ModuleMatchers => (this.exclude == x.exclude) && (this.include == x.include) && (this.includeByDefault == x.includeByDefault) - case _ => false - } - override def hashCode: Int = { - 37 * (37 * (37 * (37 * (17 + "lmcoursier.definitions.ModuleMatchers".##) + exclude.##) + include.##) + includeByDefault.##) - } - override def toString: String = { - "ModuleMatchers(" + exclude + ", " + include + ", " + includeByDefault + ")" - } - private[this] def copy(exclude: Set[lmcoursier.definitions.Module] = exclude, include: Set[lmcoursier.definitions.Module] = include, includeByDefault: Boolean = includeByDefault): ModuleMatchers = { - new ModuleMatchers(exclude, include, includeByDefault) - } - def withExclude(exclude: Set[lmcoursier.definitions.Module]): ModuleMatchers = { - copy(exclude = exclude) - } - def withInclude(include: Set[lmcoursier.definitions.Module]): ModuleMatchers = { - copy(include = include) - } - def withIncludeByDefault(includeByDefault: Boolean): ModuleMatchers = { - copy(includeByDefault = includeByDefault) - } -} +@data class ModuleMatchers( + exclude: Set[Module], + include: Set[Module], + includeByDefault: Boolean = true +) + object ModuleMatchers { - /** ModuleMatchers that matches to any modules. */ - def all: ModuleMatchers = ModuleMatchers(Set.empty, Set.empty) - def only(mod: Module): ModuleMatchers = ModuleMatchers(Set.empty, Set(mod), includeByDefault = false) - def apply(exclude: Set[lmcoursier.definitions.Module], include: Set[lmcoursier.definitions.Module]): ModuleMatchers = new ModuleMatchers(exclude, include) - def apply(exclude: Set[lmcoursier.definitions.Module], include: Set[lmcoursier.definitions.Module], includeByDefault: Boolean): ModuleMatchers = new ModuleMatchers(exclude, include, includeByDefault) + def all: ModuleMatchers = + ModuleMatchers(Set.empty, Set.empty) + def only(mod: Module): ModuleMatchers = + ModuleMatchers(Set.empty, Set(mod), includeByDefault = false) } diff --git a/modules/lm-coursier/src/main/scala/lmcoursier/definitions/Project.scala b/modules/lm-coursier/src/main/scala/lmcoursier/definitions/Project.scala index e2f466167..056a8706c 100644 --- a/modules/lm-coursier/src/main/scala/lmcoursier/definitions/Project.scala +++ b/modules/lm-coursier/src/main/scala/lmcoursier/definitions/Project.scala @@ -1,60 +1,14 @@ -/** - * This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. - */ - -// DO NOT EDIT MANUALLY package lmcoursier.definitions -final class Project private ( - val module: Module, - val version: String, - val dependencies: Seq[(Configuration, Dependency)], - val configurations: Map[Configuration, Seq[Configuration]], - val properties: Seq[(String, String)], - val packagingOpt: Option[Type], - val publications: Seq[(Configuration, Publication)], - val info: Info) extends Serializable { - - - - override def equals(o: Any): Boolean = o match { - case x: Project => (this.module == x.module) && (this.version == x.version) && (this.dependencies == x.dependencies) && (this.configurations == x.configurations) && (this.properties == x.properties) && (this.packagingOpt == x.packagingOpt) && (this.publications == x.publications) && (this.info == x.info) - case _ => false - } - override def hashCode: Int = { - 37 * (37 * (37 * (37 * (37 * (37 * (37 * (37 * (37 * (17 + "lmcoursier.definitions.Project".##) + module.##) + version.##) + dependencies.##) + configurations.##) + properties.##) + packagingOpt.##) + publications.##) + info.##) - } - override def toString: String = { - "Project(" + module + ", " + version + ", " + dependencies + ", " + configurations + ", " + properties + ", " + packagingOpt + ", " + publications + ", " + info + ")" - } - private[this] def copy(module: Module = module, version: String = version, dependencies: Seq[(Configuration, Dependency)] = dependencies, configurations: Map[Configuration, Seq[Configuration]] = configurations, properties: Seq[(String, String)] = properties, packagingOpt: Option[Type] = packagingOpt, publications: Seq[(Configuration, Publication)] = publications, info: Info = info): Project = { - new Project(module, version, dependencies, configurations, properties, packagingOpt, publications, info) - } - def withModule(module: Module): Project = { - copy(module = module) - } - def withVersion(version: String): Project = { - copy(version = version) - } - def withDependencies(dependencies: Seq[(Configuration, Dependency)]): Project = { - copy(dependencies = dependencies) - } - def withConfigurations(configurations: Map[Configuration, Seq[Configuration]]): Project = { - copy(configurations = configurations) - } - def withProperties(properties: Seq[(String, String)]): Project = { - copy(properties = properties) - } - def withPackagingOpt(packagingOpt: Option[Type]): Project = { - copy(packagingOpt = packagingOpt) - } - def withPublications(publications: Seq[(Configuration, Publication)]): Project = { - copy(publications = publications) - } - def withInfo(info: Info): Project = { - copy(info = info) - } -} -object Project { - - def apply(module: Module, version: String, dependencies: Seq[(Configuration, Dependency)], configurations: Map[Configuration, Seq[Configuration]], properties: Seq[(String, String)], packagingOpt: Option[Type], publications: Seq[(Configuration, Publication)], info: Info): Project = new Project(module, version, dependencies, configurations, properties, packagingOpt, publications, info) -} + +import dataclass.data + +@data class Project( + module: Module, + version: String, + dependencies: Seq[(Configuration, Dependency)], + configurations: Map[Configuration, Seq[Configuration]], + properties: Seq[(String, String)], + packagingOpt: Option[Type], + publications: Seq[(Configuration, Publication)], + info: Info +) diff --git a/modules/lm-coursier/src/main/scala/lmcoursier/definitions/Publication.scala b/modules/lm-coursier/src/main/scala/lmcoursier/definitions/Publication.scala index 44a7e997c..bb5f9e253 100644 --- a/modules/lm-coursier/src/main/scala/lmcoursier/definitions/Publication.scala +++ b/modules/lm-coursier/src/main/scala/lmcoursier/definitions/Publication.scala @@ -1,45 +1,16 @@ -/** - * This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. - */ - -// DO NOT EDIT MANUALLY package lmcoursier.definitions -final class Publication private ( - val name: String, - val `type`: Type, - val ext: Extension, - val classifier: Classifier) extends Serializable { - def attributes: Attributes = Attributes(`type`, classifier) - def withAttributes(attributes: Attributes): Publication = withType(attributes.`type`).withClassifier(attributes.classifier) - - - override def equals(o: Any): Boolean = o match { - case x: Publication => (this.name == x.name) && (this.`type` == x.`type`) && (this.ext == x.ext) && (this.classifier == x.classifier) - case _ => false - } - override def hashCode: Int = { - 37 * (37 * (37 * (37 * (37 * (17 + "lmcoursier.definitions.Publication".##) + name.##) + `type`.##) + ext.##) + classifier.##) - } - override def toString: String = { - "Publication(" + name + ", " + `type` + ", " + ext + ", " + classifier + ")" - } - private[this] def copy(name: String = name, `type`: Type = `type`, ext: Extension = ext, classifier: Classifier = classifier): Publication = { - new Publication(name, `type`, ext, classifier) - } - def withName(name: String): Publication = { - copy(name = name) - } - def withType(`type`: Type): Publication = { - copy(`type` = `type`) - } - def withExt(ext: Extension): Publication = { - copy(ext = ext) - } - def withClassifier(classifier: Classifier): Publication = { - copy(classifier = classifier) - } -} -object Publication { - - def apply(name: String, `type`: Type, ext: Extension, classifier: Classifier): Publication = new Publication(name, `type`, ext, classifier) + +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) } diff --git a/modules/lm-coursier/src/main/scala/lmcoursier/definitions/Reconciliation.scala b/modules/lm-coursier/src/main/scala/lmcoursier/definitions/Reconciliation.scala index d095ba6e0..9fc6fe2d9 100644 --- a/modules/lm-coursier/src/main/scala/lmcoursier/definitions/Reconciliation.scala +++ b/modules/lm-coursier/src/main/scala/lmcoursier/definitions/Reconciliation.scala @@ -1,5 +1,7 @@ package lmcoursier.definitions + sealed abstract class Reconciliation extends Serializable + object Reconciliation { case object Default extends Reconciliation case object Relaxed extends Reconciliation diff --git a/modules/lm-coursier/src/main/scala/lmcoursier/definitions/Strict.scala b/modules/lm-coursier/src/main/scala/lmcoursier/definitions/Strict.scala index c1ea79afc..f40eed74a 100644 --- a/modules/lm-coursier/src/main/scala/lmcoursier/definitions/Strict.scala +++ b/modules/lm-coursier/src/main/scala/lmcoursier/definitions/Strict.scala @@ -1,55 +1,14 @@ package lmcoursier.definitions -final class Strict private ( - val include: Set[(String, String)], - val exclude: Set[(String, String)], - val ignoreIfForcedVersion: Boolean +import dataclass.data + +@data class Strict( + include: Set[(String, String)] = Set(("*", "*")), + exclude: Set[(String, String)] = Set.empty, + ignoreIfForcedVersion: Boolean = true ) { - - override def equals(obj: Any): Boolean = - obj match { - case other: Strict => - include == other.include && - exclude == other.exclude && - ignoreIfForcedVersion == other.ignoreIfForcedVersion - case _ => - false - } - - override def hashCode(): Int = { - var code = 17 + "lmcoursier.definitions.Strict".## - code = 37 * code + include.## - code = 37 * code + exclude.## - code = 37 * code + ignoreIfForcedVersion.## - 37 * code - } - - override def toString: String = - s"Strict($include, $exclude, $ignoreIfForcedVersion)" - - private def copy( - include: Set[(String, String)] = include, - exclude: Set[(String, String)] = exclude, - ignoreIfForcedVersion: Boolean = ignoreIfForcedVersion - ): Strict = - new Strict(include, exclude, ignoreIfForcedVersion) - - - def withInclude(include: Set[(String, String)]): Strict = - copy(include = include) def addInclude(include: (String, String)*): Strict = - copy(include = this.include ++ include) - - def withExclude(exclude: Set[(String, String)]): Strict = - copy(exclude = exclude) + withInclude(this.include ++ include) def addExclude(exclude: (String, String)*): Strict = - copy(exclude = this.exclude ++ exclude) - - def withIgnoreIfForcedVersion(ignoreIfForcedVersion: Boolean): Strict = - copy(ignoreIfForcedVersion = ignoreIfForcedVersion) -} - -object Strict { - def apply(): Strict = - new Strict(Set(("*", "*")), Set.empty, ignoreIfForcedVersion = true) + withExclude(this.exclude ++ exclude) } diff --git a/project/Settings.scala b/project/Settings.scala index 313d0f3a1..052320c73 100644 --- a/project/Settings.scala +++ b/project/Settings.scala @@ -14,6 +14,11 @@ object Settings { def sbt10Version = "1.0.2" + private lazy val isAtLeastScala213 = Def.setting { + import Ordering.Implicits._ + CrossVersion.partialVersion(scalaVersion.value).exists(_ >= (2, 13)) + } + lazy val shared = Seq( resolvers += Resolver.sonatypeRepo("releases"), crossScalaVersions := Seq(scala212), @@ -23,7 +28,15 @@ object Settings { "-deprecation", "-language:higherKinds", "-language:implicitConversions" - ) + ), + libraryDependencies ++= { + if (isAtLeastScala213.value) Nil + else Seq(compilerPlugin("org.scalamacros" % s"paradise" % "2.1.1" cross CrossVersion.full)) + }, + scalacOptions ++= { + if (isAtLeastScala213.value) Seq("-Ymacro-annotations") + else Nil + } ) ++ { val prop = sys.props.getOrElse("publish.javadoc", "").toLowerCase(Locale.ROOT) if (prop == "0" || prop == "false") diff --git a/project/plugins.sbt b/project/plugins.sbt index ad1338223..44a03f0ef 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,17 +1,7 @@ - -plugins_( - "com.geirsson" % "sbt-ci-release" % "1.4.31", - "com.typesafe" % "sbt-mima-plugin" % "0.3.0", - "org.scala-sbt" % "sbt-contraband" % "0.4.4" -) - -libs ++= Seq( - "org.scala-sbt" %% "scripted-plugin" % sbtVersion.value -) +addSbtPlugin("com.geirsson" % "sbt-ci-release" % "1.4.31") +addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "0.3.0") addSbtPlugin("io.get-coursier" % "sbt-coursier" % "2.0.0-RC4") addSbtPlugin("io.get-coursier" % "sbt-shading" % "2.0.0-RC4") - -def plugins_(modules: ModuleID*) = modules.map(addSbtPlugin) -def libs = libraryDependencies +libraryDependencies += "org.scala-sbt" %% "scripted-plugin" % sbtVersion.value