Skip to content

Commit

Permalink
Bump to sbt 1.7.1 (#459)
Browse files Browse the repository at this point in the history
* copy/paste error

* Upgrade to sbt 1.7.1

- downstream libraries must now upgrade too
- was necessary because of dependency changes in sbt, see sbt/librarymanagement#399
  • Loading branch information
oyvindberg authored Jul 13, 2022
1 parent 91a4815 commit ca6468d
Show file tree
Hide file tree
Showing 139 changed files with 167 additions and 191 deletions.
2 changes: 1 addition & 1 deletion docs/library-developer.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Have a look at [mobx-slinky](https://github.com/ScalablyTyped/mobx-slinky)

## Requirements

**This plugin needs sbt 1.5.x or 1.6.x**.
**This plugin needs sbt 1.7.x**.

Since we generate source code, it should work with any combination of
Scala 2.12 / 2.13 / 3.0 and Scala.js 1.10+
Expand Down
2 changes: 1 addition & 1 deletion docs/plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ If you really want more than one conversion make sure to [shade](conversion-opti

## Requirements

**This plugin needs sbt 1.5.x or 1.6.x**.
**This plugin needs sbt 1.7.x**.

Since we generate source code, it should work with any combination of
Scala 2.12 / 2.13 / 3 and Scala.js 1.10+
Expand Down
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.5.5
sbt.version=1.7.1
2 changes: 1 addition & 1 deletion release.sc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@ import $ivy.`com.lihaoyi::ammonite-ops:2.4.1`
import $ivy.`com.lihaoyi::ammonite-ops:2.4.1`
import ammonite.ops._

import scala.util.Try
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package org.scalablytyped.converter.internal

import _root_.io.circe013.syntax._
import _root_.io.circe013.syntax.*
import com.olvind.logging.{Formatter, Logger}
import gigahorse.support.okhttp.Gigahorse
import okhttp3.{OkHttpClient, Request, Response}
import gigahorse.support.apachehttp.Gigahorse
import gigahorse.{HttpClient, Request}
import org.scalablytyped.converter.internal.ImportTypings.InOut
import org.scalablytyped.converter.internal.compat.CompletableFutureOps
import org.scalablytyped.converter.internal.importer.Cmd
import org.scalablytyped.converter.internal.seqs._
import org.scalablytyped.converter.internal.seqs.*
import org.scalablytyped.converter.plugin.RemoteCache
import org.scalablytyped.converter.plugin.ScalablyTypedPluginBase.autoImport.{stDir, stRemoteCache}
import sbt.{Def, Global, Task, TaskKey}
Expand All @@ -21,9 +21,9 @@ import software.amazon.awssdk.services.s3.{S3AsyncClient, S3AsyncClientBuilder}

import java.net.URI
import java.util.concurrent.CompletionException
import scala.concurrent.duration._
import scala.concurrent.duration.*
import scala.concurrent.{Await, ExecutionContext, Future}
import scala.util.control.NonFatal
import scala.util.{Failure, Success}

object RunCache {
case class Key(input: ImportTypings.Input) {
Expand Down Expand Up @@ -161,15 +161,15 @@ object RunCache {
def pull(pullUri: URI) =
Lock.synchronized {
val downloads: Future[Present] =
mehttp.ensureDownloaded(pullUri / localRunFile.relativeTo(cacheDir), localRunFile).flatMap {
ensureDownloaded(pullUri / localRunFile.relativeTo(cacheDir), localRunFile).flatMap {
case yes: PresentFile.Yes =>
val (input, output) = Json.force[InOut](new String(yes.bytes, constants.Utf8))

require(input === key.input)

val files: Seq[Future[PresentFile]] =
output.allRelPaths
.map(relPath => mehttp.ensureDownloaded(uri = pullUri / relPath, dest = ivyLocal / relPath))
.map(relPath => ensureDownloaded(uri = pullUri / relPath, dest = ivyLocal / relPath))

Future.sequence(files).map { presentFiles: Seq[PresentFile] =>
// format: off
Expand Down Expand Up @@ -249,54 +249,30 @@ object RunCache {
}
}

// Meh, I have no idea
//
// The combination of futures, execution contexts, gigahorse, okhttp is broken and starts failing requests east and west
// on any parallelism, like this:
// java.util.concurrent.RejectedExecutionException: Task okhttp3.RealCall$AsyncCall@6495a32c rejected from java.util.concurrent.ThreadPoolExecutor@6acf64c2[Terminated, pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 1]
//
// This here duplicates just enough working code from sbt and adapts it so things at least work.
// Also I've tried to not take any more dependencies on third party code into the sbt giga classloader,
// as conflicts are more or less guaranteed.
object mehttp {

private lazy val http: OkHttpClient =
Gigahorse
.http(gigahorse.Config().withReadTimeout(60.minutes))
.underlying[OkHttpClient]
.newBuilder()
.authenticator(new sbt.internal.librarymanagement.JavaNetAuthenticator)
.followRedirects(true)
.followSslRedirects(true)
.build

def ensureDownloaded(uri: URI, dest: os.Path)(implicit ec: ExecutionContext): Future[PresentFile] =
if (files.exists(dest)) Future.successful(PresentFile.Cached(dest))
else
Future {
getUrl(uri) match {
case ok @ PresentFile.Downloaded(bytes) =>
files.writeBytes(dest.toNIO, bytes)
ok
case otherwise => otherwise
}
}
private lazy val http: HttpClient =
Gigahorse
.http(gigahorse.Config().withReadTimeout(60.minutes).withFollowRedirects(true))

def ensureDownloaded(uri: URI, dest: os.Path)(implicit ec: ExecutionContext): Future[PresentFile] =
if (files.exists(dest)) Future.successful(PresentFile.Cached(dest))
else
getUrl(uri).map {
case ok @ PresentFile.Downloaded(bytes) =>
files.writeBytes(dest.toNIO, bytes)
ok
case otherwise => otherwise
}

private def getUrl(uri: URI): PresentFile = {
var response: Response = null
try {
response = http.newCall(new Request.Builder().url(uri.toString).get().build()).execute()
response.code() match {
case success if success > 199 && success < 300 => PresentFile.Downloaded(response.body().bytes())
private def getUrl(uri: URI)(implicit ec: ExecutionContext): Future[PresentFile] =
http.run(Request(uri.toString)).transform {
case Success(response) =>
val res = response.status match {
case success if success > 199 && success < 300 => PresentFile.Downloaded(response.bodyAsByteBuffer.array())
case 404 => PresentFile.NotFound
case 403 => PresentFile.Forbidden
case other => PresentFile.Err(new RuntimeException(s"Got status code $other"))
}
} catch {
case NonFatal(th) => PresentFile.Err(th)
} finally {
if (response != null) response.close()
}
Success(res)
case Failure(th) => Success(PresentFile.Err(th))
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,10 @@ object ScalablyTypedPluginBase extends AutoPlugin {
Global / Keys.onLoad := (state => {
val old = (Global / Keys.onLoad).value
Keys.sbtVersion.value match {
case valid if valid.startsWith("1.5") || valid.startsWith("1.6") || valid.startsWith("1.7") => old(state)
case valid if valid.startsWith("1.7") => old(state)
case invalid =>
sys.error(
s"This version of the ScalablyTyped plugin only supports sbt 1.5.x, 1.6.x and 1.7.x. You're currently using $invalid",
s"This version of the ScalablyTyped plugin only supports 1.7.x. You're currently using $invalid",
)
}
}),
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.7.0
sbt.version=1.7.1
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.6.0
sbt.version=1.7.1
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.5.7
sbt.version=1.7.1
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package scalajs
import io.circe013.{Decoder, Encoder}

object Versions {
val sbtVersion = "1.5.5"
val sbtVersion = "1.7.1"

// this accepts any nightly or milestone with the same binversion as a major release. good enough for now
private val Version = "(\\d+).(\\d+).(\\d+).*".r
Expand Down
2 changes: 1 addition & 1 deletion tests/antd/check-3/a/antd/project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.5.5
sbt.version=1.7.1
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.5.5
sbt.version=1.7.1
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.5.5
sbt.version=1.7.1
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.5.5
sbt.version=1.7.1
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.5.5
sbt.version=1.7.1
2 changes: 1 addition & 1 deletion tests/aws-sdk/check-3/a/aws-sdk/project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.5.5
sbt.version=1.7.1
2 changes: 1 addition & 1 deletion tests/babylon/check-3/b/babylon/project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.5.5
sbt.version=1.7.1
2 changes: 1 addition & 1 deletion tests/babylon/check-3/n/node/project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.5.5
sbt.version=1.7.1
2 changes: 1 addition & 1 deletion tests/bigint/check-3/b/bigint/project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.5.5
sbt.version=1.7.1
2 changes: 1 addition & 1 deletion tests/bigint/check-3/s/std/project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.5.5
sbt.version=1.7.1
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.5.5
sbt.version=1.7.1
2 changes: 1 addition & 1 deletion tests/chart.js/check-3/s/std/project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.5.5
sbt.version=1.7.1
2 changes: 1 addition & 1 deletion tests/cldrjs/check-3/c/cldrjs/project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.5.5
sbt.version=1.7.1
2 changes: 1 addition & 1 deletion tests/cldrjs/check-3/s/std/project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.5.5
sbt.version=1.7.1
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.5.5
sbt.version=1.7.1
2 changes: 1 addition & 1 deletion tests/commander/check-3/n/node/project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.5.5
sbt.version=1.7.1
2 changes: 1 addition & 1 deletion tests/commander/check-3/s/std/project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.5.5
sbt.version=1.7.1
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.5.5
sbt.version=1.7.1
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.5.5
sbt.version=1.7.1
2 changes: 1 addition & 1 deletion tests/create-error/check-3/s/std/project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.5.5
sbt.version=1.7.1
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.5.5
sbt.version=1.7.1
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.5.5
sbt.version=1.7.1
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.5.5
sbt.version=1.7.1
2 changes: 1 addition & 1 deletion tests/echarts/check-3/e/echarts/project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.5.5
sbt.version=1.7.1
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.5.5
sbt.version=1.7.1
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.5.5
sbt.version=1.7.1
2 changes: 1 addition & 1 deletion tests/electron/check-3/e/electron/project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.5.5
sbt.version=1.7.1
2 changes: 1 addition & 1 deletion tests/electron/check-3/n/node/project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.5.5
sbt.version=1.7.1
2 changes: 1 addition & 1 deletion tests/electron/check-3/s/std/project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.5.5
sbt.version=1.7.1
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.5.5
sbt.version=1.7.1
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.5.5
sbt.version=1.7.1
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.5.5
sbt.version=1.7.1
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.5.5
sbt.version=1.7.1
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.5.5
sbt.version=1.7.1
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.5.5
sbt.version=1.7.1
2 changes: 1 addition & 1 deletion tests/firebase/check-3/f/firebase/project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.5.5
sbt.version=1.7.1
2 changes: 1 addition & 1 deletion tests/fp-ts/check-3/f/fp-ts/project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.5.5
sbt.version=1.7.1
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.5.5
sbt.version=1.7.1
2 changes: 1 addition & 1 deletion tests/insight/check-3/i/insight/project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.5.5
sbt.version=1.7.1
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.5.5
sbt.version=1.7.1
2 changes: 1 addition & 1 deletion tests/keyof/check-3/k/keyof/project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.5.5
sbt.version=1.7.1
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.5.5
sbt.version=1.7.1
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.5.5
sbt.version=1.7.1
Loading

0 comments on commit ca6468d

Please sign in to comment.