I have been asked by my developers to have scodec libraries installed on a linux server and I'm lost as I can't find any documentation that points about installing the scodec library!
scodec has 11 repositories in github. This is scodec.org, the official documentation. Seems like the releases page on the docs, is not very updated. So I am going to elaborate on the repositories based on github:
scodec-bits
Provides persistent datatypes for working with bits and bytes.
Add the following into your build.sbt file:
libraryDependencies += "org.scodec" %% "scodec-bits" % "1.1.23"
Maven link. Github link.
scodec-stream
Scodec-stream is a library for streaming binary encoding and decoding. It is built atop scodec and fs2.
Add the following into your build.sbt file:
libraryDependencies += "org.scodec" %% "scodec-stream" % "2.0.0"
Maven link. Github link.
scodec-protocols
Provides models of common binary protocols using the scodec library.
Add the following into your build.sbt file:
libraryDependencies += "org.scodec" %% "scodec-protocols" % "2.0.0"
Maven link. Github link.
scodec
Github link. This package DO NOT publish to Maven central/Sonatype. Hence you cannot fetch it this way. You can try to download one of the releases and read How can I add unmanaged JARs in sbt-assembly to the final fat JAR?
scodec-cats
Integration between scodec and cats.
Add the following into your build.sbt:
libraryDependencies += "org.scodec" %% "scodec-cats" % "1.0.0"
Maven link. Github link.
scodec-build
This repository contains an SBT plugin that is used by the SBT builds of the other scodec modules. It is not intended for direct use.
I will not elaborate about this one. If there is a need for that please comment and I'll add details.
scodec.github.io
No releases yet. Skipping as well. Github link.
scodec-website
Source for scodec.org website. Hence skipping.
scodec-spire
Integration between scodec and spire. This package last publish was at 2016, and it was for Scala 2.11. But you can add it with:
libraryDependencies += "org.scodec" %% "scodec-spire" % "0.4.0"
Maven link. Github link.
I skipped scodec-scalaz and scodec-akka which are archived.
I hope this will give you an idea where to start.
Related
I stumbled upon this Akka grpc tutorial which suggests that we can create a jar from a project that has .proto file under src/main/proto and add it as a dependency in client and server projects to build their respective stubs.
libraryDependencies += "com.example" %% "my-grpc-service" % "1.0.0" % "protobuf-src"
But this doesn't seem to work!! Are there any example projects that demonstrates how this would work in action? How can we externalize protobuf sources and use the same in a jvm based project?
I was able to figure out how to externalise protobuf files properly as per suggestion from akka-grpc docs.
The problem was that I was not adding sbt-akka-grpc plugin required by sbt to recognise .proto files and include them in the packaged jar. Without this plugin there won't be any .proto file made available in the packaged jar.
addSbtPlugin("com.lightbend.akka.grpc" % "sbt-akka-grpc" % "1.1.0")
Make sure to add organization settings in your build.sbt to prepare jar correctly.
organization := "com.iamsmkr"
Also, if you wish to cross-compile this jar to multiple versions add following entries in your build.sbt:
scalaVersion := "2.13.3"
crossScalaVersions := Seq(scalaVersion.value, "2.12.14")
and then to publish:
$ sbt +publishLocal
With appropriate jars published you can now add them as dependencies in your client and server projects like so:
libraryDependencies +=
"com.iamsmkr" %% "prime-protobuf" % protobufSourceVersion % "protobuf-src"
You can check out this project I am working on to see this in action.
Alternate Way
An alternate way I figured is that you can keep your .proto files in a root directory and then refer them in client and server build.sbt like so:
PB.protoSources.in(Compile) := Seq(sourceDirectory.value / ".." / ".." / "proto")
Checkout this project to see it in action.
When I build an artefact with
sbt universal:packageZipTarball
the scala-compiler.jar is included as a lib in my artefact.
Why is the scala-compiler needed at runtime? In my understanding it shouldn't be needed.
How can I exclude this jar?
It is probably pulled in as a transitive dependency by one of your libraryDependencies. You can use this sbt plugin to find out which one:
https://github.com/sbt/sbt-dependency-graph
Once you found out, you can block it by appending exclude("org.scala-lang", "scala-compiler") to the relevant dependency.
For instance, older versions of the pureconfig library used to erroneously pull this dependency in. It can be fixed like so:
libraryDependencies +=
"com.github.pureconfig" %% "pureconfig" % "0.10.0" exclude("org.scala-lang", "scala-compiler")
I would like to update from Akka 2.4.10 to the current Akka 2.5.6. For any reasons I can't find a Download-Link on https://akka.io. On Github I found the source files but what I'm looking for are the compiled .class-files bundled in .jar-files, so that I can directly integrate them as library in IntelliJ IDEA. (With version 2.4.10 there was a file "akka_2.11-2.4.10.zip" available for download at https://akka.io, which had these .jar-files in the "lib"-subdirectory.)
You can get the JARs directly from Maven Central, but you should really consider using a build management tool like SBT. You don't even have to install anything, you can just use the one bundled with IntelliJ. Simply create a file named build.sbt in the root of your project with these contents (taken straight from the Akka documentation):
libraryDependencies ++= Seq(
"com.typesafe.akka" %% "akka-actor" % "2.5.6",
"com.typesafe.akka" %% "akka-testkit" % "2.5.6" % Test
)
Open it in IntelliJ and a bar should appear on top of your editor window, prompting you to import the file. This will take care of downloading the appropriate JARs (along with any dependencies).
You should update akka dependency version and your build system would automatically fetch the necessary jar files compatible with the scala version. From here you can find all akka libraries published to maven repository.
Say I want to include a dependency on the play-json library in my sbt file. How and where can I find that information?
I tried searching central repo, play git repository -- couldn't find anything.
First of all, when you want to include a dependency, you've somehow been told about it - about the required version and where to find it. Ask the person this question and you're done. The official source should always be the home page of a dependency.
I'd use http://search.maven.org/ or http://mvnrepository.com/ and pick whatever version is the most current. In your case, however, esp. after the comment where you pointed at Adding Play JSON Library to sbt the answer was right there - in the answers - see https://stackoverflow.com/a/20475410/1305344:
Play 2.2 is out and can be added separately from rest of Play
Framework. in build.sbt:
resolvers += "Typesafe Repo" at "http://repo.typesafe.com/typesafe/releases/"
libraryDependencies += "com.typesafe.play" %% "play-json" % "2.2.1"
The trick is to set up resolvers properly and using the above resolver gives http://repo.typesafe.com/typesafe/releases/com/typesafe/play/play-json_2.10.
When you've got resolvers and any version in your build configuration, you may want to use sbt-updates that's (quoting the plugin's headline) "SBT plugin that can check maven repositories for dependency updates". Quite handy to have it installed as a global plugin, i.e. .sbt/0.13/plugins/sbt-updates.sbt with the following:
resolvers += Classpaths.sbtPluginSnapshots
addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.1.6-SNAPSHOT")
When you execute dependencyUpdates you're told what needs version update.
> dependencyUpdates
[info] Found 1 dependency update for superapp
[info] org.jacoco:org.jacoco.agent:jacoco : 0.6.4.201312101107 -> 0.6.5.201403032054 -> 0.7.0.201403182114
[success] Total time: 1 s, completed 2014-03-28 18:30:12
As you can see, I need to upgrade jacoco.
If the project you depend on releases to some known repositories, running sbt-updates regularly will ultimately tell you about the update. I'd strongly recommend reading RELEASE_NOTES for an update before upgrading since it may be introducing some breaking changes you'd rather know about before going to production.
Can not find scala.actors package in latest milestones, while it still presents in scaladocs:
https://oss.sonatype.org/content/groups/public/org/scala-lang/scala-library/2.10.0-M6
The scala-actors library is now a separate artifact. You can add it to your project like
"org.scala-lang" % "scala-actors" % "2.10.0-M6"
It is online here:
https://oss.sonatype.org/content/groups/public/org/scala-lang/scala-actors/2.10.0-M6/