将 SBT 项目发布到本地目录 [英] Publish SBT project to local directory

查看:15
本文介绍了将 SBT 项目发布到本地目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在我的个人网络服务器上发布我的一些 SBT 项目.据我所知,您通常将 SBT 项目导出为 Maven 目录,其中包含 POM.xml,其中包含项目定义.

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 contains the project definitions.

正如 Brian Clapper 指出的,您可以通过创建多个配置文件并使用 sbt publish 来发布这样的 Maven 存储库.在他的教程中,存储库是通过 FTP 传输的.

As Brian Clapper pointed out, you can publish such a Maven repository by creating several configuration files and using sbt publish. In his tutorial, the repository is transferred via FTP.

我想手动将我的 Maven 存储库推送到服务器,以便拥有更多控制权.你能给我一些提示,如何做到这一点?

I want to push my Maven repository to the server manually so I have more control. Can you give me some hints, how to accomplish this?

推荐答案

我想出了如何做到这一点.该解决方案创建了一个与 Maven 兼容的本地 Ivy 存储库.

I figured out how you can do this. This solution creates a local Ivy repository, which is compatible with Maven.

您必须在 build.sbt 中设置以下值:

You have to set the following values in your build.sbt:

name := "project-name"

organization := "org.example"

version := "0.0.0"

scalaVersion := "2.9.2"

publishTo := Some(Resolver.file("file", new File("/path/to/your/releases"))

之后,您可以发布您的版本

After that, you can publish your release

sbt publish

这将打印类似于以下行的内容

This will print something like the following lines

[info] Set current project to project-name (in build file:/path/to/your/project/)
[info] Updating {file:/path/to/your/project/}default-2e51ea...
[info] Packaging /path/to/your/project/target/scala-2.9.2/project-name_2.9.2-0.0.0-S
NAPSHOT-sources.jar ...
[info] Resolving org.scala-lang#scala-library;2.9.2 ...
[info] Done packaging.
[info] Done updating.
[info] :: delivering :: org.example#project-name_2.9.2;0.0.0 :: 0.0.0 :: release :: Tue Jul 24 15:41:04 CEST 2012
[info]  delivering ivy file to /path/to/your/project/target/scala-2.9.2/ivy-0.0.0.xml
[info] Wrote /path/to/your/project/target/scala-2.9.2/project-name_2.9.2-0.0.0.pom
[info] Packaging /path/to/your/project/target/scala-2.9.2/project-name_2.9.2-0.0.0.jar ...
[info] Done packaging.
[info]  published project-name_2.9.2 to /path/to/your/releases/org/example/project-name_2.9.2/0.0.0-SNAPSHOT/project-name_2.9.2-0.0.0.pom
[info]  published project-name_2.9.2 to /path/to/your/releases/org/example/project-name_2.9.2/0.0.0-SNAPSHOT/project-name_2.9.2-0.0.0.jar
[info]  published project-name_2.9.2 to /path/to/your/releases/org/example/project-name_2.9.2/0.0.0-SNAPSHOT/project-name_2.9.2-0.0.0-sources.jar
[info]  published project-name_2.9.2 to /path/to/your/releases/org/example/project-name_2.9.2/0.0.0-SNAPSHOT/project-name_2.9.2-0.0.0-javadoc.jar
[success] Total time: 1 s, completed 24.07.2012 15:41:05

您可以将生成的文件放在任何 Web 服务器上(例如 http://repo.example.org/)并使用它通过将以下行添加到您的 build.sbt 中,在另一个项目的构建脚本中:

You can put the generated files on any web server (e.g. http://repo.example.org/) and use it in the build script of another project by adding the following lines to your build.sbt:

resolvers += "Personal repository" at "http://repo.example.org/"

libraryDependencies += "org.example" % "project-name" % "0.0.0"

有关更多信息,请参阅SBT:入门库依赖项SBT:出版.

For more information, see SBT: Getting Started Library Dependencies and SBT: Publishing.

这篇关于将 SBT 项目发布到本地目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆