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

.factorypath lacks jars, when corresponding projects are opened in Eclipse #64

Open
basinilya opened this issue Feb 26, 2018 · 5 comments

Comments

@basinilya
Copy link

I have a project that generates sources correctly when it's opened alone, but if I import its dependencies in Eclipse, it can no longer geneate sources. That's because the generated .factorypath doesn't have entries that correspond to the projects opened in Eclipse.

As a workaround please deduce the "M2_REPO/**/*.jar" path from the dependency projects' GAV and add to .factorypath.

@fbricon
Copy link
Member

fbricon commented Feb 26, 2018

Sorry, workspace dependencies are not supported by the underlying JDT APT engine, so we can't add them to the .factorypath.

You can try to delegate AP to the maven plugin instead of JDT APT, but it's not guaranteed to work anyway. Add the following property to your pom.xml's properties block:

`<m2e.apt.activation>maven_plugin</m2e.apt.activation>

@basinilya
Copy link
Author

basinilya commented Feb 27, 2018

workspace dependencies are not supported

I know that and this is why I'm asking you to use the repo jars regardless.

@basinilya
Copy link
Author

<m2e.apt.activation>maven_plugin</m2e.apt.activation>

This doesn't seem to have any effect at all, neither does the global setting in Window Preferences

@dsyer
Copy link

dsyer commented Nov 1, 2018

I have the same problem, or possibly something similar. In my case the APT project is not even a dependency of the target project (the one that won't build), but it is in the maven-compiler-plugin configuration. The processor just happens to be something I'm working on, so it is open in Eclipse. If I switch off the Maven project nature for the processor project then everything magically starts working, but (obviously) that isn't very convenient, since it is a Maven project.

If you look at what happens to the Java Compiler settings when you right click and Maven -> Update Project..., you can see what the problem is: it is not that the .factorypath is wrong, it is simply that annotation processing is switched off in the JDT settings. You can switch it "on" manually, and as long as the .factorypath is pre-computed to something correct, it will work, but only until the next time you do Maven -> Update project.... If m2e could leave that flag "on" on and go ahead and calculate the factory path from the locally cached processor jar, everything would work fine.

So to be clear, I understand there might be a limitation in Eclipse that prevents changes in the APT processor from being immediately reflected in other projects in the workspace, but I do not see why it needs to be switched off completely. I'm quite happy in this case to manually build and install the processor when it changes.

UPDATE: even more odd (and there's an ugly a workaround somewhere, although not very practical for "production" use), I find that if I add another APT processor in the maven-compiler-plugin in addition to my own local one, then m2e switches APT processing back on. It doesn't add my local APT processor to the factory path, so it is still broken, but I could trick it into working by faking the dependencies in the additional processor.

@mickaelistria
Copy link

m2e-apt's code is now included in https://github.com/eclipse-m2e/m2e-core , please consider reporting issue to https://github.com/eclipse-m2e/m2e-core/issues if it's still relevant.

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

No branches or pull requests

4 participants