Maven Compiler Plugin
  1. Maven Compiler Plugin
  2. MCOMPILER-97

META-INF/services/javax.annotation.processing.Processor copied before compilation and causes error

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 2.0.2
    • Fix Version/s: None
    • Labels:
      None
    • Environment:
      Ubuntu 8.10, JDK 6.

      Description

      It is tricky to compile a Maven module which defines a (269-compliant) annotation processor. If you write the code for the processor in src/main/java and register it in src/main/resources, META-INF/services/javax.annotation.processing.Processor is copied to target/classes first, and then javac is run. But javac is given target/classes in -classpath, so it tries to load the processor, which of course has not been compiled yet - a chicken-and-egg problem.

      The most straightforward workaround is to specify <compilerArgument>-proc:none</compilerArgument> in your POM. This will only work, however, if the module does not use any annotation processors defined in dependencies. If it does, there may be some other trick involving -processorpath and Maven variable substitution to insert the dependency classpath.

      Switching the order of resources:resources and compiler:compile would help - at least a clean build would work - though it could still cause problems in incremental builds. Better would be for the compiler plugin to pass -processorpath based on the dependency classpath (i.e. -classpath minus target/classes) when using -source 1.6 or higher.

      1. maven-6647998-test.zip
        8 kB
        Jesse Glick
      2. MCOMPILER-97-workaround.zip
        6 kB
        Jesse Glick

        Issue Links

          Activity

          Jesse Glick created issue -
          Jesse Glick made changes -
          Field Original Value New Value
          Link This issue is depended upon by MCOMPILER-98 [ MCOMPILER-98 ]
          Jürgen made changes -
          Link This issue is related to MCOMPILER-134 [ MCOMPILER-134 ]
          Jesse Glick made changes -
          Attachment MCOMPILER-97-workaround.zip [ 55903 ]
          hendy made changes -
          Attachment MANIFEST.MF [ 60048 ]
          hendy made changes -
          Attachment MANIFEST.MF [ 60049 ]
          hendy made changes -
          Attachment MANIFEST.MF [ 60050 ]
          Arnaud HERITIER made changes -
          Attachment MANIFEST.MF [ 60050 ]
          Arnaud HERITIER made changes -
          Attachment MANIFEST.MF [ 60049 ]
          Arnaud HERITIER made changes -
          Attachment MANIFEST.MF [ 60048 ]
          Mark Thomas made changes -
          Project Import Sun Apr 05 09:20:51 UTC 2015 [ 1428225651644 ]
          Mark Thomas made changes -
          Workflow jira [ 12718612 ] Default workflow, editable Closed status [ 12749903 ]
          Mark Thomas made changes -
          Project Import Sun Apr 05 22:48:53 UTC 2015 [ 1428274133206 ]
          Mark Thomas made changes -
          Workflow jira [ 12956150 ] Default workflow, editable Closed status [ 12993198 ]

            People

            • Assignee:
              Unassigned
              Reporter:
              Jesse Glick
            • Votes:
              10 Vote for this issue
              Watchers:
              14 Start watching this issue

              Dates

              • Created:
                Updated:

                Development