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

时间:2017-08-26 18:06:53

标签: scala sbt bintray

我第一次尝试在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

1 个答案:

答案 0 :(得分:2)

我能够自己解决问题。如果您查看插件的源代码

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

许可证的数据类型是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")
)