From 6f8a9d295f0880109ae4a72337ed8f74ba4a80af Mon Sep 17 00:00:00 2001 From: Alexandre Archambault Date: Mon, 12 Mar 2018 11:18:20 +0100 Subject: [PATCH] Fix deprecation warnings --- .../scala-2.12/coursier/extra/Native.scala | 9 +++++---- .../main/scala/coursier/CoursierPlugin.scala | 20 +++++++++++++------ .../src/test/scala/coursier/IvyXmlTests.scala | 2 +- .../coursier/SbtCompatibility.scala | 4 ++++ .../test/scala/coursier/test/JsTests.scala | 2 +- .../coursier/test/DirectoryListingTests.scala | 2 +- .../test/HttpAuthenticationTests.scala | 2 +- .../scala/coursier/test/CacheFetchTests.scala | 2 +- .../scala/coursier/test/ChecksumTests.scala | 2 +- .../test/scala/coursier/test/IvyTests.scala | 2 +- .../test/scala/coursier/test/MavenTests.scala | 2 +- .../scala/coursier/test/PropertiesTests.scala | 2 +- .../test/ResolutionProcessTests.scala | 2 +- .../scala/coursier/test/ActivationTests.scala | 2 +- .../scala/coursier/test/CentralTests.scala | 2 +- .../scala/coursier/test/ExclusionsTests.scala | 2 +- .../coursier/test/IvyPatternParserTests.scala | 2 +- .../test/scala/coursier/test/ParseTests.scala | 2 +- .../scala/coursier/test/PomParsingTests.scala | 2 +- .../scala/coursier/test/ResolutionTests.scala | 2 +- .../test/VersionConstraintTests.scala | 2 +- .../scala/coursier/test/VersionTests.scala | 2 +- .../test/scala/coursier/util/PrintTests.scala | 2 +- .../test/scala/coursier/util/TreeTests.scala | 2 +- 24 files changed, 44 insertions(+), 31 deletions(-) diff --git a/extra/src/main/scala-2.12/coursier/extra/Native.scala b/extra/src/main/scala-2.12/coursier/extra/Native.scala index bc4bd9334..98bd0635b 100644 --- a/extra/src/main/scala-2.12/coursier/extra/Native.scala +++ b/extra/src/main/scala-2.12/coursier/extra/Native.scala @@ -32,7 +32,8 @@ object Native { Seq(s"$binaryName$major$minor", s"$binaryName-$major.$minor") } :+ binaryName - Process("which" +: binaryNames).lines_! + Process("which" +: binaryNames) + .lineStream_! .map(new File(_)) .headOption .getOrElse { @@ -325,7 +326,7 @@ object Native { val compileOpts = { val includes = { val includedir = - Try(Process("llvm-config --includedir").lines_!) + Try(Process("llvm-config --includedir").lineStream_!) .getOrElse(Seq.empty) ("/usr/local/include" +: includedir).map(s => s"-I$s") } @@ -392,7 +393,7 @@ object Native { val nativeCompileOptions = { val includes = { val includedir = - Try(Process("llvm-config --includedir").lines_!) + Try(Process("llvm-config --includedir").lineStream_!) .getOrElse(Seq.empty) ("/usr/local/include" +: includedir).map(s => s"-I$s") } @@ -444,7 +445,7 @@ object Native { val nativeLinkingOptions = { val libs = { val libdir = - Try(Process("llvm-config --libdir").lines_!) + Try(Process("llvm-config --libdir").lineStream_!) .getOrElse(Seq.empty) ("/usr/local/lib" +: libdir).map(s => s"-L$s") } diff --git a/sbt-coursier/src/main/scala/coursier/CoursierPlugin.scala b/sbt-coursier/src/main/scala/coursier/CoursierPlugin.scala index 2bd8e4481..6d1231cce 100644 --- a/sbt-coursier/src/main/scala/coursier/CoursierPlugin.scala +++ b/sbt-coursier/src/main/scala/coursier/CoursierPlugin.scala @@ -81,7 +81,7 @@ object CoursierPlugin extends AutoPlugin { IvyXml.writeFiles(currentProject, shadedConfigOpt, ivySbt.value, streams.value.log) }).value - private val pluginIvySnapshotsBase = Resolver.SbtPluginRepositoryRoot.stripSuffix("/") + "/ivy-snapshots" + private val pluginIvySnapshotsBase = Resolver.SbtRepositoryRoot.stripSuffix("/") + "/ivy-snapshots" // allows to get the actual repo list when sbt starts up private val hackHack = Seq( @@ -93,25 +93,33 @@ object CoursierPlugin extends AutoPlugin { // hack to trigger https://github.com/sbt/sbt/blob/v1.0.1/main/src/main/scala/sbt/Defaults.scala#L2856, // to have the third case be used instead of the second one, at https://github.com/sbt/sbt/blob/v1.0.1/main/src/main/scala/sbt/Defaults.scala#L2069 - // 😃🔫 new xsbti.AppConfiguration { def provider() = { + import scala.language.reflectiveCalls val prov = app.provider() + val noWarningForDeprecatedStuffProv = prov.asInstanceOf[{ + def mainClass(): Class[_ <: xsbti.AppMain] + }] new xsbti.AppProvider { def newMain() = prov.newMain() def components() = prov.components() - def mainClass() = prov.mainClass() + def mainClass() = noWarningForDeprecatedStuffProv.mainClass() def mainClasspath() = prov.mainClasspath() def loader() = prov.loader() def scalaProvider() = { val scalaProv = prov.scalaProvider() + val noWarningForDeprecatedStuffScalaProv = scalaProv.asInstanceOf[{ + def libraryJar(): File + def compilerJar(): File + }] + new xsbti.ScalaProvider { def app(id: xsbti.ApplicationID) = scalaProv.app(id) def loader() = scalaProv.loader() def jars() = scalaProv.jars() - def libraryJar() = scalaProv.libraryJar() + def libraryJar() = noWarningForDeprecatedStuffScalaProv.libraryJar() def version() = scalaProv.version() - def compilerJar() = scalaProv.compilerJar() + def compilerJar() = noWarningForDeprecatedStuffScalaProv.compilerJar() def launcher() = { val launch = scalaProv.launcher() new xsbti.Launcher { @@ -152,7 +160,7 @@ object CoursierPlugin extends AutoPlugin { packageConfigs: Seq[(Configuration, String)] ) = hackHack ++ Seq( clean := { - clean.value + val noWarningPlz = clean.value Tasks.resolutionsCache.clear() Tasks.reportsCache.clear() }, diff --git a/sbt-coursier/src/test/scala/coursier/IvyXmlTests.scala b/sbt-coursier/src/test/scala/coursier/IvyXmlTests.scala index 8738a7aca..8f695d727 100644 --- a/sbt-coursier/src/test/scala/coursier/IvyXmlTests.scala +++ b/sbt-coursier/src/test/scala/coursier/IvyXmlTests.scala @@ -4,7 +4,7 @@ import utest._ object IvyXmlTests extends TestSuite { - val tests = TestSuite { + val tests = Tests { "no truncation" - { val project = Project( diff --git a/sbt-shared/src/main/scala-2.10/coursier/SbtCompatibility.scala b/sbt-shared/src/main/scala-2.10/coursier/SbtCompatibility.scala index 5ca0e8403..c00ba3c98 100644 --- a/sbt-shared/src/main/scala-2.10/coursier/SbtCompatibility.scala +++ b/sbt-shared/src/main/scala-2.10/coursier/SbtCompatibility.scala @@ -3,4 +3,8 @@ package coursier object SbtCompatibility { def needsIvyXmlLocal = List(sbt.Keys.deliverLocalConfiguration) def needsIvyXml = List(sbt.Keys.deliverConfiguration) + + implicit class ResolverCompationExtraOps(val res: sbt.Resolver.type) { + def SbtRepositoryRoot = res.SbtPluginRepositoryRoot + } } diff --git a/tests/js/src/test/scala/coursier/test/JsTests.scala b/tests/js/src/test/scala/coursier/test/JsTests.scala index adf157fb9..eadc9d8a0 100644 --- a/tests/js/src/test/scala/coursier/test/JsTests.scala +++ b/tests/js/src/test/scala/coursier/test/JsTests.scala @@ -9,7 +9,7 @@ import scala.concurrent.{ Future, Promise } object JsTests extends TestSuite { - val tests = TestSuite { + val tests = Tests { 'promise{ val p = Promise[Unit]() Future(p.success(())) diff --git a/tests/jvm/src/it/scala/coursier/test/DirectoryListingTests.scala b/tests/jvm/src/it/scala/coursier/test/DirectoryListingTests.scala index 224eab9bf..024d574f7 100644 --- a/tests/jvm/src/it/scala/coursier/test/DirectoryListingTests.scala +++ b/tests/jvm/src/it/scala/coursier/test/DirectoryListingTests.scala @@ -22,7 +22,7 @@ object DirectoryListingTests extends TestSuite { val module = Module("com.abc", "test") val version = "0.1" - val tests = TestSuite { + val tests = Tests { 'withListing - { 'jar - CentralTests.withArtifacts( module, diff --git a/tests/jvm/src/it/scala/coursier/test/HttpAuthenticationTests.scala b/tests/jvm/src/it/scala/coursier/test/HttpAuthenticationTests.scala index 1fd350fef..952fa3b73 100644 --- a/tests/jvm/src/it/scala/coursier/test/HttpAuthenticationTests.scala +++ b/tests/jvm/src/it/scala/coursier/test/HttpAuthenticationTests.scala @@ -7,7 +7,7 @@ import coursier.maven.MavenRepository object HttpAuthenticationTests extends TestSuite { - val tests = TestSuite { + val tests = Tests { 'httpAuthentication - { // requires an authenticated HTTP server to be running on localhost:8080 with user 'user' // and password 'pass' diff --git a/tests/jvm/src/test/scala/coursier/test/CacheFetchTests.scala b/tests/jvm/src/test/scala/coursier/test/CacheFetchTests.scala index dd83802d5..2d309d266 100644 --- a/tests/jvm/src/test/scala/coursier/test/CacheFetchTests.scala +++ b/tests/jvm/src/test/scala/coursier/test/CacheFetchTests.scala @@ -66,7 +66,7 @@ object CacheFetchTests extends TestSuite { assert(errors.isEmpty) } - val tests = TestSuite { + val tests = Tests { // using scala-test would allow to put the below comments in the test names... diff --git a/tests/jvm/src/test/scala/coursier/test/ChecksumTests.scala b/tests/jvm/src/test/scala/coursier/test/ChecksumTests.scala index 642b20c98..6e63b9cf3 100644 --- a/tests/jvm/src/test/scala/coursier/test/ChecksumTests.scala +++ b/tests/jvm/src/test/scala/coursier/test/ChecksumTests.scala @@ -11,7 +11,7 @@ import scala.concurrent.{ExecutionContext, Future} object ChecksumTests extends TestSuite { - val tests = TestSuite { + val tests = Tests { 'parse - { diff --git a/tests/jvm/src/test/scala/coursier/test/IvyTests.scala b/tests/jvm/src/test/scala/coursier/test/IvyTests.scala index 6632149b7..094a09931 100644 --- a/tests/jvm/src/test/scala/coursier/test/IvyTests.scala +++ b/tests/jvm/src/test/scala/coursier/test/IvyTests.scala @@ -18,7 +18,7 @@ object IvyTests extends TestSuite { throw new Exception("Cannot happen") ) - val tests = TestSuite { + val tests = Tests { 'dropInfoAttributes - { CentralTests.resolutionCheck( module = Module( diff --git a/tests/jvm/src/test/scala/coursier/test/MavenTests.scala b/tests/jvm/src/test/scala/coursier/test/MavenTests.scala index 93cf7dce1..7f039180d 100644 --- a/tests/jvm/src/test/scala/coursier/test/MavenTests.scala +++ b/tests/jvm/src/test/scala/coursier/test/MavenTests.scala @@ -9,7 +9,7 @@ object MavenTests extends TestSuite { // only tested on the JVM for lack of support of XML attributes in the platform-dependent XML stubs - val tests = TestSuite { + val tests = Tests { 'testSnapshotNoVersioning - { val dep = Dependency( diff --git a/tests/jvm/src/test/scala/coursier/test/PropertiesTests.scala b/tests/jvm/src/test/scala/coursier/test/PropertiesTests.scala index c2b261ae9..09daf6aba 100644 --- a/tests/jvm/src/test/scala/coursier/test/PropertiesTests.scala +++ b/tests/jvm/src/test/scala/coursier/test/PropertiesTests.scala @@ -5,7 +5,7 @@ import utest._ object PropertiesTests extends TestSuite { - val tests = TestSuite { + val tests = Tests { 'version - { assert(Properties.version.nonEmpty) diff --git a/tests/jvm/src/test/scala/coursier/test/ResolutionProcessTests.scala b/tests/jvm/src/test/scala/coursier/test/ResolutionProcessTests.scala index 4da7822d5..2b0c21ebb 100644 --- a/tests/jvm/src/test/scala/coursier/test/ResolutionProcessTests.scala +++ b/tests/jvm/src/test/scala/coursier/test/ResolutionProcessTests.scala @@ -13,7 +13,7 @@ import scalaz.concurrent.Task object ResolutionProcessTests extends TestSuite { - val tests = TestSuite { + val tests = Tests { 'fetchAll - { diff --git a/tests/shared/src/test/scala/coursier/test/ActivationTests.scala b/tests/shared/src/test/scala/coursier/test/ActivationTests.scala index d7d7f9a7c..8693dbdca 100644 --- a/tests/shared/src/test/scala/coursier/test/ActivationTests.scala +++ b/tests/shared/src/test/scala/coursier/test/ActivationTests.scala @@ -22,7 +22,7 @@ object ActivationTests extends TestSuite { // - condition on OS or JDK, but no OS or JDK info provided (-> no match) // - negated OS infos (starting with "!") - not implemented yet - val tests = TestSuite { + val tests = Tests { 'OS - { 'fromProperties - { 'MacOSX - { diff --git a/tests/shared/src/test/scala/coursier/test/CentralTests.scala b/tests/shared/src/test/scala/coursier/test/CentralTests.scala index 0d33ea153..2a57aab2f 100644 --- a/tests/shared/src/test/scala/coursier/test/CentralTests.scala +++ b/tests/shared/src/test/scala/coursier/test/CentralTests.scala @@ -214,7 +214,7 @@ abstract class CentralTests extends TestSuite { assert(artifact.url.endsWith("." + extension)) } - val tests = TestSuite { + val tests = Tests { 'logback - { async { diff --git a/tests/shared/src/test/scala/coursier/test/ExclusionsTests.scala b/tests/shared/src/test/scala/coursier/test/ExclusionsTests.scala index 051421384..87d5a18e0 100644 --- a/tests/shared/src/test/scala/coursier/test/ExclusionsTests.scala +++ b/tests/shared/src/test/scala/coursier/test/ExclusionsTests.scala @@ -8,7 +8,7 @@ object ExclusionsTests extends TestSuite { def exclusionsAdd(e1: Set[(String, String)], e2: Set[(String, String)]) = core.Exclusions.minimize(e1 ++ e2) - val tests = TestSuite { + val tests = Tests { val e1 = Set(("org1", "name1")) val e2 = Set(("org2", "name2")) diff --git a/tests/shared/src/test/scala/coursier/test/IvyPatternParserTests.scala b/tests/shared/src/test/scala/coursier/test/IvyPatternParserTests.scala index 4d40fe9e8..73b0fb2d1 100644 --- a/tests/shared/src/test/scala/coursier/test/IvyPatternParserTests.scala +++ b/tests/shared/src/test/scala/coursier/test/IvyPatternParserTests.scala @@ -8,7 +8,7 @@ import utest._ object IvyPatternParserTests extends TestSuite { - val tests = TestSuite { + val tests = Tests { 'plugin - { val strPattern = "[organization]/[module](/scala_[scalaVersion])(/sbt_[sbtVersion])/[revision]/resolved.xml.[ext]" diff --git a/tests/shared/src/test/scala/coursier/test/ParseTests.scala b/tests/shared/src/test/scala/coursier/test/ParseTests.scala index f32c8c0db..121745363 100644 --- a/tests/shared/src/test/scala/coursier/test/ParseTests.scala +++ b/tests/shared/src/test/scala/coursier/test/ParseTests.scala @@ -22,7 +22,7 @@ object ParseTests extends TestSuite { val url = "file%3A%2F%2Fsome%2Fencoded%2Furl" - val tests = TestSuite { + val tests = Tests { "bintray-ivy:" - { val obtained = Parse.repository("bintray-ivy:scalameta/maven") assert(obtained.right.exists(isIvyRepo)) diff --git a/tests/shared/src/test/scala/coursier/test/PomParsingTests.scala b/tests/shared/src/test/scala/coursier/test/PomParsingTests.scala index 23aa32550..eec377c90 100644 --- a/tests/shared/src/test/scala/coursier/test/PomParsingTests.scala +++ b/tests/shared/src/test/scala/coursier/test/PomParsingTests.scala @@ -8,7 +8,7 @@ import utest._ object PomParsingTests extends TestSuite { - val tests = TestSuite { + val tests = Tests { 'readClassifier{ val depNode =""" diff --git a/tests/shared/src/test/scala/coursier/test/ResolutionTests.scala b/tests/shared/src/test/scala/coursier/test/ResolutionTests.scala index a038fb5a2..b8c21b966 100644 --- a/tests/shared/src/test/scala/coursier/test/ResolutionTests.scala +++ b/tests/shared/src/test/scala/coursier/test/ResolutionTests.scala @@ -206,7 +206,7 @@ object ResolutionTests extends TestSuite { testRepository ) - val tests = TestSuite { + val tests = Tests { 'empty{ async{ val res = await(resolve0( diff --git a/tests/shared/src/test/scala/coursier/test/VersionConstraintTests.scala b/tests/shared/src/test/scala/coursier/test/VersionConstraintTests.scala index 0f909d3a7..df8b10370 100644 --- a/tests/shared/src/test/scala/coursier/test/VersionConstraintTests.scala +++ b/tests/shared/src/test/scala/coursier/test/VersionConstraintTests.scala @@ -6,7 +6,7 @@ import utest._ object VersionConstraintTests extends TestSuite { - val tests = TestSuite { + val tests = Tests { 'parse{ 'empty{ val c0 = Parse.versionConstraint("") diff --git a/tests/shared/src/test/scala/coursier/test/VersionTests.scala b/tests/shared/src/test/scala/coursier/test/VersionTests.scala index 74c486f83..98c64b9e2 100644 --- a/tests/shared/src/test/scala/coursier/test/VersionTests.scala +++ b/tests/shared/src/test/scala/coursier/test/VersionTests.scala @@ -14,7 +14,7 @@ object VersionTests extends TestSuite { versions.iterator.sliding(2).withPartial(false).forall{case Seq(a, b) => compare(a, b) < 0 } - val tests = TestSuite { + val tests = Tests { 'stackOverflow - { val s = "." * 100000 diff --git a/tests/shared/src/test/scala/coursier/util/PrintTests.scala b/tests/shared/src/test/scala/coursier/util/PrintTests.scala index 42ee57fd7..3b0b37645 100644 --- a/tests/shared/src/test/scala/coursier/util/PrintTests.scala +++ b/tests/shared/src/test/scala/coursier/util/PrintTests.scala @@ -6,7 +6,7 @@ import utest._ object PrintTests extends TestSuite { - val tests = TestSuite { + val tests = Tests { 'ignoreAttributes - { val dep = Dependency( Module("org", "name"), diff --git a/tests/shared/src/test/scala/coursier/util/TreeTests.scala b/tests/shared/src/test/scala/coursier/util/TreeTests.scala index 71c895ebb..465063486 100644 --- a/tests/shared/src/test/scala/coursier/util/TreeTests.scala +++ b/tests/shared/src/test/scala/coursier/util/TreeTests.scala @@ -54,7 +54,7 @@ object TreeTests extends TestSuite { e.addChild(f) - val tests = TestSuite { + val tests = Tests { 'basic { val str = Tree[Node](roots)(_.children, _.label) assert(str ==