Skip to content
This repository has been archived by the owner on Feb 18, 2022. It is now read-only.

Support annotationProcessorPaths option in maven-compiler-plugin 3.5 #47

Closed
agudian opened this issue Jan 19, 2016 · 9 comments
Closed
Milestone

Comments

@agudian
Copy link

agudian commented Jan 19, 2016

Hi there,

maven-compiler-plugin version 3.5 is being released tomorrow or so, and it would be awesome if m2e-apt would support the new option annotationProcessorPaths, which allows to specify the annotation processor path explicitly (see http://maven.apache.org/components/plugins-archives/maven-compiler-plugin-LATEST/compile-mojo.html#annotationProcessorPaths):

<plugin>
  <artifactId>maven-compiler-plugin</artifactId>
  <configuration>
    <annotationProcessorPaths>
      <path>
        <groupId>org.sample</groupId>
        <artifactId>sample-annotation-processor</artifactId>
        <version>1.2.3</version>
      </path>
      <!-- ... more ... -->
    </annotationProcessorPaths>
  </configuration>

The resolved dependencies of the artifacts listed in that option would need to be applied in .factorypath.

Would be great if someone could pick this up and implement it.

Thanks!

@fbricon
Copy link
Member

fbricon commented Jan 19, 2016

It shouldn't be terribly hard to implement : collect the annotationProcessorPaths, trigger artifact resolution and add to .factorypath (before or after the other dependencies?)

However I don't think I'll have time to take a serious look at it before a few days. If you feel like providing a PR, please be my guest :-)

@fbricon
Copy link
Member

fbricon commented Jan 19, 2016

In any case, could you link to a sample project using that feature, once m-c-p 3.5 is released?

@agudian
Copy link
Author

agudian commented Jan 19, 2016

I'll prepare a sample project by tomorrow when I got the plugin release process rounded up... :)

fbricon added a commit to fbricon/m2e-apt that referenced this issue Jan 19, 2016
Signed-off-by: Fred Bricon <fbricon@gmail.com>
fbricon added a commit to fbricon/m2e-apt that referenced this issue Jan 19, 2016
Signed-off-by: Fred Bricon <fbricon@gmail.com>
fbricon added a commit to fbricon/m2e-apt that referenced this issue Jan 19, 2016
Signed-off-by: Fred Bricon <fbricon@gmail.com>
@agudian
Copy link
Author

agudian commented Jan 20, 2016

Here's a simple sample project: https://github.com/agudian/m-compiler-p-examples

I'll also try to come up with another sample that contains transitive dependencies in the annotation processor in the coming days.

Thanks again for taking a look!

@fbricon
Copy link
Member

fbricon commented Jan 21, 2016

I'll test it on Friday. I suggest you make the annotation processor project a separate project, since eclipse APT doesn't support APs from open workspace projects.

@agudian
Copy link
Author

agudian commented Jan 22, 2016

I suggest you make the annotation processor project a separate project, since eclipse APT doesn't support APs from open workspace projects.

Having to mvn install the processor project in those cases is OK, I guess. Eclipse notices changes to the jars only after a restart anyway... I already expected this to not work smoothly in all cases... 😉

Anyway, I couldn't wait and too a look at your branch already 👍. It wasn't quite working for me, as the version of Xpp3Dom in what's brought with m2e 1.6.2 doesn't have a default-constructor - resulting in an Exception when trying to read the config to an Xpp3Dom instance.

This worked for me, though:

      final Dependency[] configuredDependencies = maven.getMojoParameterValue(mavenProject, mojoExecution,
          "annotationProcessorPaths", Dependency[].class, monitor);

      PluginDependencyResolver dependencyResolver = new PluginDependencyResolver() {
        protected Collection<Dependency> getDependencies(Plugin plugin) {
          return configuredDependencies.length == 0
              ? super.getDependencies(plugin)
              : Arrays.asList(configuredDependencies);
        }
      };

There's one more thing. I noticed that the project dependencies are added to the processor path as well. At least in this scenario, that shouln't be done. I guess an additional flag in AnnotationProcessorConfiguration could be used to control whether to add the project dependencies (if configuredDependencies.length == 0) or not. WDYT?

@fbricon
Copy link
Member

fbricon commented Jan 22, 2016

Yeah I coded that to get a feeling of how it'd look like but didn't test it. I noticed the dependencies shouldn't be added, after re-reading the doc, I need to change that.

fbricon added a commit to fbricon/m2e-apt that referenced this issue Jan 22, 2016
Signed-off-by: Fred Bricon <fbricon@gmail.com>
fbricon added a commit to fbricon/m2e-apt that referenced this issue Jan 22, 2016
Signed-off-by: Fred Bricon <fbricon@gmail.com>
fbricon added a commit to fbricon/m2e-apt that referenced this issue Jan 22, 2016
Signed-off-by: Fred Bricon <fbricon@gmail.com>
@fbricon
Copy link
Member

fbricon commented Jan 22, 2016

@agudian : could you please check if PR #48 works for you?

fbricon added a commit to fbricon/m2e-apt that referenced this issue Jan 23, 2016
Signed-off-by: Fred Bricon <fbricon@gmail.com>
fbricon added a commit to fbricon/m2e-apt that referenced this issue Jan 23, 2016
Signed-off-by: Fred Bricon <fbricon@gmail.com>
@fbricon fbricon modified the milestone: 1.2.0 Jan 24, 2016
@agudian
Copy link
Author

agudian commented Jan 25, 2016

Awesome, thanks alot! 👍

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants