将我的FAT Jar发布到本地sbt repo

时间:2017-07-15 01:44:25

标签: scala sbt

这是我的build.sbt文件

lazy val myproject = (project in file(".")).settings(
   name := "Slick3Test2",
   organization := "com.foo",
   version := "1.2",
   scalaVersion := "2.11.8",
   libraryDependencies ++= Seq(
      "com.typesafe.slick" %% "slick" % "3.2.0"
   ),
   assemblyShadeRules in assembly := Seq(
      ShadeRule.rename("slick.**" -> "shaded.@1").inAll
   ),
   artifact in (Compile, assembly) := {
      val art = (artifact in (Compile, assembly)).value
      art.copy(`classifier` = Some("assembly"))
   },
   addArtifact(artifact in (Compile, assembly), assembly)
)

我使用sbt publish-local

在本地发布了此内容

现在我引用了这是另一个项目build.sbt

name := "Slick2Test"

version := "1.0"

scalaVersion := "2.11.8"

libraryDependencies ++= Seq(
   "mysql" % "mysql-connector-java" % "5.1.36",
   "com.typesafe.slick" % "slick_2.11" % "2.1.0",
   "com.foo" %% "Slick3Test2" % "1.2"
)

但是我收到了错误

[info] Resolving jline#jline;2.12.1 ...
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  ::          UNRESOLVED DEPENDENCIES         ::
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  :: com.foo#Slick3Test2_2.11;1.2: java.text.ParseException: inconsistent module descriptor file found in '/Users/foo/.ivy2/local/com.foo/Slick3Test2_2.11/1.2/ivys/ivy.xml': bad module name: expected='Slick3Test2_2.11' found='slick3test2_2.11';
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]
[warn]  Note: Unresolved dependencies path:
[warn]      com.abhi:Slick3Test2_2.11:1.2 (/Users/foo/IdeaProjects/Slick2Test/build.sbt#L7-12)
[warn]        +- default:slick2test_2.11:1.0
[trace] Stack trace suppressed: run 'last *:ssExtractProject' for the full output.
[trace] Stack trace suppressed: run 'last *:update' for the full output.
[error] (*:ssExtractProject) sbt.ResolveException: unresolved dependency: com.foo#Slick3Test2_2.11;1.2: java.text.ParseException: inconsistent module descriptor file found in '/Users/foo/.ivy2/local/com.foo/Slick3Test2_2.11/1.2/ivys/ivy.xml': bad module name: expected='Slick3Test2_2.11' found='slick3test2_2.11';
[error] (*:update) sbt.ResolveException: unresolved dependency: com.foo#Slick3Test2_2.11;1.2: java.text.ParseException: inconsistent module descripto

1 个答案:

答案 0 :(得分:2)

您的错误与将FAT jar发布到本地存储库无关!

我认为错误本身就是描述性的:

([*A-Za-z]+(\s+)?([\d\-_]+)?)

特别是:com.foo#Slick3Test2_2.11;1.2: java.text.ParseException: inconsistent module descriptor file found in '/Users/foo/.ivy2/local/com.foo/Slick3Test2_2.11/1.2/ivys/ivy.xml': bad module name: expected='Slick3Test2_2.11' found='slick3test2_2.11';

话虽这么说,你的依赖应该看起来像:

expected='Slick3Test2_2.11' found='slick3test2_2.11';

如果您不确定图书馆的libraryDependencies ++= Seq( ... "com.foo" %% "slick3test2" % "1.2" ) 是什么,您可以随时自行查看:

artifactID

另请注意,${user.home}/.ivy2/local 存储库在local之前具有优先级,而且如果在cache缓存中找到某个库版本,则不会从外部服务器获取它