2

I have a dependency in a scala project which I want to include in it so that it will be available in the project without having to use the Internet for everyone who uses the project. In other words, I want to do kind of "publish local" but a little differently: publish local publishes it locally only at my machine and everyone using the project will have to publish it locally on their machine as well, whereas I want to publish this dependency directly in this scala project.

Is it possible and how?

UPDATE:

I want to give the project to a person over the Internet. I want they to download only my project without having to download anything else. But my project has one external dependency which I can download myself.

Can I include this dependency (after downloading it myself) into the project and give the project to the person so they'll be able to run it successfully? And how? And how do I make sbt to load it from the project and not from the Internet or anywhere else?

Incerteza
  • 32,326
  • 47
  • 154
  • 261
  • 4
    Does [Unmanaged Dependencies](http://www.scala-sbt.org/release/docs/Getting-Started/Library-Dependencies.html#unmanaged-dependencies) look like what you want? You can just add your dependency into a `lib` folder in your project and bundle it for others to use. You may also want to look at [Multi-project builds](http://www.scala-sbt.org/release/docs/Getting-Started/Multi-Project.html) for projects with multiple modules. – S.R.I Nov 15 '13 at 07:04
  • 1
    I don't understand the question. You don't want to publish it to the internet, but you don't want to publish it locally, either. What other choices could there possibly be...? I don't know what "publish this dependency directly" means. – Seth Tisue Nov 15 '13 at 13:49
  • @SethTisue **You don't want to publish it to the internet** -- not true. – Incerteza Nov 15 '13 at 14:00
  • Fine, but I'm still left guessing what your actual requirements are. Maybe this? http://stackoverflow.com/questions/7550376/how-can-sbt-pull-dependency-artifacts-from-git – Seth Tisue Nov 15 '13 at 15:09
  • @S.R.I, I have a big project containing some small ones. In what lib directory do I have to put a .jar file (in the root of the main project or in the root of some subproject)? – Incerteza Nov 16 '13 at 16:21
  • @SethTisue, the link you provided is not really what I am looking for because describes how to publish it locally, meaning not in the project but in the home directory of the user. – Incerteza Nov 16 '13 at 16:26
  • @Alex What? No, I think you are mistaken; the process described in the link I provided involves no usage of `sbt publish-local`. But actually, now that you've updated the question to be worded more clearly, see my answer. – Seth Tisue Nov 16 '13 at 23:14

1 Answers1

3

This person you are trying to give your project to: do you want them to be able to build your project themselves, or merely run it?

  • If you want others to be able to build it: Add the library as an unmanaged dependency, as described here. Put the library jar in the lib directory at the top level of your project, and check the jar into version control as part of your project.

  • If you only want others to be able to run it, either:

    • Use the sbt-assembly plugin (https://github.com/sbt/sbt-assembly) to create a single jar containing both your compiled code and the library's compiled code.

    • Or just leave it as two separate jars (yours and the library) and provide both jars to your users, perhaps along with a launch script.

Seth Tisue
  • 29,985
  • 11
  • 82
  • 149
  • yes, build. I have a project containing a few projects. However, I put a .jar in into the root `/lib` directory, removed it from `/project/Build.scala` and now it doesn't compile because it seems it can't find that .jar file. – Incerteza Nov 17 '13 at 05:57
  • 1
    Here's a transcript showing the `/lib` feature working: https://gist.github.com/SethTisue/d33c5a5e3fdd1e20b3b3 . Not sure why your project in particular would be different. Have you attempted to minimize the problem? Can you show us your build...? – Seth Tisue Nov 17 '13 at 14:06