maven


Publish SBT project to local directory


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.
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.
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?
I figured out how you can do this. This solution creates a local Ivy repository, which is compatible with Maven.
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
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"
For more information, see SBT: Getting Started Library Dependencies and SBT: Publishing.
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.

Related Links

How do I get Maven to work in RHEL 7.x when there are npm install errors?
Releasing multiple projects with custome staging to Maven Central
Maven tool is not set in Jenkins pipeline
I cann't create maven project with myeclipse2016
Maven:Including jars from remote repository
tell maven to get JAR dependency from given URL
Repairslab software editing [closed]
what is the best way to upload file with javaee maven
Maven Error “cant find or load main class…”
I run a maven project with the package goal. I defined the main class in the manifest but I still cannot have the jar file run in command prompt. Why?
Why including bom doesn't work?
runtime deployment of decision table in KIE
java.lang.IllegalArgumentException: At least one JPA metamodel must be present
Defining suppressions filter in checkstyle.xml vs pom.xml - maven-checkstyle plugin
Missing artifact org.glassfish.jersey.media:jaxrs-media-moxy:jar:2.16 in Maven project in Eclipse ,what to do?
Sonatype Nexus 3 stuck on OnLine - Ready To Connect status for proxies

Categories

HOME
ms-access
yii2
clips
amazon-ec2
magnific-popup
minimum-spanning-tree
syntax
analysis
tizen-web-app
graphql
frameworks
disassembler
cross-validation
amazon-cloudformation
elasticsearch-hadoop
tomcat6
hex-editors
invantive-sql
google-pagespeed
autocad-plugin
paging
xlsxwriter
autoconf
clickonce
hammerspoon
smb
shopware
brunch
minitab
stormpath
twilio-api
uisplitview
catel
lxd
y86
mapbox-gl
nssegmentedcontrol
plsql-psp
adobe-premiere
multilingual
withings
user-controls
unoconv
android-tabhost
galen
gzipstream
fakeiteasy
galleria
fault
azure-application-gateway
errordocument
multipeer-connectivity
alphabet
sage-one
return-value
tizen-native-app
statsd
mplayer
tactic
media-player
imanage
chord-diagram
smart-table
or-tools
jquery-filter
url-pattern
deadbolt-2
elements
multi-level
nsfilemanager
merge-conflict-resolution
pickadate
freelancer.com-api
ora-00900
t4mvc
django-unittest
dukescript
drawbitmap
ami
dereference
tt-news
mdt
markers
responsive-slides
tld
navigationservice
elliptic-curve
seaside
didselectrowatindexpath
terminal-services
gridfs
inbox
google-cloud-save
gridcontrol
pushbackinputstream
sqlperformance
comaddin
cassini-dev
free-variable
gdata-api
frameset
dbproviderfactories
infobox
xmlspy
cxxtest
revisions
multiple-languages

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App