Compiling Java annotations with sbt

I created Java annotations (since I need to save runtime) under $PROJECT/src/main/java , and my scala codewh uses these java us annotations under $PROJECT/src/main/scala . The Java annotation thus created also uses the Java ENUM value as the value.

If I compile the project, then sbt doesn't seem to compile Java annotations and errors every time the enum is used in the annotation. If I comment on all applications of Java enumeration in annotations in scala code and do compilation, using uncomment enum and compiling again, everything works fine.

How can I guarantee that sbt compiles my java annotations and enumeration (i.e. $PROJECT/src/main/java ) before trying to compile scala code when doing a clean build?

EDIT: I have bare bones build.sbt and I use sbt 0.11.2

+3
source share
2 answers

Some good news: a well-known issue has been resolved.

Some bad news: it is resolved in 2.10, and the fix cannot be sent back to 2.9.3 (quoting Paul Phillips in the subject of the problem):

I noted this for backporting, which is not a guarantee; I do not have time to do this right now, but I expect in the near future.

Some good news: if you are stuck in pre-2.10 and your Java sources are not dependent on your Scala sources, you can simply add below to your build.sbt , and all is well:

 compileOrder := CompileOrder.JavaThenScala 

Some bad news: if you are stuck in pre-2.10, and your Java sources depend on your Scala sources, I'm sure you're out of luck, and the compilation-compromise trick is probably your best bet.

+6
source

I bet you are facing the SI-2764 . This has been fixed in Scala 2.10.

At the same time, create a separate subproject for Java annotations and depend on it on the project containing the Scala code. Then the Scala compiler will only process .class files, not. java files.

0
source

Source: https://habr.com/ru/post/916706/


All Articles