如何使用SBT的命令“发布 - 本地”到maven回购?

时间:2015-04-09 08:59:23

标签: maven sbt scala-breeze

第一个项目是SBT项目。命令"发布 - 本地"只发布罐到本地.ivy存储库。但是,另一个项目是一个maven项目。我想要SBT"发布 - 本地"到maven存储库。所以另一个项目可以从.m2存储库中引用它们。我不知道该怎么做?

这是build.sbt:

organization := "org.scalanlp"

name := "breeze-parent"

lazy val root = project.in( file(".") )
.aggregate(math, natives, viz, macros).dependsOn(math, viz)

lazy val macros = project.in( file("macros"))

lazy val math = project.in( file("math")).dependsOn(macros)

lazy val natives = project.in(file("natives")).dependsOn(math)

lazy val viz = project.in( file("viz")).dependsOn(math)

lazy val benchmark = project.in(file("benchmark")).dependsOn(math, natives)

scalaVersion := Common.scalaVersion

crossScalaVersions  := Common.crossScalaVersions

addCompilerPlugin("org.scalamacros" %% "paradise" % "2.0.1" cross CrossVersion.full)

publishMavenStyle := true

publishTo <<= version { (v: String) =>
  val nexus = "https://oss.sonatype.org/"
  if (v.trim.endsWith("SNAPSHOT"))
    Some("snapshots" at nexus + "content/repositories/snapshots")
  else
    Some("releases"  at nexus + "service/local/staging/deploy/maven2")
}

publishArtifact in Test := false

pomIncludeRepository := { _ => false }

pomExtra := (
  <url>http://scalanlp.org/</url>
  <licenses>
    <license>
      <name>Apache 2</name>
      <url>http://www.apache.org/licenses/LICENSE-2.0.html</url>
      <distribution>repo</distribution>
    </license>
  </licenses>
  <scm>
    <url>git@github.com:scalanlp/breeze.git</url>
    <connection>scm:git:git@github.com:scalanlp/breeze.git</connection>
  </scm>
  <developers>
    <developer>
      <id>dlwh</id>
      <name>David Hall</name>
      <url>http://www.dlwh.org/</url>
    </developer>
  </developers>)

2 个答案:

答案 0 :(得分:50)

请使用publishM2任务。它的文档说“将工件发布到本地Maven存储库”。

sbt publishM2

答案 1 :(得分:1)

这是按照 Ajay 回答说 publishM2 的文档:

<块引用>

publishLocal 任务将发布到“本地”常春藤存储库...

与publishLocal类似,publishM2任务会发布用户的Maven 本地存储库。这是在指定的位置 $HOME/.m2/settings.xml 或 $HOME/.m2/repository/ 默认情况下。其他 build 需要 Resolver.mavenLocal 来解决它:

resolvers += Resolver.mavenLocal