Fix NoSuchMethodError when using coursier-based sbt launcher (#104)

This commit is contained in:
Alexandre Archambault 2019-07-26 15:36:50 +02:00 committed by GitHub
parent df3d5c627a
commit 4a27bd42bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 85 additions and 18 deletions

View File

@ -0,0 +1 @@
scalaVersion := "2.13.0"

View File

@ -0,0 +1,4 @@
# currently, the coursier-based sbt launcher starts sbt in the scripted tests
# without the coursier sbt plugins. This pulls the lm-coursier-shaded version
# that sbt depends on, which lacks some methods
> updateClassifiers

View File

@ -0,0 +1,2 @@
# testing regression since this sbt version
sbt.version=1.3.0-RC1

View File

@ -0,0 +1,13 @@
addSbtPlugin {
val name = sys.props.getOrElse(
"plugin.name",
sys.error("plugin.name Java property not set")
)
val version = sys.props.getOrElse(
"plugin.version",
sys.error("plugin.version Java property not set")
)
"io.get-coursier" % name % version
}

View File

@ -50,24 +50,71 @@ object Foo {
else Def.task((evictionWarningOptions in update).value)
}.value
LibraryManagement.cachedUpdate(
// LM API
lm = lm,
// Ivy-free ModuleDescriptor
module = ivyModule.value,
s.cacheStoreFactory.sub(updateCacheName.value),
Reference.display(thisProjectRef.value),
updateConf,
identity,
skip = (skip in update).value,
force = shouldForce,
depsUpdated = transitiveUpdate.value.exists(!_.stats.cached),
uwConfig = (unresolvedWarningConfiguration in update).value,
ewo = evictionOptions,
mavenStyle = publishMavenStyle.value,
compatWarning = compatibilityWarningOptions.value,
log = s.log
)
try {
LibraryManagement.cachedUpdate(
// LM API
lm = lm,
// Ivy-free ModuleDescriptor
module = ivyModule.value,
s.cacheStoreFactory.sub(updateCacheName.value),
Reference.display(thisProjectRef.value),
updateConf,
identity,
skip = (skip in update).value,
force = shouldForce,
depsUpdated = transitiveUpdate.value.exists(!_.stats.cached),
uwConfig = (unresolvedWarningConfiguration in update).value,
ewo = evictionOptions,
mavenStyle = publishMavenStyle.value,
compatWarning = compatibilityWarningOptions.value,
log = s.log
)
} catch {
case _: NoSuchMethodError =>
// cachedUpdate method changed in https://github.com/sbt/sbt/commit/6c7faf2b8611f122a37b824c6e08e950855d939f
import sbt.internal.librarymanagement.CompatibilityWarningOptions
import sbt.librarymanagement.{DependencyResolution, ModuleDescriptor, UnresolvedWarningConfiguration, UpdateConfiguration}
import sbt.util.CacheStoreFactory
LibraryManagement.asInstanceOf[{
def cachedUpdate(
lm: DependencyResolution,
module: ModuleDescriptor,
cacheStoreFactory: CacheStoreFactory,
label: String,
updateConfig: UpdateConfiguration,
transform: UpdateReport => UpdateReport,
skip: Boolean,
force: Boolean,
depsUpdated: Boolean,
uwConfig: UnresolvedWarningConfiguration,
ewo: EvictionWarningOptions,
mavenStyle: Boolean,
compatWarning: CompatibilityWarningOptions,
includeCallers: Boolean,
includeDetails: Boolean,
log: Logger
): UpdateReport
}].cachedUpdate(
// LM API
lm = lm,
// Ivy-free ModuleDescriptor
module = ivyModule.value,
s.cacheStoreFactory.sub(updateCacheName.value),
Reference.display(thisProjectRef.value),
updateConf,
identity,
skip = (skip in update).value,
force = shouldForce,
depsUpdated = transitiveUpdate.value.exists(!_.stats.cached),
uwConfig = (unresolvedWarningConfiguration in update).value,
ewo = evictionOptions,
mavenStyle = publishMavenStyle.value,
compatWarning = compatibilityWarningOptions.value,
includeCallers = false,
includeDetails = false,
log = s.log
)
}
}
}