withKotlin + multiple roots?


#1

I have a Java project that has multiple roots (e.g. src/dir1/com/foo/bar, src/dir2/com/foo/bar, etc). If I try to compile using Ant and <withKotlin />, Kotlin files in one root can’t find Java files in another root, though it works in IntelliJ. I’m guessing things are just misconfigured, but the documentation doesn’t seem to cover this use case. Please help, thanks!


#2

This should work, could you please paste your build file?

Example syntax:

        <javac destdir="..." ...>
            <withKotlin/>
            <src>
                <dirset dir="src/dir1/com/foo/bar" includes="src"/>
                <dirset dir="src/dir2/com/foo/bar" includes="src"/>
            </src>
            <classpath>
                 ...
            </classpath>
        </javac2>

#3

I’m getting other compile errors now, but the example you gave seems to be working. Mine now looks more like this:

<javac destdir="...">
  <withKotlin />
  <src>
    <dirset dir="src/" includes="*" />
  </src>
</javac>

Before, I had

<javac srcdir="src/" destdir="...">
  <withKotlin />
  ...
</javac>

and I expect that to Just Work, since it works when it’s all *.java. Is that a reasonable expectation?


#4

I’ve tried your second sample and it works for me:

<project name="test">
    <typedef resource="org/jetbrains/kotlin/ant/antlib.xml" classpath="kotlin-ant.jar"/>

    <javac srcdir="src" destdir="out">
        <withKotlin/>
    </javac>
</project>

(I’ve put a Java file and a Kotlin file with cross-references to the src directory.)

In any case, if you have any other issues in the future, please report them to the tracker so we can properly investigate them. Thank you!