• Stars
    star
    23
  • Rank 1,016,462 (Top 21 %)
  • Language
  • License
    MIT License
  • Created over 8 years ago
  • Updated about 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Deploying scala libraries to central for dummies

Publishing a Scala library with SBT in Sonatype OSS for dummies:

Pedro Larroy @plarroy

When you use a modern dependency management tool like maven or sbt your dependencies get downloaded automatically. For most of us that's a magic process, most of the time it works and it's great. It really simplifies dependency management and makes us developers very productive.

That's done through the "central" repository, hosted by Sonatype free of charge for open source projects.

Let's say you have an open source project and want to release some artifacts for other people to use through this convenient process. This is a step-by-step guide on how to accomplish this, as the process can be a bit involved.

Setup sonatype account

  1. Follow the two steps in initial setup
  2. Create account
  3. Create a ticket Make sure to fill "Group Id" with your desired name or domain of your project. For example "org.example", let's call this $GROUP_ID

Setup project sbt

In build.sbt: we set "organization" to $GROUP_ID if this is not correct we will get a permission denied error when trying to release.

build.sbt: Make sure to include a "name" for your lib, for example "mylib"

Add the publishing boilerplate as seen in

build.sbt (Lines 22-55) adjusting the values to your project.

Add the "sbt-pgp" plugin globally to sbt:

mkdir -p ~/.sbt/0.13/plugins
echo 'addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.0.0")' > ~/.sbt/0.13/plugins/gpg.sbt

Start sbt in your project folder

sbt

Create a gpg key

sbt> pgp-cmd gen-key

This should create the public and private keys in ~/.sbt/gpg/

Or import a preexisting key

Alternatively if you have a gpg key you can import it and point the secret keyring of sbt gpg to it:

gpg --import secring.asc
$ cat .sbt/gpg.sbt
pgpSecretRing := file("/Users/xxxx/.gnupg/secring.gpg")

And skip the next step.

Import the key in your gpg keyring

cd ~/.sbt/gpg/
gpg --import secring.asc

Copy the key ID in the output:

gpg: key 526BA3C6: ...
         ^^^^^^^^

Import the public key into a public keyserver that central will use to verify your signed jars

gpg --send-keys --keyserver pgp.mit.edu 526BA3C6 pubring.asc

Make sure your sonatype credentials are available to sbt, put the following in

.sbt/0.13/sonatype.sbt

credentials += Credentials("Sonatype Nexus Repository Manager",
                           "oss.sonatype.org",
                           "<your username>",
                           "<your password>")

From the sbt console you can now do

sbt> publishSigned

This should upload the artifacts, .jar .pom with their respective signatures.

Go to Sonatype OSS to release

Login by cliking on the upper right corner of the screen When you first upload the artifacts they are in a "staging area" not yet released

Scroll down to your artifact and verify that it has the files you want, additionally you can verify the jar with jar tvf to check the contents screen shot 00

To release our artifact we need to first "Close" screen shot 01

Check in the activity tab that everything is successful, or address any issues encountered Click "Release" After a bit, we should be able to get the dependency in other projects by adding to the libraryDependencies

"org.example" %% "mylib" % "0.1"

That should be all, congratulations! your artifact should be available for the world at large to use!

You might want to also check the similar guide in the SBT documentation

More Repositories

1

uvpp

C++11 libuv wrapper
C++
178
star
2

clearskies_core

Open source, distributed, secure data synchronization using the clearskies protocol
C++
136
star
3

mycelium

An open source information retrieval system written in C++11 and Python. Aspires to be an alternative to Nutch / Lucene. It uses MongoDB as an storage engine.
C++
84
star
4

Dive-into-C--11

Book to describe the C++11 features
Python
52
star
5

osmcompiler

A framework in Python to process OpenStreetMap data
Python
44
star
6

wget2

A wget replacement written in Python3
Python
14
star
7

yfinanceng

Yahoo! Finance next gen python 3 / pandas market data downloader
Python
9
star
8

urlcpp

A cross platform C++ URL parser and normalizer aiming to be RFC3986 correct
C++
7
star
9

ec2_launch_scripts

A nifty set of scripts to launch ec2 instances for development. Uses boto and Ansible to provision.
Vim Script
4
star
10

pbs

pbs python utility focusing on stability and added win32 support
Python
3
star
11

milight

scala milight / limitless led library
Scala
2
star
12

mobac

Mobile atlas creator (mirror)
Java
2
star
13

varint-scala

Varint encoding in Scala
Scala
2
star
14

powerwall_mqtt

Tesla Powerwall to MQTT
Python
2
star
15

SLF4J_Akka_logging_adapter

SLF4J to Akka logging adapter, compose classes and traits using Slf4j logging into Akka actors with Akka native logging
Scala
2
star
16

gsync

2
star
17

fierro-rs

A NoSQL database written in Rust
Rust
2
star
18

sudoku

A sudoku puzzle solver based on depth-first search
C++
1
star
19

fusearch

A console full text search engine for PDF collections.
Python
1
star
20

avro_python3

Apache avro module for python3
Python
1
star
21

sqlite3pp

Improved sqlite3pp, a lightweight clean C++ sqlite3 wrapper
C++
1
star
22

spark_tutorial

Spark / FP tutorial
HTML
1
star