38

Since most IDEs are only able to import Maven projects, I'd like to generate a POM.xml from an SBT managed project, is there a better way to do it?

Kevin Wright
  • 49,540
  • 9
  • 105
  • 155
Sawyer
  • 15,581
  • 27
  • 88
  • 124

3 Answers3

49

Did you try make-pom from sbt?

It generates basic POM for the current project at the ./target. To customize generation, you can override pomExtra, pomIncludeRepository and pomPostProcess at the project definition.

Saurabh
  • 71,488
  • 40
  • 181
  • 244
Vasil Remeniuk
  • 20,519
  • 6
  • 71
  • 81
  • 1
    I tried make-pom, I think my IDE only reads pom.xml file to import a project, do I need to create it manually? – Sawyer Feb 21 '11 at 15:47
  • 4
    I use `make-pom` to import SBT projects into Netbeans (that supports only Maven- and Ant-based project out of the box). It has always been taking for me just to run `make-pom`, rename produced artifact definition to `pom.xml`, and move it to the project root (last two steps can be automated in SBT with `pomPostProcess`). – Vasil Remeniuk Feb 21 '11 at 15:50
  • @VasilRemeniuk I'm having some trouble trying to find how to do those two steps, the [documentation](http://www.scala-sbt.org/0.13/docs/Publishing.html) says it is a `Node => Node` function. Modifying the root [Node](http://www.scala-lang.org/api/2.10.3/index.html#scala.xml.Node) and children should be enough to modify the XML, but: how to move the file? Thank you. – Trylks Aug 09 '15 at 09:58
8

There is a very direct way provided by SBT. You can use the below command where your SBT file exixts:

sbt makePom

This will generate the .pom file in the target folder you can search that and rename to pom.xml and keep that file in the location and run mvn clean compile install to get full out of it.

Amit khandelwal
  • 504
  • 5
  • 6
6

Vasil's answer is correct, but for Eclipse and IDEA you can generate IDE metadata more directly using plugins. For IDEA https://github.com/mpeltonen/sbt-idea, and for Eclipse https://github.com/musk/SbtEclipsify .

James Iry
  • 19,367
  • 3
  • 64
  • 56