Maven with generated Java sources?

I’m trying to add Kotlin to an existing project with a big maven pom.xml file. I followed the instructions here. The Maven build uses plugins like maven-jaxb2-plugin to generate Java sources. The problem is those Java classes are not available to the Kotlin code. Is there a recommendation for this situation? Should I just manually add the generated source directories to the configuration of the Kotlin plugin, like this?

<plugin>
   <groupId>org.jetbrains.kotlin</groupId>
   <artifactId>kotlin-maven-plugin</artifactId>
   ...
   <sourceDirs>
     <source>src/main/java</source>
     <source>src/main/kotlin</source>
     <source>target/generated-sources/foo</source>
     ...
   </sourceDirs>
1 Like

I solved this by adding the correct source dir location (target/generated-sources/xjc):

           <configuration>
                   <sourceDirs>
                       <source>src/main/kotlin</source>
                       <source>target/generated-sources/xjc</source>
                   </sourceDirs>
          </configuration>

There is a Kotlin compiler plugin ticket https://youtrack.jetbrains.com/issue/KT-13995