Use SBT and Git to create Your Own Maven Repository

来源:转载

By leverage SBT and Git, it is very easy to deploy your own distributed Maven Repository.

Publishing to Maven Repository

In your build.sbt, add:

publishTo := Some(Resolver.file("file", new File(Path.userHome.absolutePath+"/mvn-repo")))

This publishTodefines the local directory for your Maven Repository. Alternatively you can also publish to http or ssh server. But that is out of the scope of this post.

To publish, run sbtcommand:

sbt publish

The published artifacts will be build for the scala version you use. You can specify the scala version in your build.sbt:

scalaVersion := "2.11.6" Cross-publishing

To support multiple incompatible Scala versions, use command:

sbt +publish

You can also specify the Scala versions for cross publishing in your build.sbt:

crossScalaVersions := Seq("2.9.3", "2.10.6") Push to servers

For me I push my personal Maven Repository to both Github and Bitbucket:

https://github.com/janzhou/mvn-repo https://bitbucket.org/janzhou/mvn-repo Use in Your Project

To use the Maven Repository in your project, you need to add the resolvers:

resolvers += "janzhou-github-mvn-repo" at "https://raw.githubusercontent.com/janzhou/mvn-repo/master" // for githubresolvers += "janzhou-bitbucket-mvn-repo" at "https://bitbucket.org/janzhou/mvn-repo/raw/master" // for bitbucket

Add artificial build for the scala version used:

libraryDependencies += "org.janzhou" %% "native" % "0.1.0"

Or specify the scala version:

libraryDependencies += "org.janzhou" % "native_2.11" % "0.1.0" Notice the difference between %% and % References http://brizzled.clapper.org/blog/2010/05/07/sbt-and-your-own-maven-repository/ http://cemerick.com/2010/08/24/hosting-maven-repos-on-github/ http://www.scala-sbt.org/0.13/docs/Publishing.html http://www.scala-sbt.org/0.13/docs/Cross-Build.html



分享给朋友:
您可能感兴趣的文章:
随机阅读: