Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

6
  • Thanks this works! However, based on the Maven doc regarding scopes, this doesn't seem like the intended usage of optional and provided. I'll accept your answer (hey it works!) if no "better" answer comes up. Commented Jan 14, 2013 at 17:07
  • 1
    Nope, I guess provided will always do the right thing for you. I also agree that it doesn't sounds right with "provided", but I guess you wont find any better solution. Commented Jan 14, 2013 at 18:36
  • 3
    "Optional" just means it's not required by other projects which depend on this one. If they want it, they have to declare it explicitly. Usually other projects won't want your annotation processors, so it's optional (not required). For annotation processors to work, javac finds them on the compile-time classpath, which is the compile scope in maven. "provided" is a special scope for some plugins which package/bundle compile-time dependencies. They are often confused, but it's easier if you think about what other projects need from your project, when they depend on yours. Commented Mar 24, 2016 at 23:17
  • 1
    In version 3.5 of the Maven compiler plug-in a new "annotationProcessorPaths" option was introduced. I recommend to use that (see my answer below) instead of exposing the processor JAR as a project dependency. Commented Jan 21, 2017 at 9:45
  • 1
    Something to keep in mind with "annotationProcessorPaths" is that it might be unintentionally overriding processors from a parent POM. <annotationProcessorPaths combine.children="append"> in the child POM makes sure that the already configured ones are preserved. Commented Dec 25, 2021 at 12:54