From c684363dff230f9a02dbc0261cb5ad4f74fe660c Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Fri, 14 Jun 2019 09:30:05 +0200 Subject: [PATCH] Support for Scala 2.13.0 (#972) * . * . * . * wip * update travis * tweak appveyor * mill 041 * wrap-lines * Fix already added deps file generation Must have been broken by bumping the coursier version in the build via mill. * 2.13.0-M5 -> 2.13.0 in .travis.yml * bump scalatags version * fix-tests * fix * fix * tweak * readme * workaround for https://github.com/scala/bug/issues/11564 * 1.6.8 . --- .travis.yml | 16 +-- .../ammonite/interp/GlobalInitCompat.scala | 82 ------------- .../interp/CompilerCompatibility.scala | 0 .../interp/ExtraCompilerCompatibility.scala | 0 .../ammonite/interp/GlobalInitCompat.scala | 3 +- .../interp/CompilerCompatibility.scala | 21 ++-- .../ammonite/interp/GlobalInitCompat.scala | 112 ++++++++++++++++++ .../scala/ammonite/interp/Interpreter.scala | 5 + .../CustomZipAndJarFileLookupFactory.scala | 4 + .../scala/ammonite/repl/FullReplAPI.scala | 2 +- .../scala/ammonite/repl/Highlighter.scala | 1 + .../main/scala/ammonite/repl/PPrints.scala | 2 +- .../ammonite/interp/AutocompleteTests.scala | 37 +++--- .../ammonite/session/AdvancedTests.scala | 8 +- .../scala/ammonite/session/BuiltinTests.scala | 2 +- .../scala/ammonite/session/EulerTests.scala | 4 +- .../ammonite/session/ImportHookTests.scala | 6 +- .../scala/ammonite/session/ProjectTests.scala | 4 +- .../scala/ammonite/unit/SourceTests.scala | 4 +- .../ammonite/runtime/tools/IvyThing.scala | 8 +- .../scala/ammonite/main/ProxyFromEnv.scala | 2 +- .../test/resources/importHooks/IvyImport.sc | 2 +- .../scriptLevelCaching/ivyCacheTest.sc | 2 +- amm/src/test/resources/scripts/LoadIvy.sc | 2 +- .../scripts/caching/scalatagsPredef.sc | 2 +- .../scala/ammonite/interp/CachingTests.scala | 6 +- .../interp/CompilerSettingsTests.scala | 11 +- appveyor.yml | 6 +- build.sc | 87 +++++++------- ci/upload.sc | 34 +++--- .../integration/basic/SourceDownload.sc | 2 +- .../ammonite/integration/basic/scalaTags.sc | 2 +- .../resources/some-dummy-library/build.sbt | 2 +- .../integration/ErrorTruncationTests.scala | 13 +- readme/Footer.scalatex | 4 + 35 files changed, 276 insertions(+), 222 deletions(-) delete mode 100644 amm/interp/src/main/scala-2.11/ammonite/interp/GlobalInitCompat.scala rename amm/interp/src/main/{scala-2.12_2.13 => scala-2.12}/ammonite/interp/CompilerCompatibility.scala (100%) rename amm/interp/src/main/{scala-2.11_2.12 => scala-2.12}/ammonite/interp/ExtraCompilerCompatibility.scala (100%) rename amm/interp/src/main/{scala-2.12_2.13 => scala-2.12}/ammonite/interp/GlobalInitCompat.scala (99%) rename amm/interp/src/main/{scala-2.11 => scala-2.13}/ammonite/interp/CompilerCompatibility.scala (69%) create mode 100644 amm/interp/src/main/scala-2.13/ammonite/interp/GlobalInitCompat.scala rename amm/interp/src/main/{scala-2.12_2.13 => scala}/scala/tools/nsc/CustomZipAndJarFileLookupFactory.scala (99%) diff --git a/.travis.yml b/.travis.yml index ae864eda7..da3011cb7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,11 +8,6 @@ install: matrix: include: - - stage: build - env: CI_SCRIPT="mill -i unitTest" - jdk: oraclejdk8 - scala: 2.11.12 - - stage: build env: CI_SCRIPT="mill -i unitTest" jdk: openjdk11 @@ -26,12 +21,7 @@ matrix: - stage: build env: CI_SCRIPT="mill -i unitTest" jdk: oraclejdk8 - scala: 2.13.0-M5 - - - stage: build - env: CI_SCRIPT="mill -i integrationTest" - jdk: oraclejdk8 - scala: 2.11.12 + scala: 2.13.0 - stage: build env: CI_SCRIPT="mill -i integrationTest" @@ -46,7 +36,7 @@ matrix: - stage: build env: CI_SCRIPT="mill -i integrationTest" jdk: oraclejdk8 - scala: 2.13.0-M5 + scala: 2.13.0 # Everything worked, *then* kick off a release @@ -82,7 +72,7 @@ script: - export PATH=~/bin/amm:~/bin/mill:$PATH - mkdir -p ~/bin # We use 2.11 since we need to run tests on Java 7 -- if [ ! -f ~/bin/mill-0.3.3 ]; then sudo sh -c '(echo "#!/usr/bin/env sh" && curl -L https://github.com/lihaoyi/mill/releases/download/0.3.3/0.3.3) > ~/bin/mill-0.3.3 && chmod +x ~/bin/mill-0.3.3 && ( cd ~/bin && rm -f mill && ln -s mill-0.3.3 mill)'; fi +- if [ ! -f ~/bin/mill-0.4.1 ]; then sudo sh -c '(echo "#!/usr/bin/env sh" && curl -L https://github.com/lihaoyi/mill/releases/download/0.4.1/0.4.1) > ~/bin/mill-0.4.1 && chmod +x ~/bin/mill-0.4.1 && ( cd ~/bin && rm -f mill && ln -s mill-0.4.1 mill)'; fi - JAVAOPTS="-Xmx2048m" $CI_SCRIPT notifications: diff --git a/amm/interp/src/main/scala-2.11/ammonite/interp/GlobalInitCompat.scala b/amm/interp/src/main/scala-2.11/ammonite/interp/GlobalInitCompat.scala deleted file mode 100644 index b822ac6a2..000000000 --- a/amm/interp/src/main/scala-2.11/ammonite/interp/GlobalInitCompat.scala +++ /dev/null @@ -1,82 +0,0 @@ -package ammonite.interp - -import scala.reflect.io.{FileZipArchive, VirtualDirectory} -import scala.tools.nsc.{Global, Settings} -import scala.tools.nsc.plugins.Plugin -import scala.tools.nsc.reporters.AbstractReporter -import scala.tools.nsc.util.ClassPath.JavaContext -import scala.tools.nsc.util._ -import scala.reflect.io._ -import scala.tools.nsc -import scala.tools.nsc.backend.JavaPlatform -import ammonite.runtime.Classpath - -object GlobalInitCompat { - def initInteractiveGlobal(settings: Settings, - reporter: AbstractReporter, - jcp: JavaClassPath, - evalClassloader: ClassLoader) = { - new nsc.interactive.Global(settings, reporter) { g => - // Actually jcp, avoiding a path-dependent type issue in 2.10 here - override def classPath = platform.classPath - - override lazy val platform: ThisPlatform = new JavaPlatform { - val global: g.type = g - - override def classPath = jcp - } - override lazy val analyzer = CompilerCompatibility.interactiveAnalyzer(g, evalClassloader) - } - } - def initGlobal(settings: Settings, - reporter: AbstractReporter, - jcp: JavaClassPath, - evalClassloader: ClassLoader, - createPlugins: Global => List[Plugin]): nsc.Global = { - new nsc.Global(settings, reporter) { g => - override lazy val plugins = createPlugins(g) - - // Actually jcp, avoiding a path-dependent type issue in 2.10 here - override def classPath = platform.classPath - val x = new JavaPlatform{ - val global: g.type = g - override def classPath = jcp - } - override lazy val platform: ThisPlatform = x - - override lazy val analyzer = CompilerCompatibility.analyzer(g, evalClassloader) - } - } - /** - * Code to initialize random bits and pieces that are needed - * for the Scala compiler to function, common between the - * normal and presentation compiler - */ - def initGlobalClasspath(dirDeps: Seq[java.io.File], - jarDeps: Seq[java.net.URL], - dynamicClasspath: VirtualDirectory, - settings: Settings) = { - - val jCtx = new JavaContext() - - val jarCP = - jarDeps.filter(x => x.getPath.endsWith(".jar") || Classpath.canBeOpenedAsJar(x)) - .map { x => - val arc = - if (x.getProtocol == "file") - new FileZipArchive(java.nio.file.Paths.get(x.toURI).toFile) - else - new internal.CustomURLZipArchive(x) - new DirectoryClassPath(arc, jCtx) - } - .toVector - - val dirCP = - dirDeps.map(x => new DirectoryClassPath(new PlainDirectory(new Directory(x)), jCtx)) - - val dynamicCP = Seq(new DirectoryClassPath(dynamicClasspath, jCtx)) - val jcp = new JavaClassPath(jarCP ++ dirCP ++ dynamicCP, jCtx) - - jcp - } -} diff --git a/amm/interp/src/main/scala-2.12_2.13/ammonite/interp/CompilerCompatibility.scala b/amm/interp/src/main/scala-2.12/ammonite/interp/CompilerCompatibility.scala similarity index 100% rename from amm/interp/src/main/scala-2.12_2.13/ammonite/interp/CompilerCompatibility.scala rename to amm/interp/src/main/scala-2.12/ammonite/interp/CompilerCompatibility.scala diff --git a/amm/interp/src/main/scala-2.11_2.12/ammonite/interp/ExtraCompilerCompatibility.scala b/amm/interp/src/main/scala-2.12/ammonite/interp/ExtraCompilerCompatibility.scala similarity index 100% rename from amm/interp/src/main/scala-2.11_2.12/ammonite/interp/ExtraCompilerCompatibility.scala rename to amm/interp/src/main/scala-2.12/ammonite/interp/ExtraCompilerCompatibility.scala diff --git a/amm/interp/src/main/scala-2.12_2.13/ammonite/interp/GlobalInitCompat.scala b/amm/interp/src/main/scala-2.12/ammonite/interp/GlobalInitCompat.scala similarity index 99% rename from amm/interp/src/main/scala-2.12_2.13/ammonite/interp/GlobalInitCompat.scala rename to amm/interp/src/main/scala-2.12/ammonite/interp/GlobalInitCompat.scala index a410e3ec8..0e6b3f0f2 100644 --- a/amm/interp/src/main/scala-2.12_2.13/ammonite/interp/GlobalInitCompat.scala +++ b/amm/interp/src/main/scala-2.12/ammonite/interp/GlobalInitCompat.scala @@ -1,13 +1,14 @@ package ammonite.interp import ammonite.runtime.Classpath + import scala.reflect.io.{AbstractFile, FileZipArchive, VirtualDirectory} import scala.tools.nsc import scala.tools.nsc.classpath._ -import scala.tools.nsc.{CustomZipAndJarFileLookupFactory, Global, Settings} import scala.tools.nsc.interactive.{Global => InteractiveGlobal} import scala.tools.nsc.plugins.Plugin import scala.tools.nsc.reporters.AbstractReporter +import scala.tools.nsc.{CustomZipAndJarFileLookupFactory, Global, Settings} object GlobalInitCompat{ diff --git a/amm/interp/src/main/scala-2.11/ammonite/interp/CompilerCompatibility.scala b/amm/interp/src/main/scala-2.13/ammonite/interp/CompilerCompatibility.scala similarity index 69% rename from amm/interp/src/main/scala-2.11/ammonite/interp/CompilerCompatibility.scala rename to amm/interp/src/main/scala-2.13/ammonite/interp/CompilerCompatibility.scala index 6248ff5c7..30f134821 100644 --- a/amm/interp/src/main/scala-2.11/ammonite/interp/CompilerCompatibility.scala +++ b/amm/interp/src/main/scala-2.13/ammonite/interp/CompilerCompatibility.scala @@ -1,8 +1,7 @@ package ammonite.interp - import scala.tools.nsc.Global -import scala.tools.nsc.interactive.{ Global => InteractiveGlobal } +import scala.tools.nsc.interactive.{Global => InteractiveGlobal} import scala.tools.nsc.plugins.Plugin import scala.tools.nsc.typechecker.Analyzer @@ -10,23 +9,25 @@ object CompilerCompatibility extends ExtraCompilerCompatibility { def newUnitParser(compiler: Global, line: String, fileName: String) = { compiler.newUnitParser(line, fileName) } - def analyzer(g: Global, cl: ClassLoader): Analyzer { val global: g.type } = + def analyzer(g: Global, cl: ClassLoader): Analyzer { val global: g.type } = { new { val global: g.type = g } with Analyzer { - override def findMacroClassLoader() = cl + override def defaultMacroClassloader = global.findMacroClassLoader } + } type InteractiveAnalyzer = scala.tools.nsc.interactive.InteractiveAnalyzer - def interactiveAnalyzer(g: InteractiveGlobal, cl: ClassLoader) - : InteractiveAnalyzer { val global: g.type } = + def interactiveAnalyzer(g: InteractiveGlobal, + cl: ClassLoader): InteractiveAnalyzer { val global: g.type } = { new { val global: g.type = g } with InteractiveAnalyzer { - override def findMacroClassLoader() = cl } + } - def trees(g: Global)(parser: g.syntaxAnalyzer.UnitParser): Seq[Global#Tree] = + def trees(g: Global)(parser: g.syntaxAnalyzer.UnitParser): Seq[Global#Tree] = { parser.parseStatsOrPackages() + } - def pluginInit(plugin: Plugin, options: List[String], error: String => Unit): Boolean = + def pluginInit(plugin: Plugin, options: List[String], error: String => Unit): Boolean = { plugin.init(options, error) - + } } diff --git a/amm/interp/src/main/scala-2.13/ammonite/interp/GlobalInitCompat.scala b/amm/interp/src/main/scala-2.13/ammonite/interp/GlobalInitCompat.scala new file mode 100644 index 000000000..bc564e6da --- /dev/null +++ b/amm/interp/src/main/scala-2.13/ammonite/interp/GlobalInitCompat.scala @@ -0,0 +1,112 @@ +package ammonite.interp + +import ammonite.runtime.Classpath +import scala.reflect.io.{AbstractFile, FileZipArchive, VirtualDirectory} +import scala.tools.nsc +import scala.tools.nsc.classpath._ +import scala.tools.nsc.{CustomZipAndJarFileLookupFactory, Global, Settings} +import scala.tools.nsc.interactive.{Global => InteractiveGlobal} +import scala.tools.nsc.plugins.Plugin +import scala.tools.nsc.reporters.AbstractReporter + +object GlobalInitCompat{ + + def initInteractiveGlobal(settings: Settings, + reporter: AbstractReporter, + jcp: AggregateClassPath, + evalClassloader: ClassLoader): InteractiveGlobal = { + new nsc.interactive.Global(settings, reporter) { g => + // Actually jcp, avoiding a path-dependent type issue in 2.10 here + override def classPath = jcp + + override lazy val platform: ThisPlatform = new GlobalPlatform { + override val global = g + override val settings = g.settings + override val classPath = jcp + } + + override lazy val analyzer = CompilerCompatibility.interactiveAnalyzer(g, evalClassloader) + } + } + + def initGlobal(settings: Settings, + reporter: AbstractReporter, + jcp: AggregateClassPath, + evalClassloader: ClassLoader, + createPlugins: Global => List[Plugin]): Global = { + + new nsc.Global(settings, reporter) { g => + override lazy val plugins = createPlugins(g) + + // Actually jcp, avoiding a path-dependent type issue in 2.10 here + override def classPath = jcp + override def findMacroClassLoader() = evalClassloader + override lazy val platform: ThisPlatform = new GlobalPlatform { + override val global = g + override val settings = g.settings + override val classPath = jcp + } + + override lazy val analyzer = CompilerCompatibility.analyzer(g, evalClassloader) + } + } + + /** + * Code to initialize random bits and pieces that are needed + * for the Scala compiler to function, common between the + * normal and presentation compiler + */ + def initGlobalClasspath(dirDeps: Seq[java.io.File], + jarDeps: Seq[java.net.URL], + dynamicClasspath: VirtualDirectory, + settings: Settings) = { + + val jarCP = + jarDeps.filter(x => x.getPath.endsWith(".jar") || Classpath.canBeOpenedAsJar(x)) + .map { x => + if (x.getProtocol == "file") { + val arc = new FileZipArchive(java.nio.file.Paths.get(x.toURI).toFile) + ZipAndJarClassPathFactory.create(arc, settings, new scala.tools.nsc.CloseableRegistry()) + } else { + val arc = new internal.CustomURLZipArchive(x) + CustomZipAndJarFileLookupFactory.create(arc, settings) + } + } + .toVector + + val dirCP = dirDeps.map(x => new DirectoryClassPath(x)) + val dynamicCP = new VirtualDirectoryClassPath(dynamicClasspath){ + + override def getSubDir(packageDirName: String): Option[AbstractFile] = { + val pathParts = packageDirName.split('/') + var file: AbstractFile = dir + for (dirPart <- pathParts) { + file = file.lookupName(dirPart, directory = true) + if (file == null) return None + } + Some(file) + + } + override def findClassFile(className: String): Option[AbstractFile] = { + val relativePath = FileUtils.dirPath(className) + val pathParts = relativePath.split('/') + var file: AbstractFile = dir + for (dirPart <- pathParts.init) { + file = file.lookupName(dirPart, directory = true) + if (file == null) return None + } + + file.lookupName(pathParts.last + ".class", directory = false) match { + case null => None + case file => Some(file) + } + } + + } + + val jcp = new AggregateClassPath(jarCP ++ dirCP ++ Seq(dynamicCP)) + + + jcp + } +} diff --git a/amm/interp/src/main/scala/ammonite/interp/Interpreter.scala b/amm/interp/src/main/scala/ammonite/interp/Interpreter.scala index fca758e00..d42931f77 100644 --- a/amm/interp/src/main/scala/ammonite/interp/Interpreter.scala +++ b/amm/interp/src/main/scala/ammonite/interp/Interpreter.scala @@ -215,6 +215,11 @@ class Interpreter(val printer: Printer, source: CodeSource, wrapperPath: Seq[Name]): Res[ImportHookInfo] = synchronized{ + // Fake an update to the classpath to force re-creation of the compiler + // Workaround for https://github.com/scala/bug/issues/11564#issuecomment-501834821, + // which I caused in 2.13.0 and should be fixed in 2.13.1 + if (scala.util.Properties.versionNumberString == "2.13.0") headFrame.addClasspath(Nil) + for (hookImports <- Res.map(importTrees)(resolveSingleImportHook(source, _, wrapperPath))) yield ImportHookInfo( Imports(hookImports.flatten.flatMap(_.value)), diff --git a/amm/interp/src/main/scala-2.12_2.13/scala/tools/nsc/CustomZipAndJarFileLookupFactory.scala b/amm/interp/src/main/scala/scala/tools/nsc/CustomZipAndJarFileLookupFactory.scala similarity index 99% rename from amm/interp/src/main/scala-2.12_2.13/scala/tools/nsc/CustomZipAndJarFileLookupFactory.scala rename to amm/interp/src/main/scala/scala/tools/nsc/CustomZipAndJarFileLookupFactory.scala index 6d9aa35d3..4b0bfe3e7 100644 --- a/amm/interp/src/main/scala-2.12_2.13/scala/tools/nsc/CustomZipAndJarFileLookupFactory.scala +++ b/amm/interp/src/main/scala/scala/tools/nsc/CustomZipAndJarFileLookupFactory.scala @@ -25,6 +25,7 @@ object CustomZipAndJarFileLookupFactory { def zipFile: File = null override def asURLs: Seq[URL] = Seq(zipUrl) + override def asClassPathStrings: Seq[String] = Seq(zipUrl.toURI.toASCIIString) // ??? private val archive = new CustomURLZipArchive(zipUrl) @@ -51,6 +52,7 @@ object CustomZipAndJarFileLookupFactory { } yield createFileEntry(entry) def hasPackage(pkg: String) = findDirEntry(pkg).isDefined + override private[nsc] def list(inPackage: String): ClassPathEntries = { val foundDirEntry = findDirEntry(inPackage) @@ -76,6 +78,7 @@ object CustomZipAndJarFileLookupFactory { val (pkg, simpleClassName) = PackageNameUtils.separatePkgAndClassNames(className) file(pkg, simpleClassName + ".class").map(_.file) } + // This method is performance sensitive as it is used by SBT's ExtractDependencies phase. override def findClass(className: String): Option[ClassRepresentation] = { val (pkg, simpleClassName) = PackageNameUtils.separatePkgAndClassNames(className) @@ -87,6 +90,7 @@ object CustomZipAndJarFileLookupFactory { protected def createFileEntry(file: CustomURLZipArchive#Entry): ClassFileEntryImpl = ClassFileEntryImpl(file) + protected def isRequiredFileType(file: AbstractFile): Boolean = !file.isDirectory && file.hasExtension("class") } diff --git a/amm/repl/src/main/scala/ammonite/repl/FullReplAPI.scala b/amm/repl/src/main/scala/ammonite/repl/FullReplAPI.scala index dec108027..f874df86a 100644 --- a/amm/repl/src/main/scala/ammonite/repl/FullReplAPI.scala +++ b/amm/repl/src/main/scala/ammonite/repl/FullReplAPI.scala @@ -95,7 +95,7 @@ object FullReplAPI { ) val output = mutable.Buffer.empty[fansi.Str] - prefix.foreach(output +=) + prefix.foreach(output += _) val rhs = custom match { case None => diff --git a/amm/repl/src/main/scala/ammonite/repl/Highlighter.scala b/amm/repl/src/main/scala/ammonite/repl/Highlighter.scala index 6d3c26102..ff491b868 100644 --- a/amm/repl/src/main/scala/ammonite/repl/Highlighter.scala +++ b/amm/repl/src/main/scala/ammonite/repl/Highlighter.scala @@ -70,6 +70,7 @@ object Highlighter { case "Interp" => reset case "Comment" => comment case "ExprLiteral" => literal + case "PatLiteral" => literal case "TypeId" => `type` case BackTicked(body) if parse(body, scalaparse.syntax.Identifiers.AlphabetKeywords(_)).isSuccess => keyword diff --git a/amm/repl/src/main/scala/ammonite/repl/PPrints.scala b/amm/repl/src/main/scala/ammonite/repl/PPrints.scala index 0f422e114..0d58daee1 100644 --- a/amm/repl/src/main/scala/ammonite/repl/PPrints.scala +++ b/amm/repl/src/main/scala/ammonite/repl/PPrints.scala @@ -24,7 +24,7 @@ object PPrints{ ) val snippets = for (p <- t) yield { fansi.Str.join( - renderer.rec(relPathRepr(os.RelPath(p relativeTo t.base toString)), 0, 0) + renderer.rec(relPathRepr(os.RelPath(p.relativeTo(t.base).toString)), 0, 0) .iter .toStream:_* ) diff --git a/amm/repl/src/test/scala/ammonite/interp/AutocompleteTests.scala b/amm/repl/src/test/scala/ammonite/interp/AutocompleteTests.scala index bae071478..651bf38ac 100644 --- a/amm/repl/src/test/scala/ammonite/interp/AutocompleteTests.scala +++ b/amm/repl/src/test/scala/ammonite/interp/AutocompleteTests.scala @@ -99,14 +99,14 @@ object AutocompleteTests extends TestSuite{ complete( """object Zomg{ }""", Set("Zomg") -- _) complete( "printl", - Set("println") ^, - Set[String]() ^ + Set("println") ^ _, + Set[String]() ^ _ ) } // Not sure why this doesnt work // complete( // "println", - // Set[String]() ^, + // Set[String]() ^ _, // Set("def println(x: Any): Unit", "def println(): Unit") ^ // ) } @@ -114,25 +114,28 @@ object AutocompleteTests extends TestSuite{ if (!Util.java9OrAbove) { // these fail on Java 9, need investigation complete( """ammon""", Set("ammonite") ^ _) - complete( """Seq(1, 2, 3).map(argNameLol => argNam)""", Set("argNameLol") ^) + complete( + """Seq(1, 2, 3).map(argNameLol => argNam)""", + Set("argNameLol") ^ _ + ) - complete( """object Zomg{ Zom }""", Set("Zomg") ^) - complete( """object Zomg{ Zom }""", Set("Zomg") ^) - complete( """object Zomg{ Zom }""", Set("Zomg") ^) - complete( """object Zomg{ Zom }""", Set("Zomg") ^) + complete( """object Zomg{ Zom }""", Set("Zomg") ^ _) + complete( """object Zomg{ Zom }""", Set("Zomg") ^ _) + complete( """object Zomg{ Zom }""", Set("Zomg") ^ _) + complete( """object Zomg{ Zom }""", Set("Zomg") ^ _) } } 'dot - checking{ complete => complete( """java.math.""", - Set("MathContext", "BigDecimal", "BigInteger", "RoundingMode") ^ + Set("MathContext", "BigDecimal", "BigInteger", "RoundingMode") ^ _ ) val extra = if (scala2_11 || scala2_12) Set() else Set("unless", "when") complete( """scala.Option.""", - (anyCompletion ++ Set("apply", "empty") ++ extra) ^ + (anyCompletion ++ Set("apply", "empty") ++ extra) ^ _ ) complete( """Seq(1, 2, 3).map(_.)""", @@ -147,21 +150,21 @@ object AutocompleteTests extends TestSuite{ 'deep - checking{ complete => complete( """fromN""", - Set("scala.concurrent.duration.fromNow") ^ + Set("scala.concurrent.duration.fromNow") ^ _ ) complete( """Fut""", Set("scala.concurrent.Future", "java.util.concurrent.Future") -- _ ) complete( """SECO""", - Set("scala.concurrent.duration.SECONDS") ^ + Set("scala.concurrent.duration.SECONDS") ^ _ ) } 'dotPrefix - checking{ complete => complete( """java.math.Big""", - Set("BigDecimal", "BigInteger") ^ + Set("BigDecimal", "BigInteger") ^ _ ) complete( """scala.Option.option2""", - Set() ^ + Set() ^ _ ) complete( """val x = 1; x + x.>""", Set(">>", ">>>") -- _, @@ -173,7 +176,7 @@ object AutocompleteTests extends TestSuite{ "def >(x: Long): Boolean", "def >(x: Char): Boolean", "def >(x: Byte): Boolean" - ) ^ + ) ^ _ ) @@ -198,7 +201,7 @@ object AutocompleteTests extends TestSuite{ 'Array - checking{ complete => //Test around https://github.com/lihaoyi/Ammonite/issues/252 - complete("""new Array""", Set() ^) + complete("""new Array""", Set() ^ _) } 'LOCAL_SUFFIX_STRING - checking { complete => @@ -229,7 +232,7 @@ object AutocompleteTests extends TestSuite{ 'dependencies { // re-enable if we can use the same coursier version again in 2.13 - if (scala.util.Properties.versionNumberString != "2.13.0-M5") + if (scala.util.Properties.versionNumberString != "2.13.0") checking { complete => complete( """import $ivy.`io.get-c`""", diff --git a/amm/repl/src/test/scala/ammonite/session/AdvancedTests.scala b/amm/repl/src/test/scala/ammonite/session/AdvancedTests.scala index 40a6b2623..c50e2faf7 100644 --- a/amm/repl/src/test/scala/ammonite/session/AdvancedTests.scala +++ b/amm/repl/src/test/scala/ammonite/session/AdvancedTests.scala @@ -314,7 +314,7 @@ object AdvancedTests extends TestSuite{ @ // Importing plugins doesn't affect the run-time classpath - @ import $plugin.$ivy.`com.lihaoyi::scalatags:0.6.8` + @ import $plugin.$ivy.`com.lihaoyi::scalatags:0.7.0` @ import scalatags.Text error: not found: value scalatags @@ -426,7 +426,8 @@ object AdvancedTests extends TestSuite{ 'dontRefreshCompiler { * - { - check.session(""" + // Conditional check due to https://github.com/scala/bug/issues/11564 + if (scala.util.Properties.versionNumberString != "2.13.0") check.session(""" @ val c1 = repl.compiler @ val n = 2 @@ -446,7 +447,8 @@ object AdvancedTests extends TestSuite{ } 'preconfigured - { - check.session(""" + // Conditional check due to https://github.com/scala/bug/issues/11564 + if (scala.util.Properties.versionNumberString != "2.13.0") check.session(""" @ val c0 = repl.compiler @ interp.preConfigureCompiler(_ => ()) diff --git a/amm/repl/src/test/scala/ammonite/session/BuiltinTests.scala b/amm/repl/src/test/scala/ammonite/session/BuiltinTests.scala index 2d181cb2a..369a9aa33 100644 --- a/amm/repl/src/test/scala/ammonite/session/BuiltinTests.scala +++ b/amm/repl/src/test/scala/ammonite/session/BuiltinTests.scala @@ -168,7 +168,7 @@ object BuiltinTests extends TestSuite{ @ // Let's try this new cool new library - @ import $ivy.`com.lihaoyi::scalatags:0.6.8` + @ import $ivy.`com.lihaoyi::scalatags:0.7.0` @ veryImportant res4: Int = 1 diff --git a/amm/repl/src/test/scala/ammonite/session/EulerTests.scala b/amm/repl/src/test/scala/ammonite/session/EulerTests.scala index f56c7611b..993a170ae 100644 --- a/amm/repl/src/test/scala/ammonite/session/EulerTests.scala +++ b/amm/repl/src/test/scala/ammonite/session/EulerTests.scala @@ -49,7 +49,7 @@ object EulerTests extends TestSuite{ check.session(""" @ { @ (100 to 999).view - @ .flatMap(i => (i to 999).map(i *)) + @ .flatMap(i => (i to 999).map(i * _)) @ .filter(n => n.toString == n.toString.reverse) @ .max @ } @@ -551,7 +551,7 @@ object EulerTests extends TestSuite{ check.session(""" @ def ps(s: String): Iterator[String] = { @ if (s.length == 1) Iterator(s) - @ else s.toIterator.flatMap(c => ps(s.filter(c !=)).map(c +)) + @ else s.toIterator.flatMap(c => ps(s.filter(c != _)).map(c + _)) @ } @ val r = ps("0123456789").drop(999999).next().toLong diff --git a/amm/repl/src/test/scala/ammonite/session/ImportHookTests.scala b/amm/repl/src/test/scala/ammonite/session/ImportHookTests.scala index 2b2073d39..acd70a24b 100644 --- a/amm/repl/src/test/scala/ammonite/session/ImportHookTests.scala +++ b/amm/repl/src/test/scala/ammonite/session/ImportHookTests.scala @@ -75,7 +75,7 @@ object ImportHookTests extends TestSuite{ @ import scalatags.Text.all._ error: not found: value scalatags - @ import $ivy.`com.lihaoyi::scalatags:0.6.8` + @ import $ivy.`com.lihaoyi::scalatags:0.7.0` @ import scalatags.Text.all._ @@ -89,7 +89,7 @@ object ImportHookTests extends TestSuite{ @ import scalatags.Text.all._ error: not found: value scalatags - @ import $$ivy.`com.lihaoyi:scalatags_${IvyThing.scalaBinaryVersion}:0.6.8` + @ import $$ivy.`com.lihaoyi:scalatags_${IvyThing.scalaBinaryVersion}:0.7.0` @ import scalatags.Text.all._ @@ -103,7 +103,7 @@ object ImportHookTests extends TestSuite{ @ import scalatags.Text.all._ error: not found: value scalatags - @ import $ivy.`com.lihaoyi::scalatags:0.6.8`, scalatags.Text.all._ + @ import $ivy.`com.lihaoyi::scalatags:0.7.0`, scalatags.Text.all._ @ div("Hello").render res1: String = "
Hello
" diff --git a/amm/repl/src/test/scala/ammonite/session/ProjectTests.scala b/amm/repl/src/test/scala/ammonite/session/ProjectTests.scala index f1410ca79..c4dc11f4d 100644 --- a/amm/repl/src/test/scala/ammonite/session/ProjectTests.scala +++ b/amm/repl/src/test/scala/ammonite/session/ProjectTests.scala @@ -20,7 +20,7 @@ object ProjectTests extends TestSuite{ @ import scalatags.Text.all._ error: not found: value scalatags - @ import $$ivy.`com.lihaoyi::scalatags:0.6.8` + @ import $$ivy.`com.lihaoyi::scalatags:0.7.0` @ import scalatags.Text.all._ import scalatags.Text.all._ @@ -121,7 +121,7 @@ object ProjectTests extends TestSuite{ } 'cats{ check.session(""" - @ import $ivy.`org.typelevel::cats-core:1.6.0`, cats._ + @ import $ivy.`org.typelevel::cats-core:2.0.0-M4`, cats._ """) } diff --git a/amm/repl/src/test/scala/ammonite/unit/SourceTests.scala b/amm/repl/src/test/scala/ammonite/unit/SourceTests.scala index 0fd759595..3f3206bb0 100644 --- a/amm/repl/src/test/scala/ammonite/unit/SourceTests.scala +++ b/amm/repl/src/test/scala/ammonite/unit/SourceTests.scala @@ -95,7 +95,7 @@ object SourceTests extends TestSuite{ check( load(Predef.println()), "Predef.scala", - "def println() =" + "def println()" ) } @@ -122,7 +122,7 @@ object SourceTests extends TestSuite{ check( load(opt.get), "Option.scala", - "def get = " + "def get" ) } } diff --git a/amm/runtime/src/main/scala/ammonite/runtime/tools/IvyThing.scala b/amm/runtime/src/main/scala/ammonite/runtime/tools/IvyThing.scala index 1b447d262..ef5e68467 100644 --- a/amm/runtime/src/main/scala/ammonite/runtime/tools/IvyThing.scala +++ b/amm/runtime/src/main/scala/ammonite/runtime/tools/IvyThing.scala @@ -53,17 +53,17 @@ object IvyThing{ Function.chain(hooks)(fetch).eitherResult() match { case Left(err) => Left("Failed to resolve ivy dependencies:" + err.getMessage) - case Right((_, artifacts)) => - val noChangingArtifact = artifacts.forall(!_._1.changing) + case Right(result) => + val noChangingArtifact = result.artifacts.forall(!_._1.changing) def noVersionInterval = dependencies.map(_.version).forall { v => coursier.core.Parse.versionConstraint(v).interval == coursier.core.VersionInterval.zero } - val files = artifacts.map(_._2) + val files = result.artifacts.map(_._2) Right((noChangingArtifact && noVersionInterval, files)) } } - val defaultRepositories = List( + val defaultRepositories = List[coursier.Repository]( LocalRepositories.ivy2Local, coursier.MavenRepository("https://repo1.maven.org/maven2") ) diff --git a/amm/src/main/scala/ammonite/main/ProxyFromEnv.scala b/amm/src/main/scala/ammonite/main/ProxyFromEnv.scala index b4e0845b3..8bb9d9346 100644 --- a/amm/src/main/scala/ammonite/main/ProxyFromEnv.scala +++ b/amm/src/main/scala/ammonite/main/ProxyFromEnv.scala @@ -42,7 +42,7 @@ private[ammonite] object ProxyFromEnv { val propPassword = credPair.drop(1).map(s"$proto.proxyPassword" -> _) Seq(propUser) ++ propPassword } else Nil - Seq(propHost, propPort) ++ propCred toMap + (Seq(propHost, propPort) ++ propCred).toMap case bad => Map.empty } diff --git a/amm/src/test/resources/importHooks/IvyImport.sc b/amm/src/test/resources/importHooks/IvyImport.sc index a62474cf6..5e169ee18 100644 --- a/amm/src/test/resources/importHooks/IvyImport.sc +++ b/amm/src/test/resources/importHooks/IvyImport.sc @@ -1,3 +1,3 @@ -import $ivy.`com.lihaoyi::scalatags:0.6.8`, scalatags.Text.all._ +import $ivy.`com.lihaoyi::scalatags:0.7.0`, scalatags.Text.all._ val rendered = div("Moo").render \ No newline at end of file diff --git a/amm/src/test/resources/scriptLevelCaching/ivyCacheTest.sc b/amm/src/test/resources/scriptLevelCaching/ivyCacheTest.sc index 3db09e29e..334977687 100644 --- a/amm/src/test/resources/scriptLevelCaching/ivyCacheTest.sc +++ b/amm/src/test/resources/scriptLevelCaching/ivyCacheTest.sc @@ -1,4 +1,4 @@ -import $ivy.`com.lihaoyi::scalatags:0.6.8`, scalatags.Text.all._ +import $ivy.`com.lihaoyi::scalatags:0.7.0`, scalatags.Text.all._ val rendered = div("Moo").render diff --git a/amm/src/test/resources/scripts/LoadIvy.sc b/amm/src/test/resources/scripts/LoadIvy.sc index 382b98efc..fb0b0acc5 100644 --- a/amm/src/test/resources/scripts/LoadIvy.sc +++ b/amm/src/test/resources/scripts/LoadIvy.sc @@ -1,4 +1,4 @@ -interp.load.ivy("com.lihaoyi" %% "scalatags" % "0.6.8") +interp.load.ivy("com.lihaoyi" %% "scalatags" % "0.7.0") @ import scalatags.Text.all._ val res = a("omg", href:="www.google.com").render diff --git a/amm/src/test/resources/scripts/caching/scalatagsPredef.sc b/amm/src/test/resources/scripts/caching/scalatagsPredef.sc index 75b025527..ead5acf19 100644 --- a/amm/src/test/resources/scripts/caching/scalatagsPredef.sc +++ b/amm/src/test/resources/scripts/caching/scalatagsPredef.sc @@ -1 +1 @@ -import $ivy.`com.lihaoyi::scalatags:0.6.8`, scalatags.Text.all._ \ No newline at end of file +import $ivy.`com.lihaoyi::scalatags:0.7.0`, scalatags.Text.all._ \ No newline at end of file diff --git a/amm/src/test/scala/ammonite/interp/CachingTests.scala b/amm/src/test/scala/ammonite/interp/CachingTests.scala index a624fc502..54ac0f347 100644 --- a/amm/src/test/scala/ammonite/interp/CachingTests.scala +++ b/amm/src/test/scala/ammonite/interp/CachingTests.scala @@ -136,7 +136,7 @@ object CachingTests extends TestSuite{ Scripts.runScript(os.pwd, scriptPath/"TagBase.sc", interp) Scripts.runScript(os.pwd, scriptPath/"TagPrevCommand.sc", interp) - interp.loadIvy("com.lihaoyi" %% "scalatags" % "0.6.8") + interp.loadIvy("com.lihaoyi" %% "scalatags" % "0.7.0") Scripts.runScript(os.pwd, scriptPath/"TagBase.sc", interp) val n = storage.compileCache.size assert(n == 5) // customLolz predef + two blocks for each loaded file @@ -166,7 +166,7 @@ object CachingTests extends TestSuite{ val x = 1337 @ val y = x - import $ivy.`com.lihaoyi::scalatags:0.6.8`, scalatags.Text.all._ + import $ivy.`com.lihaoyi::scalatags:0.7.0`, scalatags.Text.all._ """) val scriptFile = os.temp("""div("<('.'<)", y).render""") @@ -188,7 +188,7 @@ object CachingTests extends TestSuite{ os.write( predefFile, """ - import $ivy.`com.lihaoyi::scalatags:0.6.8`; import scalatags.Text.all._ + import $ivy.`com.lihaoyi::scalatags:0.7.0`; import scalatags.Text.all._ val y = 31337 """ ) diff --git a/amm/src/test/scala/ammonite/interp/CompilerSettingsTests.scala b/amm/src/test/scala/ammonite/interp/CompilerSettingsTests.scala index 3c0786e6e..27254fbef 100644 --- a/amm/src/test/scala/ammonite/interp/CompilerSettingsTests.scala +++ b/amm/src/test/scala/ammonite/interp/CompilerSettingsTests.scala @@ -13,15 +13,18 @@ object CompilerSettingsTests extends TestSuite { val scriptPath = os.pwd / 'amm / 'src / 'test / 'resources / 'scriptCompilerSettings 'configureYrangepos { + // In this test, the script sets -Yrangepos to true using "configureCompiler", // which is called AFTER the compiler instantiates. As useOffsetPositions // is set eagerly during the compiler instantiation as !Yrangepos, its // value remains "true". - val storage = Storage.InMemory() - val interp = createTestInterp(storage) - Scripts.runScript(os.pwd, scriptPath / "configureCompiler.sc", interp) + if (scala.util.Properties.versionNumberString.startsWith("2.12.")){ + val storage = Storage.InMemory() + val interp = createTestInterp(storage) + Scripts.runScript(os.pwd, scriptPath / "configureCompiler.sc", interp) - assert(interp.compilerManager.compiler.compiler.useOffsetPositions) + assert(interp.compilerManager.compiler.compiler.useOffsetPositions) + } } 'preConfigureYrangepos { diff --git a/appveyor.yml b/appveyor.yml index d9f9025de..e201e3fbf 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -6,14 +6,14 @@ environment: matrix: - JAVA_OPTS: -Dfile.encoding=UTF8 JAVA_HOME: C:\Program Files\Java\jdk9 - TEST_TASKS: ops[2.11.12].test terminal[2.12.8].test amm.repl[2.12.8].test terminal[2.13.0-M5].test amm.repl[2.13.0-M5].test + TEST_TASKS: terminal[2.12.8].test amm.repl[2.12.8].test terminal[2.13.0].test amm.repl[2.13.0].test - JAVA_OPTS: -Dfile.encoding=UTF8 JAVA_HOME: C:\Program Files\Java\jdk1.8.0 - TEST_TASKS: amm[2.11.12].test integration[2.12.8].test integration[2.13.0-M5].test + TEST_TASKS: integration[2.12.8].test integration[2.13.0].test install: - - SET MILL_URL=https://github.com/lihaoyi/mill/releases/download/0.2.7/0.2.7 + - SET MILL_URL=https://github.com/lihaoyi/mill/releases/download/0.4.1/0.4.1 build_script: - SET "PATH=%JAVA_HOME%\bin;%PATH%" diff --git a/build.sc b/build.sc index e1808f33c..b9a9a0a4f 100644 --- a/build.sc +++ b/build.sc @@ -13,11 +13,10 @@ val commitsSinceTaggedVersion = { } -val binCrossScalaVersions = Seq("2.11.12", "2.12.8", "2.13.0-M5") +val binCrossScalaVersions = Seq("2.12.8", "2.13.0") val fullCrossScalaVersions = Seq( - "2.11.3", "2.11.4", "2.11.5", "2.11.6", "2.11.7", "2.11.8", "2.11.9", "2.11.11", "2.11.12", "2.12.0", "2.12.1", "2.12.2", "2.12.3", "2.12.4", "2.12.6", "2.12.7", "2.12.8", - "2.13.0-M5" + "2.13.0" ) val latestAssemblies = binCrossScalaVersions.map(amm(_).assembly) @@ -33,10 +32,10 @@ trait AmmInternalModule extends mill.scalalib.CrossSbtModule{ def artifactName = "ammonite-" + millOuterCtx.segments.parts.last def testFramework = "utest.runner.Framework" def scalacOptions = Seq("-P:acyclic:force", "-target:jvm-1.7") - def compileIvyDeps = Agg(ivy"com.lihaoyi::acyclic:0.1.8") - def scalacPluginIvyDeps = Agg(ivy"com.lihaoyi::acyclic:0.1.8") + def compileIvyDeps = Agg(ivy"com.lihaoyi::acyclic:0.2.0") + def scalacPluginIvyDeps = Agg(ivy"com.lihaoyi::acyclic:0.2.0") trait Tests extends super.Tests{ - def ivyDeps = Agg(ivy"com.lihaoyi::utest:0.6.6") + def ivyDeps = Agg(ivy"com.lihaoyi::utest:0.6.9") def testFrameworks = Seq("utest.runner.Framework") def forkArgs = Seq("-XX:MaxPermSize=2g", "-Xmx4g", "-Dfile.encoding=UTF8") def sources = T.sources{ @@ -114,8 +113,8 @@ trait AmmDependenciesResourceFileModule extends JavaModule{ object ops extends Cross[OpsModule](binCrossScalaVersions:_*) class OpsModule(val crossScalaVersion: String) extends AmmModule{ def ivyDeps = Agg( - ivy"com.lihaoyi::os-lib:0.2.9", - ivy"org.scala-lang.modules::scala-collection-compat:0.3.0" + ivy"com.lihaoyi::os-lib:0.3.0", + ivy"org.scala-lang.modules::scala-collection-compat:2.0.0" ) def scalacOptions = super.scalacOptions().filter(!_.contains("acyclic")) object test extends Tests @@ -124,8 +123,8 @@ class OpsModule(val crossScalaVersion: String) extends AmmModule{ object terminal extends Cross[TerminalModule](binCrossScalaVersions:_*) class TerminalModule(val crossScalaVersion: String) extends AmmModule{ def ivyDeps = Agg( - ivy"com.lihaoyi::sourcecode:0.1.5", - ivy"com.lihaoyi::fansi:0.2.6" + ivy"com.lihaoyi::sourcecode:0.1.7", + ivy"com.lihaoyi::fansi:0.2.7" ) def compileIvyDeps = Agg( ivy"org.scala-lang:scala-reflect:$crossScalaVersion" @@ -139,10 +138,10 @@ object amm extends Cross[MainModule](fullCrossScalaVersions:_*){ class UtilModule(val crossScalaVersion: String) extends AmmModule{ def moduleDeps = Seq(ops()) def ivyDeps = Agg( - ivy"com.lihaoyi::upickle:0.7.4", - ivy"com.lihaoyi::pprint:0.5.4", - ivy"com.lihaoyi::fansi:0.2.6", - ivy"org.scala-lang.modules::scala-collection-compat:0.3.0" + ivy"com.lihaoyi::upickle:0.7.5", + ivy"com.lihaoyi::pprint:0.5.5", + ivy"com.lihaoyi::fansi:0.2.7", + ivy"org.scala-lang.modules::scala-collection-compat:2.0.0" ) def compileIvyDeps = Agg( ivy"org.scala-lang:scala-reflect:$crossScalaVersion" @@ -156,12 +155,11 @@ object amm extends Cross[MainModule](fullCrossScalaVersions:_*){ def moduleDeps = Seq(ops(), amm.util()) def ivyDeps = T{ // try again using the same version when we switch to the latest scala 2.13 - val coursierVersion = - if (scalaVersion() == "2.13.0-M5") "1.1.0-M14-2" - else "1.1.0-M14-3" + val coursierVersion = "2.0.0-RC2" + Agg( ivy"io.get-coursier::coursier:$coursierVersion", - ivy"com.lihaoyi::requests:0.1.9" + ivy"com.lihaoyi::requests:0.2.0" ) } @@ -177,7 +175,7 @@ object amm extends Cross[MainModule](fullCrossScalaVersions:_*){ def ivyDeps = Agg( ivy"org.scala-lang:scala-compiler:$crossScalaVersion", ivy"org.scala-lang:scala-reflect:$crossScalaVersion", - ivy"com.lihaoyi::scalaparse:2.1.0", + ivy"com.lihaoyi::scalaparse:2.1.3", ivy"org.javassist:javassist:3.21.0-GA" ) } @@ -365,7 +363,7 @@ def generateDependenciesFile(scalaVersion: String, val content = deps .map { dep => - (dep.module.organization, dep.module.name, dep.version) + (dep.module.organization.value, dep.module.name.value, dep.version) } .sorted .map { @@ -390,20 +388,18 @@ def publishExecutable() = { val latestAssemblyJars = mill.define.Task.sequence(latestAssemblies)() println("MASTER COMMIT: Creating a release") - import ujson.Js if (!unstable){ - scalaj.http.Http("https://api.github.com/repos/lihaoyi/Ammonite/releases") - .postData( - ujson.write( - Js.Obj( - "tag_name" -> buildVersion, - "name" -> buildVersion, - "body" -> s"http://www.lihaoyi.com/Ammonite/#$buildVersion" - ) + requests.post( + "https://api.github.com/repos/lihaoyi/Ammonite/releases", + data = ujson.write( + ujson.Obj( + "tag_name" -> buildVersion, + "name" -> buildVersion, + "body" -> s"http://www.lihaoyi.com/Ammonite/#$buildVersion" ) - ) - .header("Authorization", "token " + sys.env("AMMONITE_BOT_AUTH_TOKEN")) - .asString + ), + headers = Seq("Authorization" -> s"token ${sys.env("AMMONITE_BOT_AUTH_TOKEN")}") + ) } for ((version, jar) <- binCrossScalaVersions.zip(latestAssemblyJars)) { @@ -428,8 +424,8 @@ def publishDocs() = { println("MISC COMMIT: Building readme for verification") %sbt( "readme/run", - AMMONITE_SHELL=shell("2.12.8").jar().path, - AMMONITE_ASSEMBLY=amm("2.12.8").assembly().path, + AMMONITE_SHELL=shell("2.13.0").jar().path, + AMMONITE_ASSEMBLY=amm("2.13.0").assembly().path, CONSTANTS_FILE=generateConstantsFile() ) }else T.command{ @@ -441,20 +437,20 @@ def publishDocs() = { val (stableKey, unstableKey, oldStableKeys, oldUnstableKeys) = if (!unstable){ ( - s"$latestTaggedVersion/2.12-$latestTaggedVersion", - s"$latestTaggedVersion/2.12-$latestTaggedVersion", - for(v <- Seq("2.11")) + s"$latestTaggedVersion/2.13-$latestTaggedVersion", + s"$latestTaggedVersion/2.13-$latestTaggedVersion", + for(v <- Seq("2.12")) yield s"$latestTaggedVersion/$v-$latestTaggedVersion", - for(v <- Seq("2.11")) + for(v <- Seq("2.12")) yield s"$latestTaggedVersion/$v-$latestTaggedVersion" ) }else{ ( - s"$latestTaggedVersion/2.12-$latestTaggedVersion", - s"$latestTaggedVersion/2.12-$buildVersion", - for(v <- Seq("2.11")) + s"$latestTaggedVersion/2.13-$latestTaggedVersion", + s"$latestTaggedVersion/2.13-$buildVersion", + for(v <- Seq("2.12")) yield s"$latestTaggedVersion/$v-$latestTaggedVersion", - for(v <- Seq("2.11")) + for(v <- Seq("2.12")) yield s"$latestTaggedVersion/$v-$buildVersion" ) } @@ -473,8 +469,8 @@ def publishDocs() = { %sbt( "readme/run", - AMMONITE_SHELL=shell("2.12.8").jar().path, - AMMONITE_ASSEMBLY=amm("2.12.8").assembly().path, + AMMONITE_SHELL=shell("2.13.0").jar().path, + AMMONITE_ASSEMBLY=amm("2.13.0").assembly().path, CONSTANTS_FILE=constantsFile ) %("ci/deploy_master_docs.sh") @@ -528,7 +524,10 @@ def publishSonatype(publishArtifacts: mill.main.Tasks[PublishModule.PublishData] "https://oss.sonatype.org/content/repositories/snapshots", sys.env("SONATYPE_DEPLOY_USER") + ":" + sys.env("SONATYPE_DEPLOY_PASSWORD"), Option(sys.env("SONATYPE_PGP_PASSWORD")), + None, true, + 60000, + 60000, T.ctx().log ).publishAll( true, diff --git a/ci/upload.sc b/ci/upload.sc index 75519341e..20595ea22 100644 --- a/ci/upload.sc +++ b/ci/upload.sc @@ -1,6 +1,5 @@ #!/usr/bin/env amm import ammonite.ops._ -import scalaj.http._ @main def apply(uploadedFile: Path, @@ -12,11 +11,12 @@ def apply(uploadedFile: Path, println(tagName) println(uploadName) println(authKey) - val body = Http("https://api.github.com/repos/lihaoyi/Ammonite/releases/tags/" + tagName) - .header("Authorization", "token " + authKey) - .asString.body + val body = requests.get( + "https://api.github.com/repos/lihaoyi/Ammonite/releases/tags/" + tagName, + headers = Seq("Authorization" -> s"token $authKey"), + ) - val parsed = ujson.read(body) + val parsed = ujson.read(body.text) println(body) @@ -27,15 +27,21 @@ def apply(uploadedFile: Path, s"https://uploads.github.com/repos/lihaoyi/Ammonite/releases/" + s"$snapshotReleaseId/assets?name=$uploadName" - val res = Http(uploadUrl) - .header("Content-Type", "application/octet-stream") - .header("Authorization", "token " + authKey) - .timeout(connTimeoutMs = 5000, readTimeoutMs = 60000) - .postData(read.bytes! uploadedFile) - .asString - - println(res.body) - val longUrl = ujson.read(res.body)("browser_download_url").toString + val res = requests.post( + uploadUrl, + headers = Seq( + "Content-Type" -> "application/octet-stream", + "Authorization" -> s"token $authKey" + ), + connectTimeout = 5000, + readTimeout = 60000, + data = read.bytes(uploadedFile) + ).text + + + println(res) + + val longUrl = ujson.read(res)("browser_download_url").str longUrl } diff --git a/integration/src/test/resources/ammonite/integration/basic/SourceDownload.sc b/integration/src/test/resources/ammonite/integration/basic/SourceDownload.sc index a81f5d49b..f6ffceff2 100644 --- a/integration/src/test/resources/ammonite/integration/basic/SourceDownload.sc +++ b/integration/src/test/resources/ammonite/integration/basic/SourceDownload.sc @@ -1,4 +1,4 @@ -import $ivy.`com.lihaoyi::scalatags:0.6.8` +import $ivy.`com.lihaoyi::scalatags:0.7.0` val loc = source.load(scalatags.Text) val snip = Predef.augmentString(loc.fileContent) diff --git a/integration/src/test/resources/ammonite/integration/basic/scalaTags.sc b/integration/src/test/resources/ammonite/integration/basic/scalaTags.sc index b6568c81a..015ce6c0f 100644 --- a/integration/src/test/resources/ammonite/integration/basic/scalaTags.sc +++ b/integration/src/test/resources/ammonite/integration/basic/scalaTags.sc @@ -1,4 +1,4 @@ -interp.load.ivy("com.lihaoyi" %% "scalatags" % "0.6.8") +interp.load.ivy("com.lihaoyi" %% "scalatags" % "0.7.0") @ import scalatags.Text.all._ val res = a("omg", href:="www.google.com").render diff --git a/integration/src/test/resources/some-dummy-library/build.sbt b/integration/src/test/resources/some-dummy-library/build.sbt index fcce5c75c..51b6fde28 100644 --- a/integration/src/test/resources/some-dummy-library/build.sbt +++ b/integration/src/test/resources/some-dummy-library/build.sbt @@ -7,7 +7,7 @@ lazy val root = (project in file(".")). scalaVersion := sys.env("SCALA_VERSION"), libraryDependencies += { if (java.lang.Boolean.parseBoolean(sys.env("FIRST_RUN"))) - "io.circe" %% "circe-core" % "0.11.1" + "io.circe" %% "circe-core" % "0.12.0-M3" else "io.argonaut" %% "argonaut" % "6.2.3" } diff --git a/integration/src/test/scala/ammonite/integration/ErrorTruncationTests.scala b/integration/src/test/scala/ammonite/integration/ErrorTruncationTests.scala index ef3639c7f..9f4e42e09 100644 --- a/integration/src/test/scala/ammonite/integration/ErrorTruncationTests.scala +++ b/integration/src/test/scala/ammonite/integration/ErrorTruncationTests.scala @@ -69,10 +69,15 @@ object ErrorTruncationTests extends TestSuite{ 'runtimeError - checkErrorMessage( file = 'errorTruncation/"runtimeError.sc", expected = Util.normalizeNewlines( - s"""java.lang.ArithmeticException: / by zero - | $runtimeErrorResourcePackage.runtimeError$$.(runtimeError.sc:1) - | $runtimeErrorResourcePackage.runtimeError$$.(runtimeError.sc) - |""".stripMargin + if (scala.util.Properties.versionNumberString.startsWith("2.12")) + s"""java.lang.ArithmeticException: / by zero + | $runtimeErrorResourcePackage.runtimeError$$.(runtimeError.sc:1) + | $runtimeErrorResourcePackage.runtimeError$$.(runtimeError.sc) + |""".stripMargin + else + s"""java.lang.ArithmeticException: / by zero + | $runtimeErrorResourcePackage.runtimeError$$.(runtimeError.sc:1) + |""".stripMargin ) ) } diff --git a/readme/Footer.scalatex b/readme/Footer.scalatex index 7881db1e1..541d5caef 100644 --- a/readme/Footer.scalatex +++ b/readme/Footer.scalatex @@ -123,6 +123,10 @@ @sect{Changelog} + @sect{1.6.8} + @ul + @li + Support for Scala 2.13.0 @sect{1.6.7} @ul @li