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

Some UI options to make m2e-apt more effective #30

Open
caiwei-ebay opened this issue Jun 12, 2014 · 9 comments
Open

Some UI options to make m2e-apt more effective #30

caiwei-ebay opened this issue Jun 12, 2014 · 9 comments

Comments

@caiwei-ebay
Copy link
Contributor

Hi Fred,

  1. users may only use maven-processor-plugin, they don't wish to get maven-compiler plugin automatically work, however the maven-compiler-plugin (at least as of version 2.3.2) will automatically perform annotation processing and generate annotation sources in case you have annotation processors in your project's classpath. And Maven-compiler-plugin is defined or inherited for almost all Maven projects. The annotation processing usually takes long but not necessary for most of the projects.

Is there a possibility to provide a preference option like "Do not automatically configure APT for project having maven-compiler-plugin in pom.xml".

I know there is a workaround to avoid, add "-proc:none" to maven-compiler plugin or remove depenencies that has defined annotation processors. This is not ideal. Right?

  1. APT processing on edit is a JDT APT feature that run annotation process automatically when you are editing a java/jsp file. The processing will affect the performance of source editing and WTP jsp validation. As the feature may be enabled by mistake or automatically by maven-compiler-plugin, is it possible to provide a preference option like "Disable APT reconcile on editing when configure maven projects",

AbstractAptProjectConfigurator#configure is called when configure maven projects,
so we can put code like:

IJavaProject jp = JavaCore.create(project);
if(jp != null && AptConfig.isEnabled(jp) && AptConfig.shouldProcessDuringReconcile(jp)) {
AptConfig.setProcessDuringReconcile(jp, false);
}

  1. maven-processor-plugin usually takes long to execute, and as you know, maven builder is calling the mojo execution one by one, is it possible to provide a preference option like "Run maven-processor-plugin in a job "?

Your feedback is highly appreciated, I can submit patch if you would like to make these options possible.

Thanks.

@fbricon
Copy link
Member

fbricon commented Jun 12, 2014

Wei Cai, these look like interesting ideas.

  1. we could try to add a warning marker when maven-processor-plugin is detected and -proc:none is missing. Quick fix could propose to add the missing -proc:none configuration to the pom.xml

  2. Why not, the preference could be set either via pom.xml property or project/workspace preference.

  3. I'm not quite sure running that part of the build won't bite us at some point like causing an infinite build loop. I'm not a JDT expert. I'd appreciate if @ifedorenko could give us his opinion

I'd be happy to review separate pull requests so we can keep the discussion focused on each problem

@ifedorenko
Copy link

I have alternative compiler plugin implementation that has proc:none by default ;-)

I am not familiar with maven-processor-plugin, but most likely you don't want to run it inside IDE, especially during incremental build.

The whole annotation processing design seems quite broken to me. Really bad mixture of different concerns that is hard to map into IDE and build workflows.

@caiwei-ebay
Copy link
Contributor Author

Hi Fred,

  1. For certain project, if maven-processor-plugin is defined, maven-compiler plugin is already ignored. See MavenCompilerJdtAptDelegate#isIgnored. Not sure if you mean if maven-processor-plugin is defined in any one project in workspace, we should create warning marker for missing "-proc:none"?

We have a very low level library referenced by almost all projects in workspace, and the library contains annotation processors. We have only one project defines maven-processor-plugin(let's name it "A"), while all other projects inherited a maven-compiler-plugin with no "-proc:none". We wish only project "A" get apt enabled, however almost all projects have apt enabled.

That's why I bring out a workspace preference option, I was thinking of users will either use processor-plugin or use compiler-plugin within workspace, they should not mix together.

Options in preference page could look like:
Enable apt processing for plugins:
a. maven-processor-plugin
b. maven-compiler-plugin

  1. agreed.

  2. I think JDT will not run into a build loop.
    Suppose project A has apt enabled, and B, C depends on A.
    Eclipse will first build A, maven builder then starts to run plugins one by one , and schedule a job when comes to processor-plugin. m2e then refresh resources without waiting the job to complete. Java Builder starts to build A after receiving resource change event, project B & C gets built, here A, B, C could have build errors as sources are not generated yet. When the processor-plugin Job is done, it refreshes the resource again, Java Builder starts to build A again, then B&C...
    As the java builder requires workspace lock, and resource change event broadcast also requires workspace lock, so java builder will run in serial mode. The only issue is A, B, C get built for second times, but it is really quick for the second time.

@fbricon
Copy link
Member

fbricon commented Jun 13, 2014

  1. Does Add support for a <m2e.apt.activation> Maven property #26 help? You can set a common strategy in a parent pom and override it in specific modules

  2. I'd like to be sure that when the processor-plugin job is done, it won't trigger a new maven build

@caiwei-ebay
Copy link
Contributor Author

Thanks for your comments.

  1. Yes Add support for a <m2e.apt.activation> Maven property #26 should help, or we can have alternative compiler plugin implementation that has proc:none by default, however there is education cost for this solution, user may be not aware of the maven-compiler-plugin or apt is default disabled. I'm thinking of providing a UI option in preference page or create a warning marker is more user-friendly.

I'm also wondering why proc:none is the flag to determine enable apt or not, usually maven-compiler-plugin won't have this particular argument, so maven-compiler-plugin is get enabled silently for most projects which is probably not user's purpose. Shall we bring a new argument, like only if apt.enabled is configured in maven-compiler-plugin, m2e-apt will then start to work. User should enable this configuration if they wish to use apt. Default enabling apt for compiler plugin is a real performance killer for big projects.

  1. No, it won't trigger a new maven build from my experiment. The resources generated by processor-plugin are java files, refreshing java files will trigger java builder only.

@puhko
Copy link

puhko commented Jul 16, 2015

concerning topic 2) with the proposed reconcile option ...

Is there already a full solution for this request implemented in any new version of the me2-apt plugin? Or is there a pull request existing already?
Moreover I ask myself if a change to the maven-compiler-plugin itself would be necessary here, in order to configure it through the pom.xml of a special project where apt should run. like a new parameter calling reconcileEnabled or enableTypeGenerationInEditor or anything like that (similar to properties like "generatedSourcesDirectory" aso.).
Because we are also searching for this feature for a long time now. The only thing I found out is, that the Eclipse metadata setting for the project is calling org.eclipse.jdt.apt.reconcileEnabled=false, but unfortunately it seems there is no possibility currently to configure this in the pom.xml at all.

The approach to disable it on default when applying the configurations automatically from the pom.xm through the m2e-apt connector, like caiwei-ebay mentioned, would also be ok for us.

@fbricon
Copy link
Member

fbricon commented Jul 29, 2015

PR #31 has been applied and m2e-apt 1.2.0-SNAPSHOT is available from http://download.jboss.org/jbosstools/builds/staging/m2e-apt/all/repo/

Adding <m2e.apt.processDuringReconcile>false<m2e.apt.processDuringReconcile> will disable processing during the reconcile phase.

@puhko
Copy link

puhko commented Aug 7, 2015

works fine, thx

@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

5 participants