简体   繁体   English

工件ID中包含的Scala和Scala.js版本

[英]Scala and Scala.js version included in artifact id

I just successfully released my first Scala & Scala.js cross-building library to Sonatype and can now use the following two artifacts in my applicatons: 我刚刚将我的第一个Scala&Scala.js交叉构建库成功发布到Sonatype,现在可以在我的应用程序中使用以下两个工件:

My question now is: Why is the Scala and Scala.js version included in the artifact id? 我现在的问题是:为什么工件ID中包含Scala和Scala.js版本? I don't think I have seen such a thing before so I was wondering if I did something wrong. 我不认为我以前见过这样的事情,所以我想知道自己做错了什么。 Here is my build.sbt : https://github.com/fbaierl/scalajs-cross-compile-tarjan/blob/03954a3e2d1442ad339298a986209c1403c9692e/build.sbt 这是我的build.sbthttps : //github.com/fbaierl/scalajs-cross-compile-tarjan/blob/03954a3e2d1442ad339298a986209c1403c9692e/build.sbt

That's the way that Scala artifacts work. 这就是Scala工件的工作方式。 Pretty much all artifacts look like this -- it just isn't obvious when you use those artifacts in sbt, because (IIRC) the _2.12 is implied by the %% operator in sbt. 几乎所有工件都看起来像这样-在sbt中使用这些工件时并不明显,因为(IIRC) _2.12_2.12中的%%运算符隐含。 (And the _sjs0.6 is implied by the %%% operator.) (并且_sjs0.6%%%运算符隐含。)

The underlying reason for it is that artifacts compiled by different major versions of the Scala compiler (Scala versions are epoch.major.minor) aren't binary compatible (because otherwise the language and standard library couldn't evolve). 造成这种情况的根本原因是,由Scala编译器的不同主要版本(Scala版本为epoch.major.minor)编译的工件与二进制文件不兼容(因为否则语言和标准库将无法进化)。 You can't mix eg _2.12 and _2.11 artifacts on the classpath, so the “same” version of the same library must be published separately for both Scala versions, so the suffix is needed to distinguish them. 您不能在类路径上混合_2.12和_2.11等工件,因此对于两个Scala版本,必须分别发布同一库的“相同”版本,因此需要使用后缀来区分它们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM