Publish SBT project to local directory

前端 未结 2 715
终归单人心
终归单人心 2021-01-02 01:21

I am trying to publish some of my SBT projects on my personal webserver. As far as I know you usually export a SBT project as a Maven directory including a POM.xml, that con

2条回答
  •  借酒劲吻你
    2021-01-02 01:39

    From sbt, you can use

    project myproject
    [myproject] $ publish-local
    

    Which will publish to your local ivy directory (usually ~/.ivy2/local).

    In the output you will see the paths of all the files:

    [info] Done packaging.
    [info] published myproject_2.9.1 to .../ivy2/...myproject.../poms/myproject_2.9.1.pom
    [info] published myproject_2.9.1 to .../ivy2/...myproject.../jars/myproject_2.9.1.jar
    [info] published myproject_2.9.1 to .../ivy2/...myproject.../srcs/myproject_2.9.1-sources.jar
    [info] published myproject_2.9.1 to .../ivy2/...myproject.../docs/myproject_2.9.1-javadoc.jar
    [info] published ivy to .../ivy2/...myproject.../ivys/ivy.xml
    

    Then you can grab those files and upload them to your ftp server.

    I would still recommend the approach described in the linked blogpost though. At least that's how we do it. Just a small note on storing credentials. Use the following sbt setting:

    val credentials = Credentials(Path.userHome / ".ivy2" / ".my-credentials")
    

    The credentials file will look like this:

    realm=Sonatype Nexus Repository Manager
    host=nexus.example.com
    user=deployment
    password=pass
    

    The credentials are the same you use for logging in to the Nexus web interface.

提交回复
热议问题