10

There is a library I want to use https://github.com/randhindi/jerkson in Scala project. I might add something like this to build.sbt which is located in a project's base directory:

libraryDependencies += "com.domain_example" % "library_name_test123" % "0.1.1"

But where do I get all those data: domain name, library name, version? There is no such data at https://github.com/randhindi/jerkson

So what do I need to do to use it?

3 Answers3

9

Here's a link to the Typesafe repository, which is the official repository maintained by Typesafe:

Type jerkson in the search box, which will show you all the related projects hosted on the repository.

You should be able to see the path, such as:

com/codahale/jerkson_2.8.2/0.5.0

You can decompose it to 3 components.

Try this:

libraryDependencies += "com.codahale" % "jerkson_2.8.2" % "0.5.0"

If you want the latest integration, you may use latest.integration as the third parameter

libraryDependencies += "com.codahale" % "jerkson_2.8.2" % "latest.integration"

In general, I would try Maven repository first.

Here's what Maven repository looks like:

This is nice because you can see a tab for sbt, and you can simply copy that to your code. Unfortunately, I did not see the library you want in Maven.

Priyantha
  • 4,839
  • 6
  • 26
  • 46
Mingyu
  • 31,751
  • 14
  • 55
  • 60
  • I think the jerkson project I mentioned in my answer is related to `github.com/randhindi/jerkson`. If you look at the package statement from `https://github.com/randhindi/jerkson/blob/master/src/main/java/com/codahale/jerkson/JsonSnakeCase.java`, I think they're the same. – Mingyu Jun 02 '13 at 05:18
  • but where did you get all this data `"com.codahale" % "jerkson_2.8.2" % "0.5.0"`, where is it written? –  Jun 02 '13 at 05:56
  • I have updated my answer. What you need to do is click [typesafe repo] (http://repo.typesafe.com/typesafe/webapp/browserepo.html?2), and type jerkson in the search box, which will display a list of jerkson related projects. – Mingyu Jun 02 '13 at 06:11
  • is Maven repository considered to be the first "official" place where I should try to find a dependency? –  Jun 03 '13 at 01:57
  • The official one is **Typesafe repository**. See here: (http://www.playframework.com/documentation/2.1.1/Repositories). BTW, did my answer solve your problem? – Mingyu Jun 03 '13 at 03:23
3

Based on your comments to the other answers, I believe what you wish to do is specify the dependency directly to the github URL. This has been asked before. Both answers are correct and should prove useful for you.

Community
  • 1
  • 1
joescii
  • 6,495
  • 1
  • 27
  • 32
0

If you don't want to investigate build configuration then you may clone repository and do publish-local. There will be artifact information. Also you add artifact to your local Ivy repository. In this case:

[info]  published jerkson_2.10 to /home/ezh/.ivy2/local/jerkson/jerkson_2.10/0.1-SNAPSHOT/...

In your case

"jerkson" %% "jerkson" % "0.1-SNAPSHOT"

or

"jerkson" % "jerkson_2.10" % "0.1-SNAPSHOT"

Library builded against Scala 2.10

Full log:

ezh@devbox ~/ze $ git clone https://github.com/randhindi/jerkson.git
Cloning into 'jerkson'...
remote: Counting objects: 3093, done.
remote: Compressing objects: 100% (1203/1203), done.
remote: Total 3093 (delta 984), reused 2863 (delta 790)
Receiving objects: 100% (3093/3093), 436.47 KiB | 177 KiB/s, done.
Resolving deltas: 100% (984/984), done.
ezh@devbox ~/ze $ cd jerkson/
ezh@devbox ~/ze/jerkson $ sbt-0.12 publish-local
[info] Loading project definition from /home/ezh/ze/jerkson/project
[info] Updating {file:/home/ezh/ze/jerkson/project/}default-b33f9c...
[info] Resolving org.scala-sbt#precompiled-2_10_1;0.12.4-RC1 ...
[info] Done updating.
[info] Compiling 1 Scala source to /home/ezh/ze/jerkson/project/target/scala-2.9.2/sbt-0.12/classes...
[info] Set current project to jerkson (in build file:/home/ezh/ze/jerkson/)
[info] Updating {file:/home/ezh/ze/jerkson/}jerkson...
[info] Packaging /home/ezh/ze/jerkson/target/scala-2.10/jerkson_2.10-0.1-SNAPSHOT-sources.jar ...
[info] Wrote /home/ezh/ze/jerkson/target/scala-2.10/jerkson_2.10-0.1-SNAPSHOT.pom
[info] Resolving org.scala-lang#scala-library;2.10.0 ...
[info] Done packaging.
[info] Resolving org.hamcrest#hamcrest-core;1.1 ...
[info] downloading http://oss.sonatype.org/content/groups/public/com/fasterxml/jackson/core/jackson-core/2.1.1/jackson-core-2.1.1.jar ...
[info]  [SUCCESSFUL ] com.fasterxml.jackson.core#jackson-core;2.1.1!jackson-core.jar (2325ms)
[info] downloading http://oss.sonatype.org/content/groups/public/com/fasterxml/jackson/core/jackson-databind/2.1.1/jackson-databind-2.1.1.jar ...
[info]  [SUCCESSFUL ] com.fasterxml.jackson.core#jackson-databind;2.1.1!jackson-databind.jar (2351ms)
[info] downloading http://oss.sonatype.org/content/groups/public/org/mockito/mockito-all/1.9.0/mockito-all-1.9.0.jar ...
[info]  [SUCCESSFUL ] org.mockito#mockito-all;1.9.0!mockito-all.jar (7677ms)
[info] downloading http://oss.sonatype.org/content/groups/public/junit/junit/4.10/junit-4.10.jar ...
[info]  [SUCCESSFUL ] junit#junit;4.10!junit.jar (1337ms)
[info] downloading http://oss.sonatype.org/content/groups/public/com/fasterxml/jackson/core/jackson-annotations/2.1.1/jackson-annotations-2.1.1.jar ...
[info]  [SUCCESSFUL ] com.fasterxml.jackson.core#jackson-annotations;2.1.1!jackson-annotations.jar (1384ms)                                                                                   
[info] Done updating.                                                                                                                                                                         
[info] :: delivering :: jerkson#jerkson_2.10;0.1-SNAPSHOT :: 0.1-SNAPSHOT :: integration :: Sun Jun 02 09:22:19 MSK 2013                                                                      
[info]  delivering ivy file to /home/ezh/ze/jerkson/target/scala-2.10/ivy-0.1-SNAPSHOT.xml                                                                                                    
[info] Compiling 77 Scala sources and 1 Java source to /home/ezh/ze/jerkson/target/scala-2.10/classes...                                                                                      
[info] Generating Scala API documentation for main sources to /home/ezh/ze/jerkson/target/scala-2.10/api...                                                                                   
[info] 'compiler-interface' not yet compiled for Scala 2.10.0. Compiling...                                                                                                                   
[info]   Compilation completed in 10.168 s                                                                                                                                                    
[warn] there were 51 feature warnings; re-run with -feature for details                                                                                                                       
model contains 312 documentable templates                                                                                                                                                     
[warn] /home/ezh/ze/jerkson/src/main/scala/com/codahale/jerkson/util/scalax/rules/Rules.scala:67: Tag '@requires' is not recognised                                                           
[warn] /A factory for rules that apply to a particular context.                                                                                                                             
[warn] ^                                                                                                                                                                                      
[warn] two warnings found                                                                                                                                                                     
[info] Scala API documentation generation successful.                                                                                                                                         
[info] Packaging /home/ezh/ze/jerkson/target/scala-2.10/jerkson_2.10-0.1-SNAPSHOT-javadoc.jar ...                                                                                             
[info] Done packaging.                                                                                                                                                                        
[warn] there were 17 deprecation warnings; re-run with -deprecation for details                                                                                                               
[warn] there were 1 unchecked warnings; re-run with -unchecked for details                                                                                                                    
[warn] there were 51 feature warnings; re-run with -feature for details                                                                                                                       
[warn] three warnings found
[warn] Error reading API from class file : java.lang.UnsupportedClassVersionError: com/codahale/jerkson/JsonSnakeCase : Unsupported major.minor version 51.0
[info] Packaging /home/ezh/ze/jerkson/target/scala-2.10/jerkson_2.10-0.1-SNAPSHOT.jar ...
[info] Done packaging.
[info]  published jerkson_2.10 to /home/ezh/.ivy2/local/jerkson/jerkson_2.10/0.1-SNAPSHOT/poms/jerkson_2.10.pom
[info]  published jerkson_2.10 to /home/ezh/.ivy2/local/jerkson/jerkson_2.10/0.1-SNAPSHOT/jars/jerkson_2.10.jar
[info]  published jerkson_2.10 to /home/ezh/.ivy2/local/jerkson/jerkson_2.10/0.1-SNAPSHOT/srcs/jerkson_2.10-sources.jar
[info]  published jerkson_2.10 to /home/ezh/.ivy2/local/jerkson/jerkson_2.10/0.1-SNAPSHOT/docs/jerkson_2.10-javadoc.jar
[info]  published ivy to /home/ezh/.ivy2/local/jerkson/jerkson_2.10/0.1-SNAPSHOT/ivys/ivy.xml
[success] Total time: 56 s, completed 02.06.2013 9:22:48
Ezhik
  • 876
  • 6
  • 23
  • that's ok. but I want to use it from githbu, how do I do that, how do I know what to write in build.sbt? –  Jun 02 '13 at 05:57
  • I use it from GitHub too. I do `git clone https://github.com/randhindi/jerkson.git`. What do you mean by 'use it from githbub'? Do you want something special? – Ezhik Jun 02 '13 at 06:06
  • I mean -- without cloning. –  Jun 02 '13 at 06:09
  • It is not possible without artifacts. If you want to use it without cloning then someone(randhindi?) must publish artifacts to Ivy or Maven directory structure and push it to GitHub. Please tell me how to use raw, uncompiled source codes from GitHub as dependency? IMHO there is no way.Even SBT itself checkout plugin source codes before build. – Ezhik Jun 02 '13 at 06:17
  • must I publish it only into /home/my_name? –  Jul 04 '13 at 18:33
  • 1
    You may clone it anywhere, but `publish-local` save result to *.ivy2* directory which is located inside your home directory (as usual). – Ezhik Jul 05 '13 at 03:42