title: How to fix Kotlin libraries not resolving in IntelliJ in Kotlin code (in a java project)?
body: <p>I have two projects. One written fully in Kotlin that exports a Client artifact. I am trying to use the client in a second project that has a mix of java/kotlin code. </p>
  
  <p>In the java classes I have no problem importing the kotlin files for use, but in any kotlin files, IntelliJ cannot resolve the imports. All the other kotlin code works fine and I can compile on the command line via maven with no problems. It's <em>just</em> an issue with IntelliJ not recognizing the package I'm looking for. </p>
  
  <p>I see the package in both my maven toolbar as well as in the external libraries listed in the project. I've inspected the jars and sure enough the file I expect <code>com/foo/bar/BazClient.class</code> is present, but 
  <code>import com.foo.bar.BazClient</code> tells me the package <code>bar</code> (the code from the other project) does not exist. The very same import statement works just fine in java code. </p>
  
  <p>Further adding to my problems the exact same java class that imports this client, if I convert to kotlin using IJ's builtin method, fails to compile in IntelliJ. The "build project" action completes successfully with no warnings/errors. </p>
  
  <p>Kotlin client is defined as:</p>
  
  <pre><code>package com.foo.bar
  
  import retrofit2.http.GET
  
  interface BazClient {
      @GET("/v1/fuzz")
      fun getFuzz(): Call&lt;FuzzResponse&gt;
  }
  </code></pre>
  
  <p>Working java code:</p>
  
  <pre class="lang-java prettyprint-override"><code>package com.whodat.wat;
  
  import javax.inject.Singleton;
  import com.foo.bar.BazClient;
  
  @Singleton
  public class CallTheService {
      private final BazClient bazClient;
  
      public CallTheService(BazClient bazClient) {
          this.bazClient = bazClient;
      }
  
      public FuzzResponse callIt() throws IOException {
          return bazClient.getFuzz().execute().body();
      }
  }
  </code></pre>
  
  <p>Failing kotlin code:</p>
  
  <pre><code>package com.whodat.wat
  
  import javax.inject.Singleton
  import com.foo.bar.BazClient // "bar" is red in editor
  
  @Singleton
  // Can't resolve "BazClient" here 
  class CallTheService(private val bazClient: BazClient) {
  
      fun callIt(): FuzzResponse {
          return bazClient.getFuzz().execute().body()!!
      }
  }
  </code></pre>