How to use command "publish-local" of SBT to maven repo?
Asked Answered
L

2

33

The first project is an SBT project. Command "publish-local" only publishes jars to the local .ivy repository. But, another project is a maven project. I want SBT "publish-local" to maven repository. So another project can reference them from the .m2 repository. I don't know what to do?

Here is 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>[email protected]:scalanlp/breeze.git</url>
        <connection>scm:git:[email protected]:scalanlp/breeze.git</connection>
      </scm>
      <developers>
        <developer>
          <id>dlwh</id>
          <name>David Hall</name>
          <url>http://www.dlwh.org/</url>
        </developer>
      </developers>)
Lampblack answered 9/4, 2015 at 8:59 Comment(3)
Could you check the 'publishM2' task? Its documentation says 'Publishes artifacts to the local Maven repository'Astrophotography
@AjayPadala Yep I think that's the answer. Are there cases in which it's better to answer in a comment? I'm still learning StackOverflow etiquette, but I'm pretty sure it's unkind to respond with the same answer after you've provided it in comment form.Mach
I'm not sure either, pretty new to this myself. changed to an answer :)Astrophotography
A
71

Please use the publishM2 task. Its documentation says "Publishes artifacts to the local Maven repository".

sbt publishM2
Astrophotography answered 9/4, 2015 at 9:58 Comment(0)
F
2

Here is the docs that says publishM2 as per Ajay answer:

The publishLocal task will publish to the “local” Ivy repository ...

Similar to publishLocal, publishM2 task will publish the user’s Maven local repository. This is at the location specified by $HOME/.m2/settings.xml or at $HOME/.m2/repository/ by default. Another build would require Resolver.mavenLocal to resolve out of it:

resolvers += Resolver.mavenLocal

Feinstein answered 12/5, 2021 at 10:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.