From d94503446ea28507d2a59e5d4c0e632ac52f5649 Mon Sep 17 00:00:00 2001 From: Alexandre Archambault Date: Tue, 14 May 2019 11:43:04 +0200 Subject: [PATCH 1/3] Make CoursierConfiguration easier to edit --- .../lmcoursier/CoursierConfiguration.scala | 366 ++++++++++++++---- 1 file changed, 286 insertions(+), 80 deletions(-) diff --git a/modules/lm-coursier/src/main/scala/lmcoursier/CoursierConfiguration.scala b/modules/lm-coursier/src/main/scala/lmcoursier/CoursierConfiguration.scala index c7a08440c..2c24538df 100644 --- a/modules/lm-coursier/src/main/scala/lmcoursier/CoursierConfiguration.scala +++ b/modules/lm-coursier/src/main/scala/lmcoursier/CoursierConfiguration.scala @@ -1,131 +1,337 @@ /** - * This code is generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. + * This code USED TO BE generated using [[http://www.scala-sbt.org/contraband/ sbt-contraband]]. */ -// DO NOT EDIT MANUALLY +// DO EDIT MANUALLY from now on package lmcoursier + +import java.io.File + +import lmcoursier.credentials.Credentials +import lmcoursier.definitions.{Authentication, CacheLogger, Project} +import sbt.librarymanagement.Resolver +import xsbti.Logger + final class CoursierConfiguration private ( - val log: Option[xsbti.Logger], - val resolvers: Vector[sbt.librarymanagement.Resolver], + 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[java.io.File], - val interProjectDependencies: Vector[lmcoursier.definitions.Project], + val sbtScalaJars: Vector[File], + val interProjectDependencies: Vector[Project], val excludeDependencies: Vector[(String, String)], - val fallbackDependencies: Vector[lmcoursier.FallbackDependency], + 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, lmcoursier.definitions.Authentication)], - val credentials: Seq[lmcoursier.credentials.Credentials], - val logger: Option[lmcoursier.definitions.CacheLogger], - val cache: Option[java.io.File]) extends Serializable { + val authenticationByRepositoryId: Vector[(String, Authentication)], + val credentials: Seq[Credentials], + val logger: Option[CacheLogger], + val cache: Option[File] +) extends Serializable { - private def this() = this(None, sbt.librarymanagement.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) + 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 + ) - override def equals(o: Any): Boolean = o match { - case x: CoursierConfiguration => (this.log == x.log) && (this.resolvers == x.resolvers) && (this.parallelDownloads == x.parallelDownloads) && (this.maxIterations == x.maxIterations) && (this.sbtScalaOrganization == x.sbtScalaOrganization) && (this.sbtScalaVersion == x.sbtScalaVersion) && (this.sbtScalaJars == x.sbtScalaJars) && (this.interProjectDependencies == x.interProjectDependencies) && (this.excludeDependencies == x.excludeDependencies) && (this.fallbackDependencies == x.fallbackDependencies) && (this.autoScalaLibrary == x.autoScalaLibrary) && (this.hasClassifiers == x.hasClassifiers) && (this.classifiers == x.classifiers) && (this.mavenProfiles == x.mavenProfiles) && (this.scalaOrganization == x.scalaOrganization) && (this.scalaVersion == x.scalaVersion) && (this.authenticationByRepositoryId == x.authenticationByRepositoryId) && (this.credentials == x.credentials) && (this.logger == x.logger) && (this.cache == x.cache) - case _ => false - } + 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 + case _ => false + } + override def hashCode: Int = { - 37 * (37 * (37 * (37 * (37 * (37 * (37 * (37 * (37 * (37 * (37 * (37 * (37 * (37 * (37 * (37 * (37 * (37 * (37 * (37 * (37 * (17 + "lmcoursier.CoursierConfiguration".##) + log.##) + resolvers.##) + parallelDownloads.##) + maxIterations.##) + sbtScalaOrganization.##) + sbtScalaVersion.##) + sbtScalaJars.##) + interProjectDependencies.##) + excludeDependencies.##) + fallbackDependencies.##) + autoScalaLibrary.##) + hasClassifiers.##) + classifiers.##) + mavenProfiles.##) + scalaOrganization.##) + scalaVersion.##) + authenticationByRepositoryId.##) + credentials.##) + logger.##) + cache.##) + 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 } - override def toString: String = { - "CoursierConfiguration(" + log + ", " + resolvers + ", " + parallelDownloads + ", " + maxIterations + ", " + sbtScalaOrganization + ", " + sbtScalaVersion + ", " + sbtScalaJars + ", " + interProjectDependencies + ", " + excludeDependencies + ", " + fallbackDependencies + ", " + autoScalaLibrary + ", " + hasClassifiers + ", " + classifiers + ", " + mavenProfiles + ", " + scalaOrganization + ", " + scalaVersion + ", " + authenticationByRepositoryId + ", " + credentials + ", " + logger + ", " + cache + ")" - } - private[this] def copy(log: Option[xsbti.Logger] = log, resolvers: Vector[sbt.librarymanagement.Resolver] = resolvers, parallelDownloads: Int = parallelDownloads, maxIterations: Int = maxIterations, sbtScalaOrganization: Option[String] = sbtScalaOrganization, sbtScalaVersion: Option[String] = sbtScalaVersion, sbtScalaJars: Vector[java.io.File] = sbtScalaJars, interProjectDependencies: Vector[lmcoursier.definitions.Project] = interProjectDependencies, excludeDependencies: Vector[(String, String)] = excludeDependencies, fallbackDependencies: Vector[lmcoursier.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, lmcoursier.definitions.Authentication)] = authenticationByRepositoryId, credentials: Seq[lmcoursier.credentials.Credentials] = credentials, logger: Option[lmcoursier.definitions.CacheLogger] = logger, cache: Option[java.io.File] = cache): CoursierConfiguration = { - new CoursierConfiguration(log, resolvers, parallelDownloads, maxIterations, sbtScalaOrganization, sbtScalaVersion, sbtScalaJars, interProjectDependencies, excludeDependencies, fallbackDependencies, autoScalaLibrary, hasClassifiers, classifiers, mavenProfiles, scalaOrganization, scalaVersion, authenticationByRepositoryId, credentials, logger, cache) - } - def withLog(log: Option[xsbti.Logger]): CoursierConfiguration = { + + 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)" + + 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 + ): CoursierConfiguration = + new CoursierConfiguration( + log, + resolvers, + parallelDownloads, + maxIterations, + sbtScalaOrganization, + sbtScalaVersion, + sbtScalaJars, + interProjectDependencies, + excludeDependencies, + fallbackDependencies, + autoScalaLibrary, + hasClassifiers, + classifiers, + mavenProfiles, + scalaOrganization, + scalaVersion, + authenticationByRepositoryId, + credentials, + logger, + cache + ) + + def withLog(log: Option[Logger]): CoursierConfiguration = copy(log = log) - } - def withLog(log: xsbti.Logger): CoursierConfiguration = { + + def withLog(log: Logger): CoursierConfiguration = copy(log = Option(log)) - } - def withResolvers(resolvers: Vector[sbt.librarymanagement.Resolver]): CoursierConfiguration = { + + def withResolvers(resolvers: Vector[Resolver]): CoursierConfiguration = copy(resolvers = resolvers) - } - def withParallelDownloads(parallelDownloads: Int): CoursierConfiguration = { + + def withParallelDownloads(parallelDownloads: Int): CoursierConfiguration = copy(parallelDownloads = parallelDownloads) - } - def withMaxIterations(maxIterations: Int): CoursierConfiguration = { + + def withMaxIterations(maxIterations: Int): CoursierConfiguration = copy(maxIterations = maxIterations) - } - def withSbtScalaOrganization(sbtScalaOrganization: Option[String]): CoursierConfiguration = { + + def withSbtScalaOrganization(sbtScalaOrganization: Option[String]): CoursierConfiguration = copy(sbtScalaOrganization = sbtScalaOrganization) - } - def withSbtScalaOrganization(sbtScalaOrganization: String): CoursierConfiguration = { + + def withSbtScalaOrganization(sbtScalaOrganization: String): CoursierConfiguration = copy(sbtScalaOrganization = Option(sbtScalaOrganization)) - } - def withSbtScalaVersion(sbtScalaVersion: Option[String]): CoursierConfiguration = { + + def withSbtScalaVersion(sbtScalaVersion: Option[String]): CoursierConfiguration = copy(sbtScalaVersion = sbtScalaVersion) - } - def withSbtScalaVersion(sbtScalaVersion: String): CoursierConfiguration = { + + def withSbtScalaVersion(sbtScalaVersion: String): CoursierConfiguration = copy(sbtScalaVersion = Option(sbtScalaVersion)) - } - def withSbtScalaJars(sbtScalaJars: Vector[java.io.File]): CoursierConfiguration = { + + def withSbtScalaJars(sbtScalaJars: Vector[File]): CoursierConfiguration = copy(sbtScalaJars = sbtScalaJars) - } - def withInterProjectDependencies(interProjectDependencies: Vector[lmcoursier.definitions.Project]): CoursierConfiguration = { + + def withInterProjectDependencies(interProjectDependencies: Vector[Project]): CoursierConfiguration = copy(interProjectDependencies = interProjectDependencies) - } - def withExcludeDependencies(excludeDependencies: Vector[(String, String)]): CoursierConfiguration = { + + def withExcludeDependencies(excludeDependencies: Vector[(String, String)]): CoursierConfiguration = copy(excludeDependencies = excludeDependencies) - } - def withFallbackDependencies(fallbackDependencies: Vector[lmcoursier.FallbackDependency]): CoursierConfiguration = { + + def withFallbackDependencies(fallbackDependencies: Vector[FallbackDependency]): CoursierConfiguration = copy(fallbackDependencies = fallbackDependencies) - } - def withAutoScalaLibrary(autoScalaLibrary: Boolean): CoursierConfiguration = { + + def withAutoScalaLibrary(autoScalaLibrary: Boolean): CoursierConfiguration = copy(autoScalaLibrary = autoScalaLibrary) - } - def withHasClassifiers(hasClassifiers: Boolean): CoursierConfiguration = { + + def withHasClassifiers(hasClassifiers: Boolean): CoursierConfiguration = copy(hasClassifiers = hasClassifiers) - } - def withClassifiers(classifiers: Vector[String]): CoursierConfiguration = { + + def withClassifiers(classifiers: Vector[String]): CoursierConfiguration = copy(classifiers = classifiers) - } - def withMavenProfiles(mavenProfiles: Vector[String]): CoursierConfiguration = { + + def withMavenProfiles(mavenProfiles: Vector[String]): CoursierConfiguration = copy(mavenProfiles = mavenProfiles) - } - def withScalaOrganization(scalaOrganization: Option[String]): CoursierConfiguration = { + + def withScalaOrganization(scalaOrganization: Option[String]): CoursierConfiguration = copy(scalaOrganization = scalaOrganization) - } - def withScalaOrganization(scalaOrganization: String): CoursierConfiguration = { + + def withScalaOrganization(scalaOrganization: String): CoursierConfiguration = copy(scalaOrganization = Option(scalaOrganization)) - } - def withScalaVersion(scalaVersion: Option[String]): CoursierConfiguration = { + + def withScalaVersion(scalaVersion: Option[String]): CoursierConfiguration = copy(scalaVersion = scalaVersion) - } - def withScalaVersion(scalaVersion: String): CoursierConfiguration = { + + def withScalaVersion(scalaVersion: String): CoursierConfiguration = copy(scalaVersion = Option(scalaVersion)) - } - def withAuthenticationByRepositoryId(authenticationByRepositoryId: Vector[(String, lmcoursier.definitions.Authentication)]): CoursierConfiguration = { + + def withAuthenticationByRepositoryId(authenticationByRepositoryId: Vector[(String, Authentication)]): CoursierConfiguration = copy(authenticationByRepositoryId = authenticationByRepositoryId) - } - def withCredentials(credentials: Seq[lmcoursier.credentials.Credentials]): CoursierConfiguration = { + + def withCredentials(credentials: Seq[Credentials]): CoursierConfiguration = copy(credentials = credentials) - } - def withLogger(logger: Option[lmcoursier.definitions.CacheLogger]): CoursierConfiguration = { + + def withLogger(logger: Option[CacheLogger]): CoursierConfiguration = copy(logger = logger) - } - def withLogger(logger: lmcoursier.definitions.CacheLogger): CoursierConfiguration = { + + def withLogger(logger: CacheLogger): CoursierConfiguration = copy(logger = Option(logger)) - } - def withCache(cache: Option[java.io.File]): CoursierConfiguration = { + + def withCache(cache: Option[File]): CoursierConfiguration = copy(cache = cache) - } - def withCache(cache: java.io.File): CoursierConfiguration = { + + def withCache(cache: File): CoursierConfiguration = copy(cache = Option(cache)) - } } + 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 + ) - def apply(): CoursierConfiguration = new CoursierConfiguration() - def apply(log: Option[xsbti.Logger], resolvers: Vector[sbt.librarymanagement.Resolver], parallelDownloads: Int, maxIterations: Int, sbtScalaOrganization: Option[String], sbtScalaVersion: Option[String], sbtScalaJars: Vector[java.io.File], interProjectDependencies: Vector[lmcoursier.definitions.Project], excludeDependencies: Vector[(String, String)], fallbackDependencies: Vector[lmcoursier.FallbackDependency], autoScalaLibrary: Boolean, hasClassifiers: Boolean, classifiers: Vector[String], mavenProfiles: Vector[String], scalaOrganization: Option[String], scalaVersion: Option[String], authenticationByRepositoryId: Vector[(String, lmcoursier.definitions.Authentication)], credentials: Seq[lmcoursier.credentials.Credentials], logger: Option[lmcoursier.definitions.CacheLogger], cache: Option[java.io.File]): CoursierConfiguration = new CoursierConfiguration(log, resolvers, parallelDownloads, maxIterations, sbtScalaOrganization, sbtScalaVersion, sbtScalaJars, interProjectDependencies, excludeDependencies, fallbackDependencies, autoScalaLibrary, hasClassifiers, classifiers, mavenProfiles, scalaOrganization, scalaVersion, authenticationByRepositoryId, credentials, logger, cache) - def apply(log: xsbti.Logger, resolvers: Vector[sbt.librarymanagement.Resolver], parallelDownloads: Int, maxIterations: Int, sbtScalaOrganization: String, sbtScalaVersion: String, sbtScalaJars: Vector[java.io.File], interProjectDependencies: Vector[lmcoursier.definitions.Project], excludeDependencies: Vector[(String, String)], fallbackDependencies: Vector[lmcoursier.FallbackDependency], autoScalaLibrary: Boolean, hasClassifiers: Boolean, classifiers: Vector[String], mavenProfiles: Vector[String], scalaOrganization: String, scalaVersion: String, authenticationByRepositoryId: Vector[(String, lmcoursier.definitions.Authentication)], credentials: Seq[lmcoursier.credentials.Credentials], logger: lmcoursier.definitions.CacheLogger, cache: java.io.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)) + 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 = + 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) + ) } From 87f812d6f3cd84fbfc5d9b53c8e5d76bd9f6a49a Mon Sep 17 00:00:00 2001 From: Alexandre Archambault Date: Tue, 14 May 2019 16:32:54 +0200 Subject: [PATCH 2/3] Switch to coursier sbt-launcher 1.2.11 Has fixes for ivy paths handling in particular --- .travis.yml | 2 +- appveyor.yml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index e19d1e1fe..6fab13978 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,7 @@ git: depth: false # https://stackoverflow.com/a/51727114/3714539 before_install: - mkdir .bin - - curl -Lo .bin/sbt https://github.com/coursier/sbt-extras/raw/5fb3c11d689d5aad1ead8c2ecf02e1177e5d6a88/sbt + - curl -Lo .bin/sbt https://raw.githubusercontent.com/coursier/sbt-extras/79b6cd6e0869ea04c4ba3c1e9666ae61401244ff/sbt - chmod +x .bin/sbt - export PATH="$(pwd)/.bin:$PATH" - export TRAVIS_SCALA_VERSION=2.12.8 diff --git a/appveyor.yml b/appveyor.yml index f4786bc9b..77c4c7ee2 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -3,8 +3,8 @@ version: '{build}' os: Windows Server 2012 install: - cmd: mkdir C:\sbt - - cmd: curl -Lo C:\sbt\sbt https://github.com/coursier/sbt-launcher/releases/download/v1.2.9/csbt - - cmd: curl -Lo C:\sbt\sbt.bat https://github.com/coursier/sbt-launcher/releases/download/v1.2.9/csbt.bat + - cmd: curl -Lo C:\sbt\sbt https://github.com/coursier/sbt-launcher/releases/download/v1.2.11/csbt + - cmd: curl -Lo C:\sbt\sbt.bat https://github.com/coursier/sbt-launcher/releases/download/v1.2.11/csbt.bat - cmd: SET JAVA_HOME=C:\Program Files\Java\jdk1.8.0 - cmd: SET PATH=C:\sbt;%JAVA_HOME%\bin;%PATH% - cmd: SET JAVA_OPTS=-Xmx4g -Xss2m From 54368093231a3706e0542ec30401b294f147e87b Mon Sep 17 00:00:00 2001 From: Alexandre Archambault Date: Tue, 14 May 2019 13:31:12 +0200 Subject: [PATCH 3/3] Take ivyPaths into account --- .../lmcoursier/CoursierConfiguration.scala | 74 +++++++++++++++++-- .../CoursierDependencyResolution.scala | 2 +- .../internal/ResolutionParams.scala | 10 +-- .../sbtcoursier/ResolutionTasks.scala | 2 +- .../src/sbt-test/sbt-coursier/s3/build.sbt | 4 +- .../sbt-test/shared-1/cache-local/README.md | 1 + .../sbt-test/shared-1/cache-local/cache.sbt | 1 + .../shared-1/cache-local/changes/def.sbt | 7 ++ .../shared-1/cache-local/changes/resolver.sbt | 5 ++ .../shared-1/cache-local/changes/use.sbt | 9 +++ .../shared-1/cache-local/project/plugins.sbt | 13 ++++ .../src/sbt-test/shared-1/cache-local/test | 21 ++++++ .../sbtlmcoursier/LmCoursierPlugin.scala | 3 +- 13 files changed, 136 insertions(+), 16 deletions(-) create mode 100644 modules/sbt-coursier/src/sbt-test/shared-1/cache-local/README.md create mode 100644 modules/sbt-coursier/src/sbt-test/shared-1/cache-local/cache.sbt create mode 100644 modules/sbt-coursier/src/sbt-test/shared-1/cache-local/changes/def.sbt create mode 100644 modules/sbt-coursier/src/sbt-test/shared-1/cache-local/changes/resolver.sbt create mode 100644 modules/sbt-coursier/src/sbt-test/shared-1/cache-local/changes/use.sbt create mode 100644 modules/sbt-coursier/src/sbt-test/shared-1/cache-local/project/plugins.sbt create mode 100644 modules/sbt-coursier/src/sbt-test/shared-1/cache-local/test diff --git a/modules/lm-coursier/src/main/scala/lmcoursier/CoursierConfiguration.scala b/modules/lm-coursier/src/main/scala/lmcoursier/CoursierConfiguration.scala index 2c24538df..e1241d623 100644 --- a/modules/lm-coursier/src/main/scala/lmcoursier/CoursierConfiguration.scala +++ b/modules/lm-coursier/src/main/scala/lmcoursier/CoursierConfiguration.scala @@ -32,7 +32,8 @@ final class CoursierConfiguration private ( val authenticationByRepositoryId: Vector[(String, Authentication)], val credentials: Seq[Credentials], val logger: Option[CacheLogger], - val cache: Option[File] + val cache: Option[File], + val ivyHome: Option[File] ) extends Serializable { private def this() = @@ -56,6 +57,7 @@ final class CoursierConfiguration private ( Vector.empty, Vector.empty, None, + None, None ) @@ -81,7 +83,8 @@ final class CoursierConfiguration private ( authenticationByRepositoryId == other.authenticationByRepositoryId && credentials == other.credentials && logger == other.logger && - cache == other.cache + cache == other.cache && + ivyHome == other.ivyHome case _ => false } @@ -107,11 +110,12 @@ final class CoursierConfiguration private ( code = 37 * (code + credentials.##) code = 37 * (code + logger.##) code = 37 * (code + cache.##) + code = 37 * (code + ivyHome.##) 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)" + s"CoursierConfiguration($log, $resolvers, $parallelDownloads, $maxIterations, $sbtScalaOrganization, $sbtScalaVersion, $sbtScalaJars, $interProjectDependencies, $excludeDependencies, $fallbackDependencies, $autoScalaLibrary, $hasClassifiers, $classifiers, $mavenProfiles, $scalaOrganization, $scalaVersion, $authenticationByRepositoryId, $credentials, $logger, $cache, $ivyHome)" private[this] def copy( log: Option[Logger] = log, @@ -133,7 +137,8 @@ final class CoursierConfiguration private ( authenticationByRepositoryId: Vector[(String, Authentication)] = authenticationByRepositoryId, credentials: Seq[Credentials] = credentials, logger: Option[CacheLogger] = logger, - cache: Option[File] = cache + cache: Option[File] = cache, + ivyHome: Option[File] = ivyHome ): CoursierConfiguration = new CoursierConfiguration( log, @@ -155,7 +160,8 @@ final class CoursierConfiguration private ( authenticationByRepositoryId, credentials, logger, - cache + cache, + ivyHome ) def withLog(log: Option[Logger]): CoursierConfiguration = @@ -238,6 +244,11 @@ final class CoursierConfiguration private ( def withCache(cache: File): CoursierConfiguration = copy(cache = Option(cache)) + + def withIvyHome(ivyHomeOpt: Option[File]): CoursierConfiguration = + copy(ivyHome = ivyHomeOpt) + def withIvyHome(ivyHome: File): CoursierConfiguration = + copy(ivyHome = Option(ivyHome)) } object CoursierConfiguration { @@ -287,7 +298,8 @@ object CoursierConfiguration { authenticationByRepositoryId, credentials, logger, - cache + cache, + None ) def apply( @@ -332,6 +344,54 @@ object CoursierConfiguration { authenticationByRepositoryId, credentials, Option(logger), - Option(cache) + Option(cache), + None + ) + + 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, + resolvers, + parallelDownloads, + maxIterations, + sbtScalaOrganization, + sbtScalaVersion, + sbtScalaJars, + interProjectDependencies, + excludeDependencies, + fallbackDependencies, + autoScalaLibrary, + hasClassifiers, + classifiers, + mavenProfiles, + scalaOrganization, + scalaVersion, + authenticationByRepositoryId, + credentials, + logger, + cache, + ivyHome ) } diff --git a/modules/lm-coursier/src/main/scala/lmcoursier/CoursierDependencyResolution.scala b/modules/lm-coursier/src/main/scala/lmcoursier/CoursierDependencyResolution.scala index b8a327682..0e0541df3 100644 --- a/modules/lm-coursier/src/main/scala/lmcoursier/CoursierDependencyResolution.scala +++ b/modules/lm-coursier/src/main/scala/lmcoursier/CoursierDependencyResolution.scala @@ -74,7 +74,7 @@ class CoursierDependencyResolution(conf: CoursierConfiguration) extends Dependen val checksums = CacheDefaults.checksums val projectName = "" // used for logging only… - val ivyProperties = ResolutionParams.defaultIvyProperties() + val ivyProperties = ResolutionParams.defaultIvyProperties(conf.ivyHome) val classifiers = if (conf.hasClassifiers) diff --git a/modules/lm-coursier/src/main/scala/lmcoursier/internal/ResolutionParams.scala b/modules/lm-coursier/src/main/scala/lmcoursier/internal/ResolutionParams.scala index 69e807d79..281b18edf 100644 --- a/modules/lm-coursier/src/main/scala/lmcoursier/internal/ResolutionParams.scala +++ b/modules/lm-coursier/src/main/scala/lmcoursier/internal/ResolutionParams.scala @@ -84,12 +84,12 @@ object ResolutionParams { private def cacheKey(cache: FileCache[Task]): Object = m.invoke(cache) - def defaultIvyProperties(): Map[String, String] = { + def defaultIvyProperties(ivyHomeOpt: Option[File]): Map[String, String] = { - val ivyHome = sys.props.getOrElse( - "ivy.home", - new File(sys.props("user.home")).toURI.getPath + ".ivy2" - ) + val ivyHome = sys.props + .get("ivy.home") + .orElse(ivyHomeOpt.map(_.getAbsoluteFile.toURI.getPath)) + .getOrElse(new File(sys.props("user.home")).toURI.getPath + ".ivy2") val sbtIvyHome = sys.props.getOrElse( "sbt.ivy.home", diff --git a/modules/sbt-coursier/src/main/scala/coursier/sbtcoursier/ResolutionTasks.scala b/modules/sbt-coursier/src/main/scala/coursier/sbtcoursier/ResolutionTasks.scala index 51ffd8546..799858bc8 100644 --- a/modules/sbt-coursier/src/main/scala/coursier/sbtcoursier/ResolutionTasks.scala +++ b/modules/sbt-coursier/src/main/scala/coursier/sbtcoursier/ResolutionTasks.scala @@ -86,7 +86,7 @@ object ResolutionTasks { val interProjectRepo = InterProjectRepository(interProjectDependencies) - val ivyProperties = ResolutionParams.defaultIvyProperties() + val ivyProperties = ResolutionParams.defaultIvyProperties(ivyPaths.value.ivyHome) val authenticationByRepositoryId = coursierCredentials.value.mapValues(_.authentication) diff --git a/modules/sbt-coursier/src/sbt-test/sbt-coursier/s3/build.sbt b/modules/sbt-coursier/src/sbt-test/sbt-coursier/s3/build.sbt index 77b86764a..0cab491bf 100644 --- a/modules/sbt-coursier/src/sbt-test/sbt-coursier/s3/build.sbt +++ b/modules/sbt-coursier/src/sbt-test/sbt-coursier/s3/build.sbt @@ -25,7 +25,9 @@ check := { sbtResolvers.flatMap{ sbtResolver: sbt.librarymanagement.Resolver => lmcoursier.internal.Resolvers.repository( resolver = sbtResolver, - ivyProperties = lmcoursier.internal.ResolutionParams.defaultIvyProperties(), + ivyProperties = lmcoursier.internal.ResolutionParams.defaultIvyProperties( + ivyPaths.value.ivyHome + ), log = s.log, authentication = None, ) diff --git a/modules/sbt-coursier/src/sbt-test/shared-1/cache-local/README.md b/modules/sbt-coursier/src/sbt-test/shared-1/cache-local/README.md new file mode 100644 index 000000000..51a739067 --- /dev/null +++ b/modules/sbt-coursier/src/sbt-test/shared-1/cache-local/README.md @@ -0,0 +1 @@ +Imported from https://github.com/sbt/sbt/tree/f5edeec2fdabd4313d2976b389bb6101775a5554/sbt/src/sbt-test/dependency-management/cache-local diff --git a/modules/sbt-coursier/src/sbt-test/shared-1/cache-local/cache.sbt b/modules/sbt-coursier/src/sbt-test/shared-1/cache-local/cache.sbt new file mode 100644 index 000000000..869c6d489 --- /dev/null +++ b/modules/sbt-coursier/src/sbt-test/shared-1/cache-local/cache.sbt @@ -0,0 +1 @@ +ivyPaths := { IvyPaths(baseDirectory.value, Some(target.value / ".ivy2")) } diff --git a/modules/sbt-coursier/src/sbt-test/shared-1/cache-local/changes/def.sbt b/modules/sbt-coursier/src/sbt-test/shared-1/cache-local/changes/def.sbt new file mode 100644 index 000000000..3e64f64c9 --- /dev/null +++ b/modules/sbt-coursier/src/sbt-test/shared-1/cache-local/changes/def.sbt @@ -0,0 +1,7 @@ +organization := "org.example" + +name := "def" + +version := "1.0" + +autoScalaLibrary := false diff --git a/modules/sbt-coursier/src/sbt-test/shared-1/cache-local/changes/resolver.sbt b/modules/sbt-coursier/src/sbt-test/shared-1/cache-local/changes/resolver.sbt new file mode 100644 index 000000000..642794849 --- /dev/null +++ b/modules/sbt-coursier/src/sbt-test/shared-1/cache-local/changes/resolver.sbt @@ -0,0 +1,5 @@ + +publishTo := baseDirectory(base => Some(Resolver.file("filesys-publish", base / "repo")) ).value + +resolvers += baseDirectory(base => "filesys" at (base / "repo").toURI.toString).value + diff --git a/modules/sbt-coursier/src/sbt-test/shared-1/cache-local/changes/use.sbt b/modules/sbt-coursier/src/sbt-test/shared-1/cache-local/changes/use.sbt new file mode 100644 index 000000000..d1b96f297 --- /dev/null +++ b/modules/sbt-coursier/src/sbt-test/shared-1/cache-local/changes/use.sbt @@ -0,0 +1,9 @@ +organization := "org.example" + +name := "use" + +version := "1.0" + +autoScalaLibrary := false + +libraryDependencies += "org.example" %% "def" % "1.0" diff --git a/modules/sbt-coursier/src/sbt-test/shared-1/cache-local/project/plugins.sbt b/modules/sbt-coursier/src/sbt-test/shared-1/cache-local/project/plugins.sbt new file mode 100644 index 000000000..71a44ffd3 --- /dev/null +++ b/modules/sbt-coursier/src/sbt-test/shared-1/cache-local/project/plugins.sbt @@ -0,0 +1,13 @@ +addSbtPlugin { + + val name = sys.props.getOrElse( + "plugin.name", + sys.error("plugin.name Java property not set") + ) + val version = sys.props.getOrElse( + "plugin.version", + sys.error("plugin.version Java property not set") + ) + + "io.get-coursier" % name % version +} \ No newline at end of file diff --git a/modules/sbt-coursier/src/sbt-test/shared-1/cache-local/test b/modules/sbt-coursier/src/sbt-test/shared-1/cache-local/test new file mode 100644 index 000000000..faf195ef2 --- /dev/null +++ b/modules/sbt-coursier/src/sbt-test/shared-1/cache-local/test @@ -0,0 +1,21 @@ +$ copy-file changes/def.sbt build.sbt +$ copy-file changes/resolver.sbt resolver.sbt +> reload +> publishLocal +> publish + +$ delete build.sbt +$ delete resolver.sbt +$ copy-file changes/use.sbt build.sbt +> reload +> update +> update + +# needed for sbt-coursier (clear in-memory cache) +> clean +$ delete target/.ivy2/local +-> update + +$ copy-file changes/resolver.sbt resolver.sbt +> reload +> update diff --git a/modules/sbt-lm-coursier/src/main/scala/coursier/sbtlmcoursier/LmCoursierPlugin.scala b/modules/sbt-lm-coursier/src/main/scala/coursier/sbtlmcoursier/LmCoursierPlugin.scala index 995d86c1b..7bc0dd914 100644 --- a/modules/sbt-lm-coursier/src/main/scala/coursier/sbtlmcoursier/LmCoursierPlugin.scala +++ b/modules/sbt-lm-coursier/src/main/scala/coursier/sbtlmcoursier/LmCoursierPlugin.scala @@ -7,7 +7,7 @@ import coursier.sbtcoursiershared.{InputsTasks, SbtCoursierShared} import sbt.{AutoPlugin, Classpaths, Def, Setting, Task, taskKey} import sbt.Project.inTask import sbt.KeyRanks.DTask -import sbt.Keys.{appConfiguration, autoScalaLibrary, classpathTypes, dependencyResolution, scalaBinaryVersion, scalaModuleInfo, scalaOrganization, scalaVersion, streams, updateClassifiers, updateSbtClassifiers} +import sbt.Keys.{appConfiguration, autoScalaLibrary, classpathTypes, dependencyResolution, ivyPaths, scalaBinaryVersion, scalaModuleInfo, scalaOrganization, scalaVersion, streams, updateClassifiers, updateSbtClassifiers} import sbt.librarymanagement.DependencyResolution import scala.language.reflectiveCalls @@ -133,6 +133,7 @@ object LmCoursierPlugin extends AutoPlugin { .withLogger(createLogger) .withCache(cache) .withLog(s.log) + .withIvyHome(ivyPaths.value.ivyHome) } } private def mkDependencyResolution: Def.Initialize[Task[DependencyResolution]] =