mirror of https://github.com/sbt/sbt.git
Merge remote-tracking branch 'origin/develop' into merge-develop
This commit is contained in:
commit
2e1bed8e5a
|
|
@ -10,12 +10,15 @@ jobs:
|
|||
include:
|
||||
- os: ubuntu-latest
|
||||
java: 8
|
||||
distribution: zulu
|
||||
jobtype: 1
|
||||
- os: ubuntu-latest
|
||||
java: 11
|
||||
distribution: temurin
|
||||
jobtype: 1
|
||||
- os: ubuntu-latest
|
||||
- os: macos-latest
|
||||
java: 17
|
||||
distribution: temurin
|
||||
jobtype: 1
|
||||
runs-on: ${{ matrix.os }}
|
||||
env:
|
||||
|
|
@ -26,11 +29,13 @@ jobs:
|
|||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
- name: Setup JDK
|
||||
uses: actions/setup-java@v3
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
distribution: temurin
|
||||
distribution: "${{ matrix.distribution }}"
|
||||
java-version: "${{ matrix.java }}"
|
||||
cache: sbt
|
||||
- name: Setup sbt
|
||||
uses: sbt/setup-sbt@v1
|
||||
- name: Build and test (1)
|
||||
if: ${{ matrix.jobtype == 1 }}
|
||||
shell: bash
|
||||
|
|
|
|||
|
|
@ -3,13 +3,15 @@
|
|||
*/
|
||||
package sbt.librarymanagement
|
||||
|
||||
import java.io.{ IOException, File }
|
||||
import java.io.{ File, IOException }
|
||||
import java.net.{ URI, URL }
|
||||
import scala.annotation.nowarn
|
||||
import scala.xml.XML
|
||||
import org.xml.sax.SAXParseException
|
||||
import sbt.util.Logger
|
||||
|
||||
import java.net.URI
|
||||
import scala.util.matching.Regex
|
||||
|
||||
final class RawRepository(val resolver: AnyRef, name: String) extends Resolver(name) {
|
||||
override def toString = "Raw(" + resolver.toString + ")"
|
||||
|
|
@ -400,20 +402,29 @@ private[librarymanagement] abstract class ResolverFunctions {
|
|||
def defaultRetrievePattern =
|
||||
"[type]s/[organisation]/[module]/" + PluginPattern + "[artifact](-[revision])(-[classifier]).[ext]"
|
||||
final val PluginPattern = "(scala_[scalaVersion]/)(sbt_[sbtVersion]/)"
|
||||
private[librarymanagement] def expandMavenSettings(str: String): String = {
|
||||
|
||||
private[librarymanagement] def expandMavenSettings(
|
||||
str: String,
|
||||
envVars: Map[String, String] = sys.env,
|
||||
props: Map[String, String] = sys.props.toMap
|
||||
): String = {
|
||||
// Aren't regular expressions beautifully clear and concise.
|
||||
// This means "find all ${...}" blocks, with the first group of each being the text between curly brackets.
|
||||
val findQuoted = "\\$\\{([^\\}]*)\\}".r
|
||||
val findQuoted = "\\$\\{([^}]*)}".r
|
||||
val env = "env\\.(.*)".r
|
||||
|
||||
findQuoted.replaceAllIn(
|
||||
str,
|
||||
_.group(1) match {
|
||||
case env(variable) => sys.env.getOrElse(variable, "")
|
||||
case property => sys.props.getOrElse(property, "")
|
||||
}
|
||||
regexMatch =>
|
||||
Regex.quoteReplacement {
|
||||
regexMatch.group(1) match {
|
||||
case env(variable) => envVars.getOrElse(variable, "")
|
||||
case property => props.getOrElse(property, "")
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
private[this] def mavenLocalDir: File = {
|
||||
def loadHomeFromSettings(f: () => File): Option[File] =
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -33,6 +33,13 @@ object ResolverExtraTest extends BasicTestSuite {
|
|||
)
|
||||
}
|
||||
|
||||
test("expandMavenSettings should preserve backslashes in environment variable values") {
|
||||
val path = """C:\foo\bar\baz"""
|
||||
val env = Map("SOME_PATH" -> path)
|
||||
|
||||
assert(Resolver.expandMavenSettings("${env.SOME_PATH}", env) == path)
|
||||
}
|
||||
|
||||
// - Helper functions ----------------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------------------------------
|
||||
def assertExpansion(input: String, expected: String) =
|
||||
|
|
|
|||
|
|
@ -79,9 +79,7 @@ object PomExtraDependencyAttributes {
|
|||
item.getQualifiedExtraAttributes.asInstanceOf[java.util.Map[String, String]].asScala.toMap
|
||||
}
|
||||
def filterCustomExtra(item: ExtendableItem, include: Boolean): Map[String, String] =
|
||||
qualifiedExtra(item).view.filterKeys { k =>
|
||||
qualifiedIsExtra(k) == include
|
||||
}.toMap
|
||||
qualifiedExtra(item).view.filterKeys { k => qualifiedIsExtra(k) == include }.toMap
|
||||
|
||||
def qualifiedIsExtra(k: String): Boolean =
|
||||
k.endsWith(ScalaVersionKey) || k.endsWith(SbtVersionKey)
|
||||
|
|
@ -109,17 +107,27 @@ object PomExtraDependencyAttributes {
|
|||
|
||||
/**
|
||||
* Creates the "extra" property values for DependencyDescriptors that can be written into a maven pom
|
||||
* so we don't loose the information.
|
||||
* so we don't lose the information.
|
||||
* @param s
|
||||
* @return
|
||||
*/
|
||||
def writeDependencyExtra(s: Seq[DependencyDescriptor]): Seq[String] =
|
||||
s.flatMap { dd =>
|
||||
val revId = dd.getDependencyRevisionId
|
||||
if (filterCustomExtra(revId, include = true).isEmpty)
|
||||
val filteredExtra = filterCustomExtra(revId, include = true)
|
||||
if (filteredExtra.isEmpty)
|
||||
Nil
|
||||
else
|
||||
revId.encodeToString :: Nil
|
||||
else {
|
||||
import scala.collection.JavaConverters._
|
||||
val revId0 = ModuleRevisionId.newInstance(
|
||||
revId.getOrganisation,
|
||||
revId.getName,
|
||||
revId.getBranch,
|
||||
revId.getRevision,
|
||||
filteredExtra.asJava
|
||||
)
|
||||
revId0.encodeToString :: Nil
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,13 +3,13 @@ package sbt.internal.librarymanagement
|
|||
import sbt.librarymanagement._
|
||||
import sbt.librarymanagement.syntax._
|
||||
import sbt.librarymanagement.ivy.UpdateOptions
|
||||
import Resolver._
|
||||
|
||||
object ModuleResolversTest extends BaseIvySpecification {
|
||||
override final val resolvers = Vector(
|
||||
DefaultMavenRepository,
|
||||
JavaNet2Repository,
|
||||
JCenterRepository,
|
||||
MavenRepository(
|
||||
"JFrog OSS Releases",
|
||||
"https://releases.jfrog.io/artifactory/oss-releases/"
|
||||
),
|
||||
Resolver.sbtPluginRepo("releases")
|
||||
)
|
||||
|
||||
|
|
@ -45,8 +45,7 @@ object ModuleResolversTest extends BaseIvySpecification {
|
|||
println(s"NORMAL RESOLUTION TIME $normalResolutionTime")
|
||||
println(s"FASTER RESOLUTION TIME $fasterResolutionTime")
|
||||
|
||||
// Check that faster resolution is at least 1/5 faster than normal resolution
|
||||
// This is a conservative check just to make sure we don't regress -- speedup is higher
|
||||
assert(fasterResolutionTime <= (normalResolutionTime * 0.80))
|
||||
// Check that faster resolution is faster
|
||||
assert(fasterResolutionTime < normalResolutionTime)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
addSbtPlugin("com.dwijnand" % "sbt-dynver" % "4.0.0")
|
||||
addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.1.2")
|
||||
addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "0.8.1")
|
||||
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.0.2")
|
||||
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.2")
|
||||
addSbtPlugin("org.scala-sbt" % "sbt-contraband" % "0.5.3")
|
||||
|
||||
scalacOptions += "-language:postfixOps"
|
||||
|
|
|
|||
Loading…
Reference in New Issue