[英]Clarifying cross version behavior in Scala
I wonder what is the difference between the two here:我想知道这两者之间有什么区别:
addCompilerPlugin("org.typelevel" %% "kind-projector" % "0.11.3" cross CrossVersion.full)
// if your project uses multiple Scala versions, use this for cross building
addCompilerPlugin("org.typelevel" % "kind-projector" % "0.11.3" cross CrossVersion.full)
My understanding was that cross CrossVersion.full
add the full Scala version to the library eg我的理解是
cross CrossVersion.full
将完整的 Scala 版本添加到库中,例如
kind-project_2.13.4:0.11.3
and that %%
adds the Scala Binary version eg并且
%%
添加了 Scala 二进制版本,例如
kind-project_2.13:0.11.3
Hence I do not understand why we need cross CrossVersion.full
with both %
and %%
.因此,我不明白为什么我们需要
cross CrossVersion.full
与%
和%%
。 What's the difference?有什么不同?
I am pretty sure they are the same.我很确定它们是一样的。
From Overriding the publishing convention :从覆盖发布约定:
crossVersion setting can override the publishing convention:
crossVersion 设置可以覆盖发布约定:
CrossVersion.disabled
(no suffix)CrossVersion.disabled
(无后缀)CrossVersion.binary
(_)CrossVersion.binary
(_)CrossVersion.full
(_)CrossVersion.full
(_)The default is either
CrossVersion.binary
orCrossVersion.diabled
depending on the value of crossPaths.默认值为
CrossVersion.binary
或CrossVersion.diabled
,具体取决于 crossPaths 的值。
From More about using cross-built libraries :从更多关于使用交叉构建的库:
These are equivalent:
这些是等价的:
"a" %% "b" % "1.0" ("a" % "b" % "1.0").cross(CrossVersion.binary)
So eventually all it matters is the value of crossVersion
.所以最终重要的是
crossVersion
的值。
In order to test the crossVersion
, I created a simple task in my build.sbt
:为了测试
crossVersion
,我在build.sbt
中创建了一个简单的任务:
lazy val getVersion = taskKey[Unit]("A simple task")
getVersion := {
List(dep1, dep2, dep3, dep4).foreach { d =>
val att = Seq(d.organization ,d.name ,d.revision ,d.configurations ,d.isChanging ,d.isTransitive ,d.isForce ,d.explicitArtifacts ,d.inclusions ,d.exclusions ,d.extraAttributes ,d.crossVersion ,d.branchName)
println(att)
}
}
lazy val dep1 = "org.typelevel" % "kind-projector" % "0.11.3" cross CrossVersion.full
lazy val dep2 = "org.typelevel" %% "kind-projector" % "0.11.3" cross CrossVersion.full
lazy val dep3 = "org.typelevel" % "kind-projector" % "0.11.3"
lazy val dep4 = "org.typelevel" %% "kind-projector" % "0.11.3"
The output of sbt getVersion
is: sbt getVersion
的 output 为:
List(org.typelevel, kind-projector, 0.11.3, None, false, true, false, Vector(), Vector(), Vector(), Map(), Full(, ), None)
List(org.typelevel, kind-projector, 0.11.3, None, false, true, false, Vector(), Vector(), Vector(), Map(), Full(, ), None)
List(org.typelevel, kind-projector, 0.11.3, None, false, true, false, Vector(), Vector(), Vector(), Map(), Disabled(), None)
List(org.typelevel, kind-projector, 0.11.3, None, false, true, false, Vector(), Vector(), Vector(), Map(), Binary(, ), None)
As we can see, all of the modules are equivalent, except for crossVersion
, which in both dep1
, and dep2
is Full(, )
.正如我们所看到的,所有模块都是等价的,除了
crossVersion
,它在dep1
和dep2
中都是Full(, )
。 Unlike the two others which are Disabled()
and Binary(, )
.与其他两个
Disabled()
和Binary(, )
不同。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.