Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Json4s brings in scalap-2.10.0 dependencies regardless of scalaVersion setting #108

Closed
mcamou opened this issue Mar 20, 2014 · 10 comments
Closed

Comments

@mcamou
Copy link

mcamou commented Mar 20, 2014

With the following build.sbt:

val json4sVersion = "3.2.7"

name := "Json4sDependencies"

organization := "com.tecnoguru"

version := "1.0"

scalaVersion := "2.10.3"

libraryDependencies ++= Seq("org.json4s" %% "json4s-jackson" % json4sVersion,
                            "org.json4s" %% "json4s-ext" % json4sVersion)

I get the following inside SBT:

> show dependencyClasspath
[info] List(Attributed(/Users/mario/.ivy2/cache/org.scala-lang/scala-library/jars/scala-library-2.10.3.jar), Attributed(/Users/mario/.ivy2/cache/org.json4s/json4s-jackson_2.10/jars/json4s-jackson_2.10-3.2.7.jar), Attributed(/Users/mario/.ivy2/cache/org.json4s/json4s-core_2.10/jars/json4s-core_2.10-3.2.7.jar), Attributed(/Users/mario/.ivy2/cache/org.json4s/json4s-ast_2.10/jars/json4s-ast_2.10-3.2.7.jar), Attributed(/Users/mario/.ivy2/cache/com.thoughtworks.paranamer/paranamer/jars/paranamer-2.6.jar), Attributed(/Users/mario/.ivy2/cache/org.scala-lang/scalap/jars/scalap-2.10.0.jar), Attributed(/Users/mario/.ivy2/cache/org.scala-lang/scala-compiler/jars/scala-compiler-2.10.0.jar), Attributed(/Users/mario/.ivy2/cache/org.scala-lang/scala-reflect/jars/scala-reflect-2.10.0.jar), Attributed(/Users/mario/.ivy2/cache/com.fasterxml.jackson.core/jackson-databind/bundles/jackson-databind-2.3.1.jar), Attributed(/Users/mario/.ivy2/cache/com.fasterxml.jackson.core/jackson-annotations/bundles/jackson-annotations-2.3.0.jar), Attributed(/Users/mario/.ivy2/cache/com.fasterxml.jackson.core/jackson-core/bundles/jackson-core-2.3.1.jar), Attributed(/Users/mario/.ivy2/cache/org.json4s/json4s-ext_2.10/jars/json4s-ext_2.10-3.2.7.jar), Attributed(/Users/mario/.ivy2/cache/joda-time/joda-time/jars/joda-time-2.3.jar), Attributed(/Users/mario/.ivy2/cache/org.joda/joda-convert/jars/joda-convert-1.6.jar))
[success] Total time: 0 s, completed Mar 20, 2014 3:18:47 PM

Note the scalap-2.10.0, scala-compiler-2.10.0 and scala-reflect-2.10.0 dependencies. Using the sbt-dependency-graph plugin I've narrowed it down to the scalap dependency. You can work around this by adding an explicit dependency on "org.scala-lang" % "scalap" % scalaVersion.value in your build.sbt but this should really be fixed in Json4s

@casualjim
Copy link
Member

You can override this by explicitly depending on scalap for your scala version.

If I want to be certain json4s behaves on all scala 2.10 versions then I need to compile it with 2.10.0 and leave the scala choice up to the user. or I have to publish a json4s version for each scala 2.10 version which is even less desirable I think.

@DavidPerezIngeniero
Copy link

I wonder why json4s does need a scala compiler as a runtime dependency.

@casualjim
Copy link
Member

because we need to read the byte code to find out information about scala primitives. This is more necessary on 2.9 than it is on 2.10

@DavidPerezIngeniero
Copy link

Thanks for your answer.
I've made a question in stackoverflow:
http://stackoverflow.com/questions/24446832/why-does-json4s-need-a-scala-compiler-as-a-runtime-dependency/

@enlait
Copy link

enlait commented Jul 1, 2014

This adds about ~18 MB worth of dependencies. 18Mb for working with json. Are you serious?

@casualjim
Copy link
Member

I welcome a pull request that makes reflection work otherwise also for 2.9.

@enlait
Copy link

enlait commented Jul 2, 2014

Does json4s build for scala 2.11 need reflection to work for 2.9?
I'm sure it's not an easy change, but such a huge dependency can be a show stopper.

@DavidPerezIngeniero
Copy link

This dependency is for the native version and also for the jackson version,
as it is included in json4s-core.
It can be seen here:

http://mvnrepository.com/artifact/org.json4s/json4s-core_2.10/3.2.10

2014-07-02 12:49 GMT+02:00 enlait notifications@github.com:

Does json4s build for scala 2.11 need reflection to work for 2.9?
I'm sure it's not an easy change, but such a huge dependency can be a show
stopper.


Reply to this email directly or view it on GitHub
#108 (comment).

@jongwook
Copy link

Apache Spark uses json4s and this issue broke my scala 2.11 project build.

I had to explicitly exclude scalap and scala-library like

libraryDependencies ++= Seq(
   // dependencies ... 
).map {
    _.exclude("org.scala-lang", "scalap").exclude("org.scala-lang", "scala-library")
}

otherwise sbt gets confused by the scala-library pulled by json4s, and IntelliJ won't even let me open the project.

Is it fixed in 3.3.0?

@seratch
Copy link
Member

seratch commented Sep 12, 2015

Is it fixed in 3.3.0?

Yes, it is. This issue doesn't happen in 3.3 because json4s 3.3 has its own scalap fork and doesn't depend on scala-lang's scalap.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

7 participants