|
Publishing
sbt has movedsbt has now completely moved to GitHub. See https://github.com/harrah/xsbt/wiki/Publish. PublishThis page describes how to publish your project. Publishing consists of uploading a descriptor, such as an Ivy file or Maven POM, and artifacts, such as a jar or war, to a repository so that other projects can specify your project as a dependency. The publish-local action is used to publish your project to a local Ivy repository. By default, this local repository is in ${user.home}/.ivy2/local. You can then use this project from other projects on the same machine. The publish action is used to publish your project to a remote repository. To use publishing, you need to specify the repository to publish to and the credentials to use. To specify the repository, assign a repository to val publishTo and define the publishing style. For example, to upload to Nexus: override def managedStyle = ManagedStyle.Maven val publishTo = "Scala Tools Nexus" at "http://nexus.scala-tools.org/content/repositories/releases/" There are two ways to specify credentials for such a repository. The first is to specify them inline: Credentials.add("Sonatype Nexus Repository Manager", "nexus.scala-tools.org", "admin", "admin123")The second and better way is to load them from a file, for example: Credentials(Path.userHome / ".ivy2" / ".credentials", log) The credentials file is a properties file with keys realm, host, user, and password. For example: realm=Sonatype Nexus Repository Manager host=nexus.scala-tools.org user=admin password=admin123 Once this is set up, you can run publish. Even better, enable cross-building and do +publish. See Resolvers for other supported repositories. By default, the artifact to publish is a war for DefaultWebProject and a jar for DefaultProject. You can declare other types of artifacts to publish by defining Artifact instances. See the Artifacts page for details. To publish sources and javadocs, add artifact declarations and make the publish-local and publish actions depend on package-src and package-docs: override def packageDocsJar = defaultJarPath("-javadoc.jar")
override def packageSrcJar= defaultJarPath("-sources.jar")
val sourceArtifact = Artifact.sources(artifactID)
val docsArtifact = Artifact.javadoc(artifactID)
override def packageToPublishActions = super.packageToPublishActions ++ Seq(packageDocs, packageSrc)When managedStyle is ManagedStyle.Maven, a POM is generated by the make-pom action. Override the 'pomExtra' method to provide XML (scala.xml.NodeSeq) to insert directly into the generated pom. For example: override def pomExtra =
<licenses>
<license>
<name>Apache 2</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
</license>
</licenses>As of sbt 0.7.0, make-pom adds to the POM any Maven-style repositories you have declared. You can filter these by overriding pomRepositoryFilter, which by default excludes local repositories. For example, to only include local repositories: override def pomIncludeRepository(repo: MavenRepository) =
repo.root.startsWith("file:")There is also a pomPostProcess method that can be used to manipulate the final XML before it is written. It's signature is: def pomPostProcess(pom: Node): Node | |
Mark, regarding publish-local you wrote: "You can then use this project from other projects on the same machine."
But how is the latter being done? Is it in the predefines? The Resolvers page did not mention it, nor the LibraryManagement page
Declare it as any other dependency:
Whether to support the dav protocol?
val publishTo = "Scala Tools Nexus" at "dav:http://nexus.scala-tools.org/content/repositories/releases/"
sbt is refusing to send authentication to the nexus server (local repo in our network)....i looked at the nexus log files and it appears that sbt fails to send any authentication info whatsoever.
Any ides as to why this is happening?
Just thought I'd follow up on this in case anyone ends with the same problem. The thing was the the Realm setting needs to be exactly "Sonatype Nexus Repository Manager" or you can change it in the nexus conf file.