在开发期间,我使用以下语法:
lazy val root = project.in(file(".")).dependsOn(runner)
但是对于发布我需要这个:
libraryDependencies += ... % ... % ...
但是我不希望在开发期间存在libraryDependencies
这个东西,否则我需要发布每个编译都很烦人的本地。有没有什么好的解决方案可以在我发布时将其评论并重新发布?
答案 0 :(得分:4)
您不应将子项目添加为libraryDependencies
,即使在publish
期间也不应如此。
现在要发布模块,您可以创建一个简单的publishSettings
变量:
val publishSettings : Seq[Setting[_]] = Seq(
publishTo := Some("your company releases" at "http://yourrepository"),
credentials += Credentials(
"Repository",
"repositoryUrl",
"username",
"password!"
),
publishMavenStyle := true,
publishArtifact in Test := false,
pomIncludeRepository := { _ => true }
)
lazy val main = Project(..).aggregate(subproject1, subproject2, // etc)
lazy val subproject1 = Project(
settings = Project.defaultSettings ++ publishSettings
);
lazy val subproject2 = Project(
settings = Project.defaultSettings ++ publishSettings
).dependsOn(subproject1)
SBT现在将自动在后台重新编译依赖项。请勿将其添加为libraryDependencies
,只能将其添加到dependsOn
。