Uploaded image for project: 'Maven Compiler Plugin'
  1. Maven Compiler Plugin
  2. MCOMPILER-264

Isolate annotation processors from one another

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Labels:
      None

      Description

      The MCOMPILER-203 issue went part of the way to solve this problem, however it does not help in the case where annotation processors have conflicting dependencies. Given that this is very easy to solve on the Java end, and seems possible to solve on the Maven end, I would very much like to see this come to pass.

      Here's some relevant info from that issue:

      An important note here would be that the processors should have their own dependency resolution and class loading scope, so that the versions of dependencies of the annotation processor do not have an impact on the versions used to compile the project itself (or other annotation processors).
      They should have their own <dependencies> and <exclusions> and so on.

      All you have to do with the API is call javax.tools.JavaCompiler.CompilationTask#setProcessors(). Each processor can be instantiated from an isolated class loader according to any rules or strategy that you like. To specify isolated options, you can simply wrap each Processor with one that provides the specific arguments that were configured to the delegate processor on init().

      Without isolation this is just one step removed from having your processors on the class path. The difference is that processors are generally more likely to have dependencies that conflict with other processors than to have dependencies that conflict with the class path.

      I imagine it should even be possible to hook into an external javac task by providing it with a proxy JAR from which annotation processor proxies (which instantiate isolated class loaders and return proxied processors from them). But I'd also be OK with just having this feature be unsupported for forked javac.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                dmlloyd David M. Lloyd
              • Votes:
                1 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated: