title: Kotlin in Java project, unresolved references
body: <p>I'm trying to include som Kotlin files in a rather large IntelliJ Java project, and I've stumbled upon a case where I get "unresolved reference" on absolutely every import.</p>
  
  <p>The (simplified project structure:</p>
  
  <pre><code>Project:
  saksbehandling
  - e2e 
     - cucumber
      - src
        - test
          - java
            -e2e
              - support
     - common
      - src
        - main
          - java
            - common
              - testdata
  </code></pre>
  
  <p>Kotlin classes in the <strong>support</strong> module work fine.
  Kotlin classes in the <strong>common</strong> module does not.</p>
  
  <p>The same file is located in the /e2e/cucumber/src/test/java/e2e/support and the /e2e/common/src/main/java/common/testdata folders. In the latter, I get "Unresolved reference" when I try any kind of import. Example:</p>
  
  <pre><code>import api.utils.ApiResourceFactory
  import com.google.common.io.Resources
  import e2e.utils.AdressIterator
  </code></pre>
  
  <p>Now, the api.utils an e2e.utils unresolved references are one thing. But the com.google reference? That tells me there's something seriously missing or broken.</p>
  
  <p>I've been looking for conflicting versions etc., but it's all the same project, so how can the problem be related to that? Also, making the <strong>common</strong> module dependent on the <strong>cucumber</strong> module does not help, and also that's not a good idea.</p>
  
  <p>Any ideas how to fix this probably silly newbie problem?</p>
  
  <p>BTW: In addition, when creating the Kotlin file in the <strong>common</strong> module, where no imports work, suddenly a working Kotlin file in the <strong>cucumber</strong> module also starts getting Unresolved references on things that's been working until the new file was created.</p>
  
  <p>UPDATE:</p>
  
  <p>Using this link: <a href="https://www.baeldung.com/kotlin-maven-java-project" rel="nofollow noreferrer">https://www.baeldung.com/kotlin-maven-java-project</a> to tweak the .pom file i was able to get most of the imports working.</p>
  
  <p>However, some strange things are still not working:</p>
  
  <p><strong>import kotlin.collections.ArrayList</strong> still gives "Unresolved reference: ArrayLIst"</p>
  
  <p>And in the code, I get "Unresolved reference" on the following</p>
  
  <pre><code>listOf()
  educationMap[fnr] (the []'s - No set method providing array access
  ComplaiuntWhoEnum::class.java.enumConstants - Unresolved reference: Java
  </code></pre>
  
  <p>I even get errors about Unresolve reference: Int (!)</p>
  
  <p>UPDATE 2:</p>
  
  <p>If I create a folder /common/src/main/kotlin, things look better. But then I'm unable to import those classes into classes in the cucumber module.</p>