(rootProject/*:bintrayEnsureLicenses) 您必须为此项目定义至少一个许可证

(rootProject/*:bintrayEnsureLicenses) you must define at least one license for this project

我第一次尝试在 bintray 上发布我的项目。我在这里阅读了文档

https://github.com/sbt/sbt-bintray

我的plugins.sbt文件是

addSbtPlugin("org.foundweekends" % "sbt-bintray" % "0.5.1")

这是我的build.sbt。你可以看到我已经为我的项目定义了许可证

lazy val publishSettings =  Seq(
   licenses += ("MIT", url("http://opensource.org/licenses/MIT")),
   bintrayOrganization := Some("abhishes"),
   bintrayRepository := "AbhiTestRepo",
   bintrayPackageLabels := Seq("foo", "bar")
)

lazy val commonSettings = Seq(
   "organization" := "abhishes",
   version := "1.0",
   scalaVersion := "2.12.3"
)


lazy val project1 = (project in file("SubProject1")).settings(commonSettings)
   .settings(publishSettings)
   .settings(
      name := "SubProject1"
   )

lazy val project2 = (project in file("SubProject2")).settings(commonSettings)
   .settings(publishSettings)
   .settings(
      name := "SubProject2"
   )

lazy val rootProject = (project in file("."))
   .settings(commonSettings)
   .settings(publishSettings)
   .settings(
      name := "MyScalaProject"
).dependsOn(project1, project2)

当我说 sbt publish 时,我仍然遇到此错误

> publish
[trace] Stack trace suppressed: run last rootProject/*:bintrayEnsureLicenses for the full output.
[error] (rootProject/*:bintrayEnsureLicenses) you must define at least one license for this project. Please choose one or more of
[error]  AFL-3.0, AGPL-V3, APL-1.0, APSL-2.0, Apache-1.0, Apache-1.1, Apache-2.0, Artistic-License-2.0, Attribution, BSD, BSD New, BSD Simplified, BSL-1.0, Bouncy-Castle, CA-TOSL-1.1, CDDL-1.0, CPAL-1.0, CPL-1.0, CPOL-1.02, CUAOFFICE-1.0, Codehaus, Day, Day-Addendum, ECL2, EUDATAGRID, EUPL-1.1, Eclipse-1.0, Eiffel-2.0, Entessa-1.0, Fair, Frameworx-1.0, GPL-2.0, GPL-2.0+CE, GPL-3.0, HSQLDB, Historical, IBMPL-1.0, IPAFont-1.0, ISC, IU-Extreme-1.1.1, JA-SIG, JSON, JTidy, LGPL-2.1, LGPL-3.0, Lucent-1.02, MIT, MPL-2.0, MS-PL, MS-RL, MirOS, Motosoto-0.9.1, Mozilla-1.1, Multics, NASA-1.3, NAUMEN, NOSL-3.0, NTP, Nethack, Nokia-1.0a, OCLC-2.0, OSL-3.0, Openfont-1.1, Opengroup, PHP-3.0, PostgreSQL, Public Domain, Public Domain - SUN, PythonPL, PythonSoftFoundation, QTPL-1.0, RPL-1.5, Real-1.0, RicohPL, SUNPublic-1.0, SimPL-2.0, Sleepycat, Sybase-1.0, TMate, Unlicense, UoI-NCSA, VovidaPL-1.0, W3C, WTFPL, Xnet, ZLIB, ZPL-2.0, wxWindows
[error] Total time: 1 s, completed Aug 26, 2017 1:00:10 PM
> 

编辑:这是inspect licenses

的输出
> inspect licenses
[info] Setting: scala.collection.Seq[scala.Tuple2[java.lang.String, java.net.URL]] = List()
[info] Description:
[info]  Project licenses as (name, url) pairs.
[info] Provided by:
[info]  */*:licenses
[info] Defined at:
[info]  (sbt.Classpaths) Defaults.scala:1186
[info] Reverse dependencies:
[info]  rootProject/*:bintrayEnsureBintrayPackageExists
[info]  rootProject/*:projectInfo
[info]  rootProject/*:bintrayEnsureLicenses
[info] Delegates:
[info]  rootProject/*:licenses
[info]  {.}/*:licenses
[info]  */*:licenses
[info] Related:
[info]  */*:licenses
> 

Edit2:这是 inspect rootProject/licenses

的输出
> inspect rootProject/licenses
[info] Setting: scala.collection.Seq[scala.Tuple2[java.lang.String, java.net.URL]] = List()
[info] Description:
[info]  Project licenses as (name, url) pairs.
[info] Provided by:
[info]  */*:licenses
[info] Defined at:
[info]  (sbt.Classpaths) Defaults.scala:1186
[info] Reverse dependencies:
[info]  rootProject/*:bintrayEnsureBintrayPackageExists
[info]  rootProject/*:projectInfo
[info]  rootProject/*:bintrayEnsureLicenses
[info] Delegates:
[info]  rootProject/*:licenses
[info]  {.}/*:licenses
[info]  */*:licenses
[info] Related:
[info]  */*:licenses

我自己解决了这个问题。如果你查看插件的源代码

https://github.com/sbt/sbt-bintray/blob/7a14108bd273a8bb469ad118ccd7cce5b4042099/src/main/scala/Bintray.scala#L33

licenses的数据类型为Seq[(String, url)]

基于此,我相应地更改了我的代码,将许可证制作为类型 (String, url) 的元组序列,问题得到解决。

lazy val publishSettings =  Seq(
   licenses ++= Seq(("MIT", url("http://opensource.org/licenses/MIT"))),
   bintrayOrganization := Some("abhishes"),
   bintrayRepository := "AbhiTestRepo",
   bintrayPackageLabels := Seq("foo", "bar")
)