What I ended up doing was adding a custom task to copy the content of the debug
folder into
debugTest and adding a dependency to the compileDebugTestJava task. The
script looks something like this:

afterEvaluate { project ->
    project.tasks.findAll {
        it.name.startsWith('compile') && it.name.endsWith('DebugTestJava')
    }.each { Task task ->
        task.dependsOn copyKotlinToTest
    }
}

task copyKotlinToTest(type: Copy) {
    from new File(buildDir, 'tmp/kotlin-classes/debug')
    into new File(buildDir, 'tmp/kotlin-classes/debugTest')
}


2014-10-13 19:40 GMT+02:00 Xavier Ducrohet <[email protected]>:

> The android plugin for gradle isn't really compatible with other
> java-based plugin (for now).
>
> This means that the kotlin plugin cannot plug into the tasks created by
> our plugins. You'd have to do a custom plugin for kotlin that works
> exclusively with our plugin.
>
> On Mon, Oct 13, 2014 at 9:25 AM, Kirill Rakhman <[email protected]>
> wrote:
>
>> I'm following the guide over at
>> http://kotlinlang.org/docs/reference/using-gradle.html and have
>> successfully added the Kotlin plugin to my Android's application build
>> script. I've added the kotlin folder to the app's source set like this:
>>
>>     sourceSets {
>>         main.java.srcDirs += 'src/main/kotlin'
>>     }
>>
>> And I can launch my app and use Kotlin classes without problems.
>>
>> However, if I try to run the tests, the compilation fails with the
>> following output:
>>
>> JavaClassTest.java:14: error: package package.name does not exist
>> import package.name.KotlinClass;
>>                                ^
>> JavaClassTest.java:32: error: cannot find symbol
>>     private KotlinClass getResult() {
>>             ^
>>   symbol:   class KotlinClass
>>   location: class JavaClassTest
>>
>> When running with --debug flag, the folder
>> "build\tmp\kotlin-classes\debugTest" seems to be part of the class path,
>> but this folder doesn't exist. However the folder
>> "build\tmp\kotlin-classes\debug" is there and contains all the necessary
>> classes.
>>
>> I would really appreciate some help, since I'm not the biggest Gradle
>> pro. Thanks in advance.
>>
>> Cross reference to StackOverflow:
>> http://stackoverflow.com/questions/26340426/android-unit-test-of-kotlin-class-fails-with-cannot-find-symbol-class
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "adt-dev" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
> Xavier Ducrohet
> Android SDK Tech Lead
> Google Inc.
> http://developer.android.com | http://tools.android.com
>
> Please do not send me questions directly. Thanks!
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "adt-dev" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/adt-dev/LvlkgNlTvtA/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"adt-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to