Deprecate HTTP resolvers (take 2)

Ref https://github.com/sbt/sbt/issues/4905

This is a companion PR to https://github.com/sbt/librarymanagement/pull/318.

This will print the following warnings:

```
sbt:hello> compile
[warn] insecure HTTP request is deprecated 'Artifact(jsoup, jar, jar, None, Vector(), Some(http://jsoup.org/packages/jsoup-1.9.1.jar), Map(), None, false)'; switch to HTTPS or opt-in using from(url(...), allowInsecureProtocol = true) on ModuleID or .withAllowInsecureProtocol(true) on Artifact
[warn] insecure HTTP request is deprecated 'http://repo.typesafe.com/typesafe/releases/'; switch to HTTPS or opt-in as ("Typesafe Releases" at "http://repo.typesafe.com/typesafe/releases/").withAllowInsecureProtocol(true)
[warn] insecure HTTP request is deprecated 'http://repo.typesafe.com/typesafe/releases/'; switch to HTTPS or opt-in as ("Typesafe Releases" at "http://repo.typesafe.com/typesafe/releases/").withAllowInsecureProtocol(true)
[warn] insecure HTTP request is deprecated 'http://repo.typesafe.com/typesafe/releases/'; switch to HTTPS or opt-in as ("Typesafe Releases" at "http://repo.typesafe.com/typesafe/releases/").withAllowInsecureProtocol(true)
[warn] insecure HTTP request is deprecated 'Patterns(ivyPatterns=Vector(), artifactPatterns=Vector(http://repo.typesafe.com/typesafe/releases/[organisation]/[module](_[scalaVersion])(_[sbtVersion])/[revision]/[artifact]-[revision](-[classifier]).[ext]), isMavenCompatible=true, descriptorOptional=false, skipConsistencyCheck=false)'; switch to HTTPS or opt-in as Resolver.url("Typesafe Ivy Releases", url(...)).withAllowInsecureProtocol(true)
[warn] insecure HTTP request is deprecated 'Patterns(ivyPatterns=Vector(), artifactPatterns=Vector(http://repo.typesafe.com/typesafe/releases/[organisation]/[module](_[scalaVersion])(_[sbtVersion])/[revision]/[artifact]-[revision](-[classifier]).[ext]), isMavenCompatible=true, descriptorOptional=false, skipConsistencyCheck=false)'; switch to HTTPS or opt-in as Resolver.url("Typesafe Ivy Releases", url(...)).withAllowInsecureProtocol(true)
[warn] insecure HTTP request is deprecated 'Patterns(ivyPatterns=Vector(), artifactPatterns=Vector(http://repo.typesafe.com/typesafe/releases/[organisation]/[module](_[scalaVersion])(_[sbtVersion])/[revision]/[artifact]-[revision](-[classifier]).[ext]), isMavenCompatible=true, descriptorOptional=false, skipConsistencyCheck=false)'; switch to HTTPS or opt-in as Resolver.url("Typesafe Ivy Releases", url(...)).withAllowInsecureProtocol(true)
```
This commit is contained in:
Eugene Yokota 2019-08-28 15:30:38 -04:00
parent c38ce111fe
commit 75e609cba2
3 changed files with 14 additions and 2 deletions

View File

@ -2548,6 +2548,14 @@ object Classpaths {
}
}
private[sbt] def warnInsecureProtocol(ress: Seq[Resolver], log: Logger): Unit = {
ress.foreach(_.validateProtocol(log))
}
// this warns about .from("http:/...") in ModuleID
private[sbt] def warnInsecureProtocolInModules(mods: Seq[ModuleID], log: Logger): Unit = {
mods.foreach(_.validateProtocol(log))
}
private[sbt] def defaultProjectID: Initialize[ModuleID] = Def.setting {
val base = ModuleID(organization.value, moduleName.value, version.value)
.cross(crossVersion in projectID value)
@ -2573,10 +2581,12 @@ object Classpaths {
new IvySbt(ivyConfiguration.value, CustomHttp.okhttpClient.value)
}
def moduleSettings0: Initialize[Task[ModuleSettings]] = Def.task {
val deps = allDependencies.value.toVector
warnInsecureProtocolInModules(deps, streams.value.log)
ModuleDescriptorConfiguration(projectID.value, projectInfo.value)
.withValidate(ivyValidate.value)
.withScalaModuleInfo(scalaModuleInfo.value)
.withDependencies(allDependencies.value.toVector)
.withDependencies(deps)
.withOverrides(dependencyOverrides.value.toVector)
.withExcludes(allExcludeDependencies.value.toVector)
.withIvyXML(ivyXML.value)
@ -3203,6 +3213,7 @@ object Classpaths {
val (rs, other) = (fullResolvers.value.toVector, otherResolvers.value.toVector)
val s = streams.value
warnResolversConflict(rs ++: other, s.log)
warnInsecureProtocol(rs ++: other, s.log)
InlineIvyConfiguration()
.withPaths(ivyPaths.value)
.withResolvers(rs)

View File

@ -91,6 +91,7 @@ object LMCoursier {
val sbtScalaOrganization = "org.scala-lang" // always assuming sbt uses mainline scala
val userForceVersions = Inputs.forceVersions(depsOverrides, scalaVer, scalaBinaryVer)
Classpaths.warnResolversConflict(rs, log)
Classpaths.warnInsecureProtocol(rs, log)
CoursierConfiguration()
.withResolvers(rs.toVector)
.withInterProjectDependencies(interProjectDependencies.toVector)

View File

@ -15,7 +15,7 @@ object Dependencies {
private val lmVersion =
sys.props.get("sbt.build.lm.version") match {
case Some(version) => version
case _ => nightlyVersion.getOrElse("1.3.0-M6")
case _ => nightlyVersion.getOrElse("1.3.0-M7")
}
val zincVersion = nightlyVersion.getOrElse("1.3.0-M9")