jbosstools / m2e-apt Goto Github PK
View Code? Open in Web Editor NEWMaven integration with Eclipse JDT Annotation Processor Toolkit
Maven integration with Eclipse JDT Annotation Processor Toolkit
When hitting ctrl+space after <m2e.apt.activation>
, the available activation modes should be listed (disabled, jdt_apt, maven_execution)
Let's say I have an annotation processor project named 'apt'
And another project that uses that annotation processor. Let's call it 'apt-user'.
When both are open in Eclipse, code generation never gets triggered.
When I close the 'apt' project, forcing m2e or m2e-apt to find the installed jar in the .m2 folder, code generation works fine.
I've installed m2e-apt in Eclipse Mars, and am running into the following error:
Caused by: org.apache.maven.plugin.CompilationFailureException: Compilation failure
error: Bad service configuration file, or exception thrown while constructing Processor object:
javax.annotation.processing.Processor: Provider org.eclipse.sisu.space.SisuIndexAPT6 not found
The error seems to occur in several different projects, regardless whether i'm directly using annotations, though perhaps dependencies are annotated, unless I explicitly disable it using
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<compilerArgument>-proc:none</compilerArgument>
</configuration>
</plugin>
using
<m2e.apt.activation>maven_plugin</m2e.apt.activation> or
<m2e.apt.activation>disabled</m2e.apt.activation>
makes no difference. Any ideas how to fix it?
thanks, Mitchell
When a maven project containing annotation processors is imported into workspace, it doesn't show up in the list of annotation processors added by m2e-apt.
If my project use annotation processor, Eclipse must have enabled APT processing to import project without errors.
I may do it on workspace level by: Window>Preferences>Maven>Annotation Processing>Automaticaly configure JDT...
Drawbacks:
I have to do manual configuration every new Eclipse installation -> it is annoying
Workspace settings impacts all projects -> I prefer project isolation
I may do it on project level
Drawbacks:
Annoying
I can't import project without error -> I have to import and then configure
I may do it on project level and commit and commit .settings/org.eclipse.jdt.apt.core.prefs
Drawbacks:
I have to repeat it for each module in multi-module project
I have to commit properties which I don't want to manage, for example org.eclipse.jdt.apt.genSrcDir
Ideally, I could configure somewhere in my pom.xml that: "This project needs to work annotation proccessing enabled. When imported to Eclipse, turn on APT"
Is it possible?
The m2e/apt configurator in https://github.com/excilys/m2e-extras/tree/master/com.excilys.ebi.m2e.apt uses a different approach than m2e-apt : annotation processing is delegated to the underlying maven plugin (org.bsc.maven:maven-processor-plugin) via a Build Participant.
This is less performant than using the incremental JDT APT builder but leads to "better" builds wrt maven, notably allowing the separation between test and production generated sources.
Stéphane Landelle already told me he was ok to contribute his code and since it's EPL, I think we can safely merge both codebases.
Preferences at the workspace and project level would allow the user to chose which processing strategy to use : user APT or direct maven plugin invocation.
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!
Current implementation uses 'factoryPath.addExternalJar(resolvedJarArtifact);' to add jars to the Factory Path. As a result, absolute (i.e. non portable) paths are stored in .factorypath.
We should instead reference the jars via the M2_REPO classpath variable. This will allow the .factorypath file to be shareable via SCM (whether it's a good practice or not is another debate).
We can reuse/copy some m2e-wtp code to achieve that. See https://github.com/sonatype/m2eclipse-wtp/blob/master/org.maven.ide.eclipse.wtp/src/org/maven/ide/eclipse/wtp/ArtifactHelper.java#L85
Hi,
I've configured a project using m2e-apt. Annotation sources generated from classes in src/main/java are added to the Eclipse project as a new source folder target/generated-sources/annotations. However, for classes processed from src/test/java, no such source folder (target/generated-test-sources/annotations) is added to the Eclipse project. A maven build correctly outputs these classes.
We should explore a way to only load relevant jars to the JDT APT Factory Path. See if adding only the processor dependencies is enough to get JDT APT working.
for more details see https://issues.jboss.org/browse/JBIDE-20212
Hi all,
this is an amazing productivity tool for us.
Since some days I would have an error message from aether in Eclipse on doing "Update Project" in Eclipse, failing to setup the annotation processor.
I've verified that by disabling Annotation Processing from the Maven Preferences, I would not have the problem (but not AP handling which is very annoying).
I've tried to upgrade to using the staging update repository, and all is fixed now :-)
I would suggest to promote staging at stable asap?
I'm now using
Maven Integration for Eclipse JDT APT 1.1.0.201311290819 org.jboss.tools.maven.apt.feature.feature.group JBoss, by Red Hat
And it's perfect.
If you need a project to check, just clone
https://github.com/hibernate/hibernate-search
Also, any chance we could enable "Automatically configure JDT APT" by default?
I've been using this now for a long time, consistently on all projects (WildFly, Infinispan, Hibernate Search and OGM, JGroups, Lucene, ...) and never had a problem. Problems start when people forget to enable it...
Thanks a lot, this is now a must have for us.
Changing the preferences in Maven > Annotation Processing should trigger a Maven > Project Configuration automatically
Configure JDT-APT according to the configuration of org.bsc.maven:maven-processor-plugin
I had to do that manually to recover from #19
m2e-apt relies on Sonatype Aether classes to resolve plugin dependencies. Since m2e 1.5.0.M3, Sonatype Aether has been replaced with Eclipse Aether, breaking m2e-apt.
We need to either use m2e/maven's API to resole plugin dependencies, or update m2e-apt to use Eclipse Aether classes if the former solution doesn't work, for some reason.
If you have annotated types inside src/test/java
, the corresponding sources generated by the annotation processor during a normal maven build are put inside target/generated-test-sources/test-annotations
.
However the m2e-apt plugin puts them inside target/generated-sources/annotations
, which leads to errors as the generated types now exist in both directories.
I recently discovered annotationProcessorPaths of the maven-compiler-plugin, which finally lets me get rid of provided or optional dependencies to annotation processors. The Maven build itself runs just fine, but annotation processing in Eclipse gets actively disabled for the project when I do an Alt+F5 and target\generated-sources\annotations is removed as source folder. According to #47 m2e-apt should support annotationProcessorPaths. I have 1.3.0.201610261805 which as far as I know includes this feature, right?
I attached a short pom.xml that demonstrates the issue:
pom.xml.txt
One observation I have made: Sometimes when updating the Maven project (Alt+F5), the target\generated-sources\annotations folder is added as a source folder for a split second and then disappears again.
Is this an issue with m2e-apt or am I just doing it wrong? Thanks in advance for any help.
Java 1.6 is very dead. 1.7 too but I'll probably wait for another release to require Java 1.8 to run m2e-apt
So in the mean time, I'm bumping BREE to JavaSE-1.7 for m2e-apt 1.2.
There exist annotation processors which are not declared in META-INF/services/javax.annotation.processing.Processor
. These processors need to be explicitly selected using the maven-compiler-plugin
’s <annotationProcessors>
configuration element (the equivalent of javac
’s -processor <class>
).
AFAICT, this option is not supported by m2e-apt
yet, making it impossible to configure annotation processing for such processors.
Currently changing the preferences doesn't trigger a project update, it should
Currently the output for the generated sources classpath entry is set to the outputDirectory
parameter from the POM directly (mavenProject.getBuild().getOutputDirectory()
). I think m2e-apt should not set this value directly from the pom, but it should rely on the default output directory:
<classpathentry kind="output" path="target/classes"/>
The default output directory is already set to the POM value by m2e, so it is the same as the current value by default. But some m2e configurators can modify this default output to another value, and ignore the setting in the POM. For example this is the case with m2e-android
, which must compile everything to the bin
folder (rgladwell/m2e-android#258). In that case it is crucial to not hardcode the output to the POM value, but let it be the default. If no m2e configurator change the default output value, we still have no problems, because it is already set by m2e.
@fbricon what do you think?
Hi there !
I'm the author of AndroidAnnotations, an APT library for Android projects.
We currently suggest our Maven / Eclipse users to use the maven-compiler-plugin
to get the build to work with Maven, and then manually configure the Eclipse project by adding the processor JAR stored in M2_REPO
(see here).
This clearly isn't ideal... @slandelle directed me to this plugin, which looks nice. I installed it, activated Automatically configure JDT APT
, then Maven > Update Project Configuration
, did a clean
and... nothing happens.
One thing I noticed is that Java Compiler > Annotation Processing > Enable annotation processing
is unchecked. If I check it, still nothing. If I run Maven > Update Project Configuration
then... Java Compiler > Annotation Processing > Enable annotation processing
becomes unchecked again ie (org.eclipse.jdt.apt.aptEnabled=false
in .settings/org.eclipse.jdt.apt.core.prefs
). Is that normal ?
We also tried using the maven-processor-plugin
, and it lead to similar results.
I'm not certain the problem is on this plugin side though : we use the android-maven-plugin
, in combination with the Android configurator for M2E
and of course the official Eclipse Android plugin
. This whole mix means things might not be done in a very maveny way... but if you have ideas on things I could try to solve this. I could try running the plugin in debug and look at what happens, if you have pointers on how to do that :) .
We need to run some integration tests as part of the build.
Hi.
I'm using Juno Service Release 2 with JBoss Tools 1.4.0 Final and Maven Integration for Eclipse JDT APT 1.0.1.201209200721 under JDK7 64bit on Windows 7.
I have a multimodule maven build with my own annotation processors defined in two separate modules. Everything is working fine with plain maven build on cmdline and necessary files get generated by the processors under target/generated-sources/annotations as expected on the projects using my custom annotations.
Now I'm using the m2e-apt as described here:
I'm using the recommended option with the maven-compiler-plugin. Updating maven project configuration and refreshing/rebuilding everything doesn't work for me. No additional target folder "target/generated-sources/annotations" is created and/or added to the eclipse project - even after refreshing. I also added direct dependencies to the annotation processor factories to the pom.xml as described here:
Either as "normal" deps and/or plugin deps doesn't do the trick. My annotation processor factories are providing the META-INF/services/javax.annotation.processing.Processor files.
As an alternative I used the 2nd (experimental) maven-processor-plugin option. This seems to work better. The apt folder is added to the eclipse project and files are created as expected. But there is another problem using this option:
Right after saving a file, processing starts and JBoss Tools are publishing the changes to my running JBoss server. But this fails with the "workspace is out of sync..." message refering to the generated files. Seems clear to me, since these files were created/updated outside of eclipse calling maven. Also using the "refresh workspace" option from eclipse preferences doesn't work for me. Maybe the plugin doesn't trigger and automatic workspace refresh after maven has finished its job?!
So neither option one or two works for me. Any hints why the preferred option one using maven-compiler-plugin doesn't work for me?
Thanks.
I now use the latest version of your plugin, but the compiler options are still not added from the POM. Here is my POM file:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>m2e-apt-test</groupId>
<artifactId>m2e-apt-test</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<platform.version> 4.1.1.4
</platform.version>
</properties>
<dependencies>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>${platform.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.androidannotations</groupId>
<artifactId>androidannotations</artifactId>
<version>3.0.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.androidannotations</groupId>
<artifactId>androidannotations-api</artifactId>
<version>3.0.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<compilerArgs>
<arg>-Atrace=true</arg>
<arg>-AlogLevel=ERROR</arg>
<arg>-AlogFile=${project.build.directory}/functional-test.log</arg>
</compilerArgs>
</configuration>
</plugin>
</plugins>
</build>
</project>
@fbricon can you take a look at this?
EDIT: I investigated the code, and i think i found the culprit. The ProjectUtils.parseProcessorOptions(List<String>)
method uses this regex to parse one option: "A([^ \\t\"']+)"
. This is incorrect i think, the format is like in my pom.xml.
Hi Fred,
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?
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);
}
Your feedback is highly appreciated, I can submit patch if you would like to make these options possible.
Thanks.
No problem when I build from maven, but when eclipse auto-builds when using m2e-apt with "Experimental : Delegate annotation processing to maven plugins"
I don't get my annotation processor executed (or maybe it crashes ?), I would love to know a way to get the full stacktrace but can't find anything in workspace/.metadata/log unless this error :
!ENTRY org.eclipse.m2e.logback.appender 4 0 2017-05-31 19:04:51.476
!MESSAGE error on execute: error during compilation
Which is present in eclipse Error Log view :
null
org.eclipse.m2e.logback.appender
Error
Wed May 31 20:10:24 CEST 2017
error on execute: error during compilation
But when I hover the error tooltip in my pom <execution>
block I get this non-complete stack :
Error executing (org.bsc.maven:maven-processor-plugin:2.0.5:process:process:generate-sources)
org.apache.maven.plugin.MojoExecutionException: Error executing
at org.bsc.maven.plugin.processor.AbstractAnnotationProcessorMojo.execute(AbstractAnnotationProcessorMojo.java:204)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
at org.eclipse.m2e.core.internal.embedder.MavenImpl.execute(MavenImpl.java:331)
at org.eclipse.m2e.core.internal.embedder.MavenImpl$11.call(MavenImpl.java:1362)
at org.eclipse.m2e.core.internal.embedder.MavenImpl$11.call(MavenImpl.java:1)
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:176)
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:112)
at org.eclipse.m2e.core.internal.embedder.MavenImpl.execute(MavenImpl.java:1360)
at org.eclipse.m2e.core.project.configurator.MojoExecutionBuildParticipant.build(MojoExecutionBuildParticipant.java:52)
at org.jboss.tools.maven.apt.internal.processor.MavenProcessorBuildParticipant.build(MavenProcessorBuildParticipant.java:80)
at org.eclipse.m2e.core.internal.builder.MavenBuilderImpl.build(MavenBuilderImpl.java:137)
at org.eclipse.m2e.core.internal.builder.MavenBuilder$1.method(MavenBuilder.java:172)
at org.eclipse.m2e.core.internal.builder.MavenBuilder$1.method(MavenBuilder.java:1)
at org.eclipse.m2e.core.internal.builder.MavenBuilder$BuildMethod$1$1.call(MavenBuilder.java:115)
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:176)
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:112)
at org.eclipse.m2e.core.internal.builder.MavenBuilder$BuildMethod$1.call(MavenBuilder.java:105)
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:176)
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:151)
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:99)
at org.eclipse.m2e.core.internal.builder.MavenBuilder$BuildMethod.execute(MavenBuilder.java:86)
at org.eclipse.m2e.core.internal.builder.MavenBuilder.build(MavenBuilder.java:200)
at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:735)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:206)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:246)
at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:301)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:304)
at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:360)
at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:383)
at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:144)
at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:235)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
Caused by: java.lang.Exception: error during compilation
at org.bsc.maven.plugin.processor.AbstractAnnotationProcessorMojo.executeWithExceptionsHandled(AbstractAnnotationProcessorMojo.java:353)
at org.bsc.maven.plugin.processor.AbstractAnnotationProcessorMojo.execute(AbstractAnnotationProcessorMojo.java:197)
... 33 more
Relevent part of my pom :
<plugin>
<groupId>org.bsc.maven</groupId>
<artifactId>maven-processor-plugin</artifactId>
<version>2.0.5</version>
<executions>
<execution>
<id>process</id>
<goals>
<goal>process</goal>
</goals>
<phase>generate-sources</phase>
</execution>
<execution>
<id>process-test</id>
<goals>
<goal>process-test</goal>
</goals>
<phase>generate-test-sources</phase>
<configuration>
<sourceDirectory>./test</sourceDirectory>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>rockpalm.it</groupId>
<artifactId>ic2-annotation-processor</artifactId>
<version>1.2.1-SNAPSHOT</version>
</dependency>
</dependencies>
</plugin>
Thanks for helping
I cant reproduce this 100%, but it happened to me 4-5 times. The best steps I have are here:
You can find test project attached to this JIRA https://issues.jboss.org/browse/JBIDE-19464
A Maven project shouldn't need to have every dependency filename stored in the .factorypath file in version control.
Entries referring to M2_REPO should be automatically created and updated if they are not present.
Currently there is no way to enforce the installation of m2e-apt through the pom.xml only. That would be possible with lifecycle-mapping. Could you make the m2e-apt Configurator the default for both goals of the maven-processor-plugin: https://maven-annotation-plugin.googlecode.com/svn/docs/plugin-info.html.
That way only a POM change will make every Eclipse user install that plugin automatically (similar to what is done for maven-bundle-plugin with the tycho m2e plugin
according mapping from the generated lifecycle mapping
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<versionRange>[1.0.0,)</versionRange>
<goals>
<goal>manifest</goal>
<goal>bundle</goal>
</goals>
</pluginExecutionFilter>
<action>
<configurator>
<id>maven-bundle-plugin</id>
</configurator>
</action>
<comment>source: extension(org.sonatype.tycho.m2e_0.6.0.201207302152),extension(org.apache.sling.ide.eclipse-m2e-ui_1.0.2)</comment>
</pluginExecution>
What would be the appropriate comment to add to the lifecycle mapping to my own pom.xml to make it install that extension automatically?
We should use the m2e conversion API to convert APT enabled projects to maven :
@fbricon I seem to have hit an interesting problem in immutables/immutables#745 .. when using (Google's) error-prone, which integrates with Maven via maven-compiler-plugin
with <compilerId>javac-with-errorprone
and <dependencies>
, see http://errorprone.info/docs/installation or look at this pom.xml which does that, then all of error-prone and its dependencies end up on the APT Factory Path in Eclipse, even though error-prone isn't even an Annotation Processor, but causes havoc for other annotation processors (e.g. Immutables.org).
Do you think we could we come up with a way to exclude maven-compiler-plugin dependencies?
If it helps, I could knock up a simple standalone example project that illustrates this problem.
FYI: This is with an m2e-apt 1.4.0 built today from source (see #61).
Annotation processing does not work with the maven-compiler-plugin if compilerId javac-with-errorprone is used. m2e 1.8 (in Oxygen) supports this now so it would be good to have support in m2e-apt as well. AFAIK all that is required is to add it to the lifecycleMappingMetadata.xml.
Hi,
I'm trying to use this with https://github.com/jbossas/jboss-as in Eclipse 4.2.1 on OS X Lion . When building the project I get:
Description Resource Path Location Type
Internal compiler error: java.lang.ClassCastException: com.sun.istack.internal.ws.AnnotationProcessorFactoryImpl cannot be cast to com.sun.mirror.apt.AnnotationProcessorFactory at org.eclipse.jdt.apt.core.internal.AnnotationProcessorFactoryLoader.loadJava5FactoryClasses(AnnotationProcessorFactoryLoader.java:566) JGroupsLogger_$logger.java /jboss-as-clustering-jgroups/target/generated-sources/annotations/org/jboss/as/clustering/jgroups line 0 Java Problem
(We use annotation processing to create the internationalized logger classes). The class it is trying to generate would be based on clustering/jgroups/src/main/java/org/jboss/as/clustering/jgroups/JGroupsLogger.java.
$java -version
java version "1.6.0_37"
Java(TM) SE Runtime Environment (build 1.6.0_37-b06-434-11M3909)
Java HotSpot(TM) 64-Bit Server VM (build 20.12-b01-434, mixed mode)
I enabled the "Automatically Configure JDT..." for all projects in Eclipse/Preferences. Not doing that and enabling it for individual projects works, although I have not tried enabling it for the project causing the error.
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.
Original bug report : https://issues.jboss.org/browse/JBIDE-12087
!ENTRY org.eclipse.core.jobs 4 2 2012-06-01 11:09:12.209
!MESSAGE An internal error occurred during: "Importing Maven projects".
!STACK 0
java.lang.NullPointerException
at org.jboss.tools.maven.apt.internal.AbstractAptConfiguratorDelegate.configureClasspath(AbstractAptConfiguratorDelegate.java:185)
at org.jboss.tools.maven.apt.internal.AbstractAptProjectConfigurator.configureRawClasspath(AbstractAptProjectConfigurator.java:130)
at org.eclipse.m2e.jdt.internal.AbstractJavaProjectConfigurator.invokeJavaProjectConfigurators(AbstractJavaProjectConfigurator.java:180)
at org.eclipse.m2e.jdt.internal.AbstractJavaProjectConfigurator.configure(AbstractJavaProjectConfigurator.java:128)
at org.eclipse.m2e.core.project.configurator.AbstractLifecycleMapping.configure(AbstractLifecycleMapping.java:72)
at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.updateProjectConfiguration(ProjectConfigurationManager.java:302)
at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.configureNewMavenProject(ProjectConfigurationManager.java:234)
at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.importProjects(ProjectConfigurationManager.java:150)
at org.eclipse.m2e.core.ui.internal.wizards.MavenImportWizard$1.doCreateMavenProjects(MavenImportWizard.java:164)
at org.eclipse.m2e.core.ui.internal.wizards.AbstractCreateMavenProjectsOperation.run(AbstractCreateMavenProjectsOperation.java:73)
at org.eclipse.m2e.core.ui.internal.wizards.MavenImportWizard$3.runInWorkspace(MavenImportWizard.java:249)
at org.eclipse.core.internal.resources.InternalWorkspaceJob.run(InternalWorkspaceJob.java:38)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
AbstractAptConfiguratorDelegate
assumes that all dependencies of maven-compiler-plugin are JAR files; this is true except when dependencies have been added to the plugin classpath. When this occurs, the plugin silently fails to configure the annotation processors because it is unable to read the dependency as a JAR file.
The offending piece of code is here: https://github.com/jbosstools/m2e-apt/blob/master/org.jboss.tools.maven.apt.core/src/org/jboss/tools/maven/apt/internal/AbstractAptConfiguratorDelegate.java#L128
Here is a test case illustrating the issue: https://github.com/atomicknight/m2e-apt-testcases/tree/master/nonjar_plugin_deps. Even though the project has an annotation processor on the compile classpath (Hibernate JPA metamodel generator), the processor is not configured because the non-JAR plugin dependency is tested first, causing an exception to be thrown before the Hibernate JAR is tested.
When the project that contains implementation of the AbstractProcessor is open in actual workspace and the project that reference this project, the ATP is not setup correctly. When delete project that contains implementation of the AbstractProcessor from workspace and the other project start reference just external library from local maven repository, the ATP is setup correcty.
It is seems that ProjectUtils.containsAptProcessors() return false if the ATP processor is in workspace directory not in JAR file.
In some cases, projects needs a .factorypath, because it is customized. For example they could need an Eclipse plugin as an annotation processor in Eclipse builds, which cannot be added by m2e-apt.
I think m2e-apt could use a new GUI option: "Do not change factory path if it is already present". The default value can be false. @fbricon WDYT?
I'm using cofoja and it has an APT with -A processor options.
You can see a screenshot of the 3 settings here on page 6: http://webcourse.cs.technion.ac.il/236700/Spring2013/ho/WCFiles/Contracts%20for%20Java.pdf
When manually configured, it generates in .settings.org.eclipse.jdt.apt.core.prefs
these 3 specific lines:
org.eclipse.jdt.apt.processorOptions/com.google.java.contract.classoutput=%PROJECT.DIR%/target/classes
org.eclipse.jdt.apt.processorOptions/com.google.java.contract.classpath=%PROJECT.DIR%/src/main/webapp/WEB-INF/lib/cofoja-1.1-r150.jar
org.eclipse.jdt.apt.processorOptions/com.google.java.contract.sourcepath=%PROJECT.DIR%/src/main/java
From within Eclipse, press Alt-F5 (Mac) to "Update Maven Project" and it will refresh the eclipse project with m2e-apt settings. This causes the 3 lines about to become lost..
If I use compiler args on the maven-compiler-plugin, it has no effect on rebuilding the -A parameters in Eclipse:
-Acom.google.java.contract.classoutput=${basedir}/target/classes -Acom.google.java.contract.classpath=${com.google.java.contract:cofoja:jar} -Acom.google.java.contract.sourcepath=${basedir}/src/main/javaThis thread touches on -A but the conversation seemed a little incoherent to me: #1
Please let me know if this is a bug and it can be fixed or if I am making a mistake in configuring it.
Default m2e-apt activation mode (from workspace preferences) should be overridden by an <m2e.apt.activation>
Maven property.
Valid values being :
Project preferences supercede existing pom properties
I have an Annotation Processor that reports errors and warnings.
Using the native Eclipse integration, errors and warnings are shown in both the Editor and Problems view, but using the m2e-apt plugin these messages are all shown in the Error log.
This is a problem because 1) not all developers will notice annotation messages in the Error log,
2) mesages remain in Error log after they have been resolved.,
3) we want to use the m2e-apt plugin, so generated files follow Maven conventions.
I attach two screenshots showing messages from the same Annotation processor, the first using native Eclipse integration (adding Annotation Processor to FactoryPath) and the second using the m2e-apt integration with "experimental" delagation:
Thanks,
Derek
Hi,
I've created an APT maven project to generate some code. I've succesfully tested this code from Maven and all seems to work fine. However, whenever I use the m2e-apt plugin to run this from Eclipse, I get unexpected runtime-errors in the compilation process. The concrete exceptions differ largely from build-to-build, from execution-to-execution and from pc-to-pc, i.e. there is no real direct cause which I can define.
I've seen various ResourceExceptions where internal JDK code is complaining about the JAR file being correct (the same JAR which is used for the maven compilation, i.e. the JAR is fine), I've seen exceptions of files which cannot be loaded from the classpath (classLoader.getResourceAsStream() like calls which fail) and classcast exceptions (some velocity class does not implement an interface from velocity itself).
All these seem to indicate some classloading issue, however, I've got no idea where to start searching (running an Eclipse debug session right now), or how to fix this without diving headlong into the plugin code, so any advice is apprectiated.
RIght now I can see two possible solutions:
When I import Maven project with commons-math-2.2 the library is recognized as annotation processor and registered in .factorypath file.
I scanned source files and I don't see any *Processor in math-2.2
Steps to reproduce: Import project https://github.com/michaldo/m2e-apt-problem2
Eclipse Mars 4.5.2
Maven Integration for Eclipse JDT APT 1.3.0.201606081857
Window>Preferences>Maven>Annotation Processing>Automaticaly configure JDT...
@fbricon do you have, or could provide, an update site for 1.4.0? Just manual cut, or automated bleeding/nightly, either one would work for me... cauz the Dev builds update site mentioned on the README right now seems to only have a 1.3.0 from 20161026, according to Oomph's Repository Explorer.
Background: it seems that 1.3.0 doesn't work under Photon Milestone 4 (4.8.0M4) Build id: 20171214-1849 with M2E 1.8.2 from 20171007 anymore, could that be? So experienced in https://github.com/vorburger/opendaylight-eclipse-setup ... unless I'm dumb and it's some other unrelated problem; but wanted to try latest before digging further, and feeling lazy for locally building one from master... 😄
When uninstalling m2e-apt (to try and diagnose build issues), the workspace is left in a corrupted state. All poms now have the following error:
Project configurator "org.jboss.tools.maven.apt.MavenCompilerAptProjectConfigurator" required by plugin execution "org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (execution: default-compile, phase: compile)" is not available. To enable full functionality, install the project configurator and run Maven->Update Project Configuration. pom.xml /BobCommon line 3 Maven Project Build Lifecycle Mapping Problem
Additionally, I had to manually remove
.settings/org.eclipse.jdt.apt.core.prefs
.factorypath
and edit
.classpath
org.eclipse.wst.common.component
It looks like the workspace lifecyclemapping files in .metadata.plugins\org.eclipse.m2e.core retain metadata regarding apt:
org.jboss.tools.maven.apt.MavenCompilerAptProjectConfigurator
Suppose project A defines an annotation processor class C, and project B depends on A (both are Maven projects.)
Normally, when you have B open in Eclipse, the factory path for B contains A's jar from the Maven repo, and all is well. But this breaks if the project for A is also open in Eclipse: the factory path for B doesn't contain anything corresponding to A, and C won't run.
More specifically, if A is the only dependency with annotation processors, annotation processing will be disabled for B. If there are other dependencies with other annotation processors, annotation processing will be enabled, and the factory path will contain all dependent jars, but nothing for A.
My guess is that this may be due to the fact that A, as a dependency, is not resolved to a jar, but to the open project's output folder?
When I import Maven project with default compiler annotation processing is enabled, but for JDT compiler it is not enabled.
Steps to reproduce: Import project https://github.com/michaldo/m2e-apt-problem
Eclipse Mars 4.5.2
Maven Integration for Eclipse JDT APT 1.2.0.201601252104
Window>Preferences>Maven>Annotation Processing>Automaticaly configure JDT...
Maybe it is already reported as #22 but those issue is quite old
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.