title: sbt add java project
body: <p>Working on some scala software in IDEA IntelliJ. (It also features Android if it is essential). Suppose I have two projects:</p>
  
  <p>P1, written in scala, uses sbt as the build tool</p>
  
  <p>P2, written in java, uses gradle as the build tool</p>
  
  <p>I want to call some code from P2, having its full source. So I import P2 as a module in my IntelliJ scala project. But when I compile my sbt project using sbt-shell, it tells me an error that it cannot find any definitions of classes and packages declared in P2. I guess I need to create a proper reference in my build.sbt file so it could understand where the definitions come from. I've found one solution which suggests adding unmanaged java source paths to build.sbt like so:</p>
  
  <pre><code>unmanagedSourceDirectories in Compile += file("mydependency")
  </code></pre>
  
  <p>but thing is that dependency has dependencies itself. When I try to compile that, sbt tells me that it cannot find definitions of that dependency. So I need a way to reference full java project in build.sbt so that I could then compille whole thing via sbt shell (in fact, I forced to use the very sbt shell).</p>
  
  <p>Any suggestions?</p>