# Kotlin and java in the same directories for gradle build?

**URL:** <https://discuss.kotlinlang.org/t/kotlin-and-java-in-the-same-directories-for-gradle-build/290>\
**Category:** Uncategorized\
**Created:** [April 5, 2015, 4:45am UTC](https://discuss.kotlinlang.org/t/kotlin-and-java-in-the-same-directories-for-gradle-build/290 "2015-04-05T04:45:50Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![bebarker](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/bebarker/32/1514_2.png) [@bebarker](https://discuss.kotlinlang.org/u/bebarker)\
**Post date:** [April 5, 2015, 4:45am UTC](https://discuss.kotlinlang.org/t/kotlin-and-java-in-the-same-directories-for-gradle-build/290/1 "2015-04-05T04:45:50Z")

</div>

I believe I read this is now possible in M11, but I am having errors like this with gradle:

e: C:cygwin64homebrand\_000LWJake2srclwjake2gameentity\_state\_t.kt: (30, 7): Unresolved reference: edict\_t

But edict\_t is defined in LWJake2srclwjake2gameedict\_t.java:

&nbsp;

```kotlin
public class edict_t {
  /** Constructor. */
    public edict_t(int i) {
  s.number = i;
        index = i;
    }
```

`…`

`
My gradle file is posted along with the rest of the repo here, if it helps (not too long, but not sure what might be relevant as yet):
https://github.com/bbarker/LWJake2/tree/initKotlin
That said, this build.gradle is probably a bit far from being fully functional, if I had to guess; the working Ant build.xml is also in the directory.
`

---

<div class="post-metadata">

**Author:** ![Natalia.Ukhorskaya](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/natalia.ukhorskaya/32/1447_2.png) [@Natalia.Ukhorskaya](https://discuss.kotlinlang.org/u/Natalia.Ukhorskaya)\
**Post date:** [April 6, 2015, 11:29am UTC](https://discuss.kotlinlang.org/t/kotlin-and-java-in-the-same-directories-for-gradle-build/290/2 "2015-04-06T11:29:23Z")

</div>

Hi, I've take a look at your build.gradle file and I think that the problem is here

> sourceSets { &nbsp;&nbsp;main.java.srcDirs += 'src/lwjake2' }

Your Java-files have package 'lwjake2.\*', so the source directory should be

> main.java.srcDirs += 'src/lwjake2'

Could you check if it helps?

---

<div class="post-metadata">

**Author:** ![bebarker](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/bebarker/32/1514_2.png) [@bebarker](https://discuss.kotlinlang.org/u/bebarker)\
**Post date:** [April 6, 2015, 4:20pm UTC](https://discuss.kotlinlang.org/t/kotlin-and-java-in-the-same-directories-for-gradle-build/290/3 "2015-04-06T16:20:31Z")

</div>

Thanks for taking a look. Lately, not just with Kotlin (or gradle), I feel that 80% of my problems can be traced to build systems :(.

If I understood you correctly, changing ‘src/lwjake2/’ to ‘src/lwjake2’ (removing the trailing ‘/’) still gives the same error.

---

<div class="post-metadata">

**Author:** ![Natalia.Ukhorskaya](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/natalia.ukhorskaya/32/1447_2.png) [@Natalia.Ukhorskaya](https://discuss.kotlinlang.org/u/Natalia.Ukhorskaya)\
**Post date:** [April 6, 2015, 4:22pm UTC](https://discuss.kotlinlang.org/t/kotlin-and-java-in-the-same-directories-for-gradle-build/290/4 "2015-04-06T16:22:48Z")

</div>

I'm sorry for my mistake. Source root should be

> main.java.srcDirs += 'src'

---

<div class="post-metadata">

**Author:** ![bebarker](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/bebarker/32/1514_2.png) [@bebarker](https://discuss.kotlinlang.org/u/bebarker)\
**Post date:** [April 6, 2015, 4:40pm UTC](https://discuss.kotlinlang.org/t/kotlin-and-java-in-the-same-directories-for-gradle-build/290/5 "2015-04-06T16:40:26Z")

</div>

Great, this does it ... now I begin to understand how Gradle handles package names, though I still need to check a few thigns.
