wix-incubator / exodus

Easily migrate your JVM code from Maven to Bazel
MIT License
222 stars 21 forks source link

Exodus generated bazel build files fail for files with lombok annotation #57

Open aman-harness opened 4 years ago

aman-harness commented 4 years ago

The build fails with error: error: symbol not found io.harness.rule.DevInfo$DevInfoBuilder

the file is defined like this:

@Builder
public class DevInfo {

Is there any best practices over how to use annotation processor with exodus? I checked the documentation but couldn't find anything in the troubleshooting guide: https://wix.github.io/exodus/troubleshooting.html

natansil commented 4 years ago

Exodus employs a static dependency analyzer. As such it cannot understand annotations. One way to resolve this is to add temporary "fake" usages of DevInfoBuilder like:

public class TempUsage {
  public static void use() {
      println(new DevInfoBuilder())
  }
}

Another way is to use override mechanism (write to bazel_migration folder to internal_file_deps.overrides file in some format) it depends how widespread is the use of these annotations.

maybe adding these usage classes artificially for the build is easiest

aman-harness commented 4 years ago

We use @slf4j annotation in almost all the files (> 7k) which automatically creates the logger.

Also, using lombok needs special handeling using processor class.

java_plugin(
  name = "lombok_plugin",
  processor_class = "lombok.launch.AnnotationProcessorHider$AnnotationProcessor",
  deps = ["@lombok_jar//jar"],
)

I don't see these in the bazel generated files. So I think this will need some special handeling in internal_file_deps.overrides file.

natansil commented 4 years ago

So which bazel target do you want to add as dependency? I think that the best option will actually be to run buildozer after migration is done: Something like: buildozer 'add deps [lombok target]' //...

natansil commented 4 years ago

Hi @aman, I’ve fixed the parallization of analysis issue. So you can now run more than one module at a time: https://github.com/wix/exodus/pull/55

Did you manage to solve the lombok issue with a buildozer command?