Error compiling mixed Java / Scala project and Lombok

I am trying to compile a mixed Maven Java / Scala project that has a Scala class that depends on a Java bean with lombok annotations. I tried adding the jombok jar file to the load path of the Scala compiler as well as the lombok agent, but the compiler still could not find the generated getters. Is there any way for the Scala compiler to recognize lombok annotations? If not, what would be a good way?

Note that I am trying to avoid introducing another maven project just to compile this bean first, since the bean logically belongs to the same project. Also, I cannot rewrite the bean in Scala, as it is later used in the GWT project.

Thanks,

+8
java scala maven lombok
source share
1 answer

I think you cannot avoid it. Normal Scala / Integration in Java works as follows:

  • Scala comes first since Java knows nothing about Scala.
    • Scalac parses Java files and learns about visible elements.
    • Scalac reads Scala files and generates class files.
  • Java takes the last place and reads Java files plus class files created by Scala.

The obvious problem is that Scala does not know anything about Lombok annotation, so it cannot determine the elements generated by it.

If you have no dependency on Java before Scala, you can simply invert the order: let Java go first and Scala includes javac class output files in its class path.

Otherwise, I suppose you need to break it.

+9
source share

All Articles