Skip to content

Instantly share code, notes, and snippets.

@adrobisch
Last active August 29, 2015 14:13
Show Gist options
  • Save adrobisch/689990492b972b33ee6e to your computer and use it in GitHub Desktop.
Save adrobisch/689990492b972b33ee6e to your computer and use it in GitHub Desktop.
sbt central publish for Java projects
import com.typesafe.sbt.SbtNativePackager._
import NativePackagerKeys._
net.virtualvoid.sbt.graph.Plugin.graphSettings
packageArchetype.java_application
organization := "com.example"
name := "example"
version := "1.0-SNAPSHOT"
crossPaths := false
autoScalaLibrary := false
packageDescription in Debian := "Example Package"
maintainer in Debian := "John Foo"
libraryDependencies ++= Seq(
"junit" % "junit" % "4.11" % "test"
)
publishMavenStyle := true
publishTo := {
val nexus = "https://oss.sonatype.org/"
if (isSnapshot.value)
Some("snapshots" at nexus + "content/repositories/snapshots")
else
Some("releases" at nexus + "service/local/staging/deploy/maven2")
}
pomExtra :=
<url>https://github.com/example/example</url>
<licenses>
<license>
<name>MIT</name>
<url>http://opensource.org/licenses/mit-license.php</url>
<distribution>repo</distribution>
</license>
</licenses>
<scm>
<url>git@github.com:example/example.git</url>
<connection>scm:git:git@github.com:example/example.git</connection>
</scm>
<developers>
<developer>
<id>johnfoon</id>
<name>John Foo</name>
<url>http://johnfoo.com</url>
</developer>
</developers>
mainClass in selectMainClass := Some("com.example.MainClass")
addCommandAlias("dist", "universal:packageBin")
Release
=======
1. Change version to release version in build.sbt (e.g. 1.1) and commit it.
2. Tag the version: git tag <newVersion>
3. Run: sbt publishSigned
4. Change version to next development version in build.sbt (e.g. 1.2-SNAPSHOT) and commit it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment