ktakagaki / hayabaya

0 stars 0 forks source link

Sometimes, behind 2 lines of code lies almost 3 hours of work #29

Closed ghost closed 8 years ago

ghost commented 8 years ago

@ktakagaki I decided to finally fix the warnings from SBT about how there were collissions between multiple transitive dependencies. To be exact, the following transitive dependencies were somewhere down the line being evicted, with even one dep being evicted for an older version!

Conflicting transitive dependencies

Using the sbt-dependency graph plugin

$sbt dependencyBrowseGraph // Opens a zoomable graph in the browser

I could easily see that it all came back to the primary sinner - typesafe scala-logging and to some extend a collission with logback-classic. One could have switched out logback but I didn't want to, I just wanted to exclude those fucking 3 transitive dependencies from scala-logging. Easy as pie.

So off I go, using exclude(), adding it like this

libraryDependencies ++= {
  Seq(
    "com.typesafe.scala-logging" %% "scala-logging" % "3.1.0" withSources() withJavadoc()
    exclude("org.scala-lang", "modules.scala-xml", "org.slf4j", "slf4j-api", etc ...),
    "ch.qos.logback" %  "logback-classic" % "1.1.7"
  )}

Anyway it didn't work. Looking up the API docs for SBTs exclude method, it was clear that you can only exclude one transitive dependency at a time from your managed dependency, or alternatively exclude ALL transitive dependencies for ALL managed dependencies!

Long story short. 25 tabs later, having asked on both IRC, www.gitter.im, read through the sourcecode of SBT and refered with the manual and googled for every concievable StackExchange post, I found no actual answer or tutorial. But I did manage to solve it eventually :+1:

Point being, it took 3 fucking hours, and all I had to do was add 2 lines like this!

libraryDependencies ++= {
  Seq(
    "org.scalatest" %% "scalatest" % "2.2.6" % "test" withSources() withJavadoc(),
    "com.typesafe.scala-logging" %% "scala-logging" % "3.1.0" withSources() withJavadoc()
    exclude("org.scala-lang", "modules.scala-xml") exclude("org.slf4j", "slf4j-api")
    exclude("org.scala-lang", "scala-reflect"),
    "ch.qos.logback" %  "logback-classic" % "1.1.7"
  )
}

I really hate how sometimes you can make 1 commit in your git history, changing perhaps only 1 line of code, maybe even just finding a ";". Not looking like much work, but actually it was a giant pain in the arse!

Rambling off from my side...I just really wanted to vent my frustration :)

PS: I want to use ScalaTest to test how Hayabaya handles command line arguments, calling with no args, some args, wrong args etc. But I can't really find any information on how you do this in ScalaTest. I also learned only yesterday that to run your project in SBT with arguments you have to do like this

$sbt run arg1 # wont work!
$sbt "run arg1 ... argn" # works correctly
ghost commented 8 years ago

@ktakagaki I have some more code to push, but GitHub doesn't seem to allow me to do so until you have merged the current pull request. I haven't gotten super far compared to what I had hoped for considering the number of hours spend. But I have made GREAT progress in figuring out what I don't know about Scala. You know like how you can read a book and everything is easy to understand, you read the entire book. And then you get stuck already at the first and easiest exercises??