# Kotlin + Groovy : Groovy unable to resolve Kotlin class

**URL:** <https://discuss.gradle.org/t/kotlin-groovy-groovy-unable-to-resolve-kotlin-class/23245>\
**Category:** Help/Discuss\
**Tags:** plugins\
**Created:** [July 10, 2017, 6:48am UTC](https://discuss.gradle.org/t/kotlin-groovy-groovy-unable-to-resolve-kotlin-class/23245 "2017-07-10T06:48:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sam1](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/sam1/32/7606_2.png) [@Sam1](https://discuss.gradle.org/u/Sam1)\
**Post date:** [July 10, 2017, 6:48am UTC](https://discuss.gradle.org/t/kotlin-groovy-groovy-unable-to-resolve-kotlin-class/23245/1 "2017-07-10T06:48:52Z")

</div>

I’m experimenting with replacing Gradle plugins currently written in Groovy with Kotlin.  
In a such a project where Groovy class A references Kotlin class B, a `gradlew clean build` will fail with:

```gradle
example\misc-gradle-tasks>gradlew clean build

> Task :compileKotlin
Using kotlin incremental compilation

> Task :compileGroovy
startup failed:
example\src\main\groovy\A.groovy: 44: unable to resolve class B
 @ line 44, column 5.
       @Internal
       ^

FAILURE: Build failed with an exception.

```

After some experimentation, I’ve found I can work around this by manually specifying this task dependency:

```gradle
compileGroovy.dependsOn 'copyMainKotlinClasses'

```

Is there already a bug for this? Or is there some other step which should be taken to properly mix groovy and kotlin in the same project?

For reference:  
Gradle version 4.0.1  
sample buildscript:

```gradle
plugins {
    id 'groovy'
    id("org.jetbrains.kotlin.jvm").version("1.1.3-2")
}
compileGroovy.dependsOn 'copyMainKotlinClasses'

dependencies {
    compile gradleApi()
    compile ("org.jetbrains.kotlin:kotlin-stdlib:1.1.3-2")
    
    testCompile gradleTestKit()
    testCompile ('org.spockframework:spock-core:1.1-groovy-2.4') {
        exclude module: 'groovy-all'
    }
}

```

---

<div class="post-metadata">

**Author:** ![Sam1](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/sam1/32/7606_2.png) [@Sam1](https://discuss.gradle.org/u/Sam1)\
**Post date:** [July 11, 2017, 2:05am UTC](https://discuss.gradle.org/t/kotlin-groovy-groovy-unable-to-resolve-kotlin-class/23245/2 "2017-07-11T02:05:15Z")

</div>

I’ve also found that, unlike with Java, Kotlin classes are unable to reference Groovy classes in the same project, as Groovy is built subsequently to Kotlin.

I wonder, are there any plans to make migrating a Groovy project to Kotlin as easy as it is to migrate Java to Kotlin?
