Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

issue #4 : add support for maven-processor-plugin

A complete refactoring was undertaken to provide support for
org.bsc.maven:maven-processor-plugin :

- all classes were moved to an internal package as we can not guarantee a
  public API at this point.
- plugin dependencies are added to the factory path
- compile AND runtime dependencies are searched for / added to the factory
  path
- java nature is added if missing, as the APT configuration is triggered
  before the Java one, it needs to work with a Java project.
- unused code was removed (mostly marker management).

Signed-off-by: Fred Bricon <fbricon@gmail.com>
  • Loading branch information...
commit 3c6bf77be327b9342d50199f22a57899095f2ca5 1 parent ff70274
@fbricon fbricon authored
Showing with 1,195 additions and 266 deletions.
  1. +4 −1 org.jboss.tools.maven.apt.core/.settings/org.eclipse.jdt.core.prefs
  2. +54 −2 org.jboss.tools.maven.apt.core/.settings/org.eclipse.jdt.ui.prefs
  3. +1 −2  org.jboss.tools.maven.apt.core/META-INF/MANIFEST.MF
  4. +18 −2 org.jboss.tools.maven.apt.core/lifecycle-mapping-metadata.xml
  5. +10 −3 org.jboss.tools.maven.apt.core/plugin.xml
  6. +151 −248 ...org/jboss/tools/maven/apt/{AptProjectConfigurator.java → internal/AbstractAptProjectConfigurator.java}
  7. +31 −0 org.jboss.tools.maven.apt.core/src/org/jboss/tools/maven/apt/internal/AnnotationProcessorConfiguration.java
  8. +1 −1  org.jboss.tools.maven.apt.core/src/org/jboss/tools/maven/apt/{ → internal}/AnnotationServiceLocator.java
  9. +81 −0 ...ss.tools.maven.apt.core/src/org/jboss/tools/maven/apt/internal/DefaultAnnotationProcessorConfiguration.java
  10. +86 −0 org.jboss.tools.maven.apt.core/src/org/jboss/tools/maven/apt/internal/MavenCompilerAptProjectConfigurator.java
  11. +2 −2 org.jboss.tools.maven.apt.core/src/org/jboss/tools/maven/apt/{ → internal}/MavenJdtAptPlugin.java
  12. +64 −0 ...jboss.tools.maven.apt.core/src/org/jboss/tools/maven/apt/internal/MavenProcessorAptProjectConfigurator.java
  13. +106 −0 org.jboss.tools.maven.apt.core/src/org/jboss/tools/maven/apt/internal/PluginDependencyResolver.java
  14. +74 −0 org.jboss.tools.maven.apt.tests/.settings/org.eclipse.jdt.core.prefs
  15. +56 −0 org.jboss.tools.maven.apt.tests/.settings/org.eclipse.jdt.ui.prefs
  16. +3 −0  org.jboss.tools.maven.apt.tests/.settings/org.hibernate.eclipse.console.prefs
  17. +53 −0 org.jboss.tools.maven.apt.tests/projects/eclipselink/pom.xml
  18. +28 −0 org.jboss.tools.maven.apt.tests/projects/eclipselink/src/main/java/foo/bar/Dummy.java
  19. +8 −0 org.jboss.tools.maven.apt.tests/projects/eclipselink/src/main/java/foo/bar/DummyStuff.java
  20. +5 −0 org.jboss.tools.maven.apt.tests/projects/eclipselink/src/main/resources/META-INF/persistence.xml
  21. +34 −0 org.jboss.tools.maven.apt.tests/projects/p2/pom.xml
  22. +18 −0 org.jboss.tools.maven.apt.tests/projects/p2/src/main/java/foo/bar/Dummy.java
  23. +8 −0 org.jboss.tools.maven.apt.tests/projects/p2/src/main/java/foo/bar/DummyStuff.java
  24. +51 −0 org.jboss.tools.maven.apt.tests/projects/p3/pom.xml
  25. +18 −0 org.jboss.tools.maven.apt.tests/projects/p3/src/main/java/foo/bar/Dummy.java
  26. +8 −0 org.jboss.tools.maven.apt.tests/projects/p3/src/main/java/foo/bar/DummyStuff.java
  27. +34 −0 org.jboss.tools.maven.apt.tests/projects/p4/pom.xml
  28. +18 −0 org.jboss.tools.maven.apt.tests/projects/p4/src/main/java/foo/bar/Dummy.java
  29. +8 −0 org.jboss.tools.maven.apt.tests/projects/p4/src/main/java/foo/bar/DummyStuff.java
  30. +35 −0 org.jboss.tools.maven.apt.tests/projects/p5/pom.xml
  31. +18 −0 org.jboss.tools.maven.apt.tests/projects/p5/src/main/java/foo/bar/Dummy.java
  32. +8 −0 org.jboss.tools.maven.apt.tests/projects/p5/src/main/java/foo/bar/DummyStuff.java
  33. +101 −5 org.jboss.tools.maven.apt.tests/src/org/jboss/tools/maven/apt/tests/M2eAptProjectconfiguratorTest.java
View
5 org.jboss.tools.maven.apt.core/.settings/org.eclipse.jdt.core.prefs
@@ -1,4 +1,3 @@
-#Thu Jul 07 08:59:26 MST 2011
eclipse.preferences.version=1
org.eclipse.jdt.core.builder.cleanOutputFolder=clean
org.eclipse.jdt.core.builder.duplicateResourceTask=warning
@@ -76,13 +75,17 @@ org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warnin
org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning
org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
org.eclipse.jdt.core.compiler.problem.redundantNullCheck=warning
+org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore
org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore
+org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
+org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=warning
org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
+org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled
org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
View
56 org.jboss.tools.maven.apt.core/.settings/org.eclipse.jdt.ui.prefs
@@ -1,5 +1,5 @@
-#Tue Nov 30 18:52:17 EST 2010
eclipse.preferences.version=1
+editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
formatter_profile=_m2 plugin
formatter_settings_version=11
org.eclipse.jdt.ui.exception.name=ex
@@ -11,4 +11,56 @@ org.eclipse.jdt.ui.keywordthis=true
org.eclipse.jdt.ui.ondemandthreshold=99
org.eclipse.jdt.ui.overrideannotation=false
org.eclipse.jdt.ui.staticondemandthreshold=99
-org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?><templates><template autoinsert\="true" context\="gettercomment_context" deleted\="false" description\="Comment for getter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.gettercomment" name\="gettercomment">/**\n * @return Returns the ${bare_field_name}.\n */</template><template autoinsert\="true" context\="settercomment_context" deleted\="false" description\="Comment for setter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.settercomment" name\="settercomment">/**\n * @param ${param} The ${bare_field_name} to set.\n */</template><template autoinsert\="true" context\="constructorcomment_context" deleted\="false" description\="Comment for created constructors" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name\="constructorcomment">/**\n * ${tags}\n */</template><template autoinsert\="false" context\="filecomment_context" deleted\="false" description\="Comment for created Java files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.filecomment" name\="filecomment">/*******************************************************************************&\#13;\n * Copyright (c) 2011 JBoss by Red Hat, Inc.&\#13;\n * All rights reserved. This program and the accompanying materials&\#13;\n * are made available under the terms of the Eclipse Public License v1.0&\#13;\n * which accompanies this distribution, and is available at&\#13;\n * http\://www.eclipse.org/legal/epl-v10.html&\#13;\n *&\#13;\n * Contributors\:&\#13;\n * Sonatype, Inc. - initial API and implementation&\#13;\n *******************************************************************************/</template><template autoinsert\="false" context\="typecomment_context" deleted\="false" description\="Comment for created types" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.typecomment" name\="typecomment">/**\n * ${type_name}\n *\n * @author ${user}\n */</template><template autoinsert\="true" context\="fieldcomment_context" deleted\="false" description\="Comment for fields" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" name\="fieldcomment">/**\n * \n */</template><template autoinsert\="true" context\="methodcomment_context" deleted\="false" description\="Comment for non-overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodcomment" name\="methodcomment">/**\n * ${tags}\n */</template><template autoinsert\="true" context\="overridecomment_context" deleted\="false" description\="Comment for overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.overridecomment" name\="overridecomment">/* (non-Javadoc)\n * ${see_to_overridden}\n */</template><template autoinsert\="false" context\="newtype_context" deleted\="false" description\="Newly created files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.newtype" name\="newtype">${filecomment}\n${package_declaration}\n\n${typecomment}\n${type_declaration}</template><template autoinsert\="false" context\="catchblock_context" deleted\="false" description\="Code in new catch blocks" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.catchblock" name\="catchblock">// ${todo} Auto-generated catch block\nMavenLogger.log(${exception_var});</template><template autoinsert\="true" context\="methodbody_context" deleted\="false" description\="Code in created method stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodbody" name\="methodbody">// ${todo} Auto-generated method ${enclosing_method}\n${body_statement}</template><template autoinsert\="true" context\="constructorbody_context" deleted\="false" description\="Code in created constructor stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorbody" name\="constructorbody">${body_statement}\n// ${todo} Auto-generated constructor stub</template><template autoinsert\="true" context\="getterbody_context" deleted\="false" description\="Code in created getters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.getterbody" name\="getterbody">return ${field};</template><template autoinsert\="true" context\="setterbody_context" deleted\="false" description\="Code in created setters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.setterbody" name\="setterbody">${field} \= ${param};</template><template autoinsert\="true" context\="delegatecomment_context" deleted\="false" description\="Comment for delegate methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.delegatecomment" name\="delegatecomment">/**\n * ${tags}\n * ${see_to_target}\n */</template><template autoinsert\="true" context\="classbody_context" deleted\="false" description\="Code in new class type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.classbody" name\="classbody">\n</template><template autoinsert\="true" context\="interfacebody_context" deleted\="false" description\="Code in new interface type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.interfacebody" name\="interfacebody">\n</template><template autoinsert\="true" context\="enumbody_context" deleted\="false" description\="Code in new enum type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.enumbody" name\="enumbody">\n</template><template autoinsert\="true" context\="annotationbody_context" deleted\="false" description\="Code in new annotation type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.annotationbody" name\="annotationbody">\n</template><template autoinsert\="true" context\="gettercomment_context" deleted\="false" description\="Comment for getter function" enabled\="true" id\="org.eclipse.wst.jsdt.ui.text.codetemplates.gettercomment" name\="gettercomment">/**\n * @return the ${bare_field_name}\n */</template><template autoinsert\="true" context\="settercomment_context" deleted\="false" description\="Comment for setter function" enabled\="true" id\="org.eclipse.wst.jsdt.ui.text.codetemplates.settercomment" name\="settercomment">/**\n * @param ${param} the ${bare_field_name} to set\n */</template><template autoinsert\="true" context\="constructorcomment_context" deleted\="false" description\="Comment for created constructors" enabled\="true" id\="org.eclipse.wst.jsdt.ui.text.codetemplates.constructorcomment" name\="constructorcomment">/**\n * ${tags}\n */</template><template autoinsert\="true" context\="filecomment_context" deleted\="false" description\="Comment for created JavaScript files" enabled\="true" id\="org.eclipse.wst.jsdt.ui.text.codetemplates.filecomment" name\="filecomment">/**\n * \n */</template><template autoinsert\="true" context\="typecomment_context" deleted\="false" description\="Comment for created types" enabled\="true" id\="org.eclipse.wst.jsdt.ui.text.codetemplates.typecomment" name\="typecomment">/**\n * @author ${user}\n *\n * ${tags}\n */</template><template autoinsert\="true" context\="fieldcomment_context" deleted\="false" description\="Comment for vars" enabled\="true" id\="org.eclipse.wst.jsdt.ui.text.codetemplates.fieldcomment" name\="fieldcomment">/**\n * \n */</template><template autoinsert\="true" context\="methodcomment_context" deleted\="false" description\="Comment for non-overriding function" enabled\="true" id\="org.eclipse.wst.jsdt.ui.text.codetemplates.methodcomment" name\="methodcomment">/**\n * ${tags}\n */</template><template autoinsert\="true" context\="overridecomment_context" deleted\="false" description\="Comment for overriding functions" enabled\="true" id\="org.eclipse.wst.jsdt.ui.text.codetemplates.overridecomment" name\="overridecomment">/* (non-Jsdoc)\n * ${see_to_overridden}\n */</template><template autoinsert\="true" context\="delegatecomment_context" deleted\="false" description\="Comment for delegate functions" enabled\="true" id\="org.eclipse.wst.jsdt.ui.text.codetemplates.delegatecomment" name\="delegatecomment">/**\n * ${tags}\n * ${see_to_target}\n */</template><template autoinsert\="true" context\="newtype_context" deleted\="false" description\="Newly created files" enabled\="true" id\="org.eclipse.wst.jsdt.ui.text.codetemplates.newtype" name\="newtype">${filecomment}\n${package_declaration}\n\n${typecomment}\n${type_declaration}</template><template autoinsert\="true" context\="classbody_context" deleted\="false" description\="Code in new class type bodies" enabled\="true" id\="org.eclipse.wst.jsdt.ui.text.codetemplates.classbody" name\="classbody">\n</template><template autoinsert\="false" context\="catchblock_context" deleted\="false" description\="Code in new catch blocks" enabled\="true" id\="org.eclipse.wst.jsdt.ui.text.codetemplates.catchblock" name\="catchblock">// ${todo} Auto-generated catch block\nMavenLogger.log(${exception_var});</template><template autoinsert\="true" context\="methodbody_context" deleted\="false" description\="Code in created function stubs" enabled\="true" id\="org.eclipse.wst.jsdt.ui.text.codetemplates.methodbody" name\="methodbody">// ${todo} Auto-generated function stub\n${body_statement}</template><template autoinsert\="true" context\="constructorbody_context" deleted\="false" description\="Code in created constructor stubs" enabled\="true" id\="org.eclipse.wst.jsdt.ui.text.codetemplates.constructorbody" name\="constructorbody">${body_statement}\n// ${todo} Auto-generated constructor stub</template><template autoinsert\="true" context\="getterbody_context" deleted\="false" description\="Code in created getters" enabled\="true" id\="org.eclipse.wst.jsdt.ui.text.codetemplates.getterbody" name\="getterbody">return ${field};</template><template autoinsert\="true" context\="setterbody_context" deleted\="false" description\="Code in created setters" enabled\="true" id\="org.eclipse.wst.jsdt.ui.text.codetemplates.setterbody" name\="setterbody">${field} \= ${param};</template></templates>
+org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?><templates><template autoinsert\="true" context\="gettercomment_context" deleted\="false" description\="Comment for getter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.gettercomment" name\="gettercomment">/**\r\n * @return Returns the ${bare_field_name}.\r\n */</template><template autoinsert\="true" context\="settercomment_context" deleted\="false" description\="Comment for setter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.settercomment" name\="settercomment">/**\r\n * @param ${param} The ${bare_field_name} to set.\r\n */</template><template autoinsert\="true" context\="constructorcomment_context" deleted\="false" description\="Comment for created constructors" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name\="constructorcomment">/**\r\n * ${tags}\r\n */</template><template autoinsert\="false" context\="filecomment_context" deleted\="false" description\="Comment for created Java files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.filecomment" name\="filecomment">/*******************************************************************************&\#13;\r\n * Copyright (c) ${year} Red Hat, Inc. and others.&\#13;\r\n * All rights reserved. This program and the accompanying materials&\#13;\r\n * are made available under the terms of the Eclipse Public License v1.0&\#13;\r\n * which accompanies this distribution, and is available at&\#13;\r\n * http\://www.eclipse.org/legal/epl-v10.html&\#13;\r\n *&\#13;\r\n * Contributors\:&\#13;\r\n * Red Hat, Inc. - initial API and implementation&\#13;\r\n *******************************************************************************/</template><template autoinsert\="false" context\="typecomment_context" deleted\="false" description\="Comment for created types" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.typecomment" name\="typecomment">/**\r\n * ${type_name}\r\n *\r\n * @author ${user}\r\n */</template><template autoinsert\="true" context\="fieldcomment_context" deleted\="false" description\="Comment for fields" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" name\="fieldcomment">/**\r\n * \r\n */</template><template autoinsert\="true" context\="methodcomment_context" deleted\="false" description\="Comment for non-overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodcomment" name\="methodcomment">/**\r\n * ${tags}\r\n */</template><template autoinsert\="true" context\="overridecomment_context" deleted\="false" description\="Comment for overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.overridecomment" name\="overridecomment">/* (non-Javadoc)\r\n * ${see_to_overridden}\r\n */</template><template autoinsert\="false" context\="newtype_context" deleted\="false" description\="Newly created files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.newtype" name\="newtype">${filecomment}\r\n${package_declaration}\r\n\r\n${typecomment}\r\n${type_declaration}</template><template autoinsert\="false" context\="catchblock_context" deleted\="false" description\="Code in new catch blocks" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.catchblock" name\="catchblock">// ${todo} Auto-generated catch block\r\nMavenLogger.log(${exception_var});</template><template autoinsert\="true" context\="methodbody_context" deleted\="false" description\="Code in created method stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodbody" name\="methodbody">// ${todo} Auto-generated method ${enclosing_method}\r\n${body_statement}</template><template autoinsert\="true" context\="constructorbody_context" deleted\="false" description\="Code in created constructor stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorbody" name\="constructorbody">${body_statement}\r\n// ${todo} Auto-generated constructor stub</template><template autoinsert\="true" context\="getterbody_context" deleted\="false" description\="Code in created getters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.getterbody" name\="getterbody">return ${field};</template><template autoinsert\="true" context\="setterbody_context" deleted\="false" description\="Code in created setters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.setterbody" name\="setterbody">${field} \= ${param};</template><template autoinsert\="true" context\="delegatecomment_context" deleted\="false" description\="Comment for delegate methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.delegatecomment" name\="delegatecomment">/**\r\n * ${tags}\r\n * ${see_to_target}\r\n */</template><template autoinsert\="true" context\="classbody_context" deleted\="false" description\="Code in new class type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.classbody" name\="classbody">\r\n</template><template autoinsert\="true" context\="interfacebody_context" deleted\="false" description\="Code in new interface type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.interfacebody" name\="interfacebody">\r\n</template><template autoinsert\="true" context\="enumbody_context" deleted\="false" description\="Code in new enum type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.enumbody" name\="enumbody">\r\n</template><template autoinsert\="true" context\="annotationbody_context" deleted\="false" description\="Code in new annotation type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.annotationbody" name\="annotationbody">\r\n</template><template autoinsert\="true" context\="gettercomment_context" deleted\="false" description\="Comment for getter function" enabled\="true" id\="org.eclipse.wst.jsdt.ui.text.codetemplates.gettercomment" name\="gettercomment">/**\r\n * @return the ${bare_field_name}\r\n */</template><template autoinsert\="true" context\="settercomment_context" deleted\="false" description\="Comment for setter function" enabled\="true" id\="org.eclipse.wst.jsdt.ui.text.codetemplates.settercomment" name\="settercomment">/**\r\n * @param ${param} the ${bare_field_name} to set\r\n */</template><template autoinsert\="true" context\="constructorcomment_context" deleted\="false" description\="Comment for created constructors" enabled\="true" id\="org.eclipse.wst.jsdt.ui.text.codetemplates.constructorcomment" name\="constructorcomment">/**\r\n * ${tags}\r\n */</template><template autoinsert\="true" context\="filecomment_context" deleted\="false" description\="Comment for created JavaScript files" enabled\="true" id\="org.eclipse.wst.jsdt.ui.text.codetemplates.filecomment" name\="filecomment">/**\r\n * \r\n */</template><template autoinsert\="true" context\="typecomment_context" deleted\="false" description\="Comment for created types" enabled\="true" id\="org.eclipse.wst.jsdt.ui.text.codetemplates.typecomment" name\="typecomment">/**\r\n * @author ${user}\r\n *\r\n * ${tags}\r\n */</template><template autoinsert\="true" context\="fieldcomment_context" deleted\="false" description\="Comment for vars" enabled\="true" id\="org.eclipse.wst.jsdt.ui.text.codetemplates.fieldcomment" name\="fieldcomment">/**\r\n * \r\n */</template><template autoinsert\="true" context\="methodcomment_context" deleted\="false" description\="Comment for non-overriding function" enabled\="true" id\="org.eclipse.wst.jsdt.ui.text.codetemplates.methodcomment" name\="methodcomment">/**\r\n * ${tags}\r\n */</template><template autoinsert\="true" context\="overridecomment_context" deleted\="false" description\="Comment for overriding functions" enabled\="true" id\="org.eclipse.wst.jsdt.ui.text.codetemplates.overridecomment" name\="overridecomment">/* (non-Jsdoc)\r\n * ${see_to_overridden}\r\n */</template><template autoinsert\="true" context\="delegatecomment_context" deleted\="false" description\="Comment for delegate functions" enabled\="true" id\="org.eclipse.wst.jsdt.ui.text.codetemplates.delegatecomment" name\="delegatecomment">/**\r\n * ${tags}\r\n * ${see_to_target}\r\n */</template><template autoinsert\="true" context\="newtype_context" deleted\="false" description\="Newly created files" enabled\="true" id\="org.eclipse.wst.jsdt.ui.text.codetemplates.newtype" name\="newtype">${filecomment}\r\n${package_declaration}\r\n\r\n${typecomment}\r\n${type_declaration}</template><template autoinsert\="true" context\="classbody_context" deleted\="false" description\="Code in new class type bodies" enabled\="true" id\="org.eclipse.wst.jsdt.ui.text.codetemplates.classbody" name\="classbody">\r\n</template><template autoinsert\="false" context\="catchblock_context" deleted\="false" description\="Code in new catch blocks" enabled\="true" id\="org.eclipse.wst.jsdt.ui.text.codetemplates.catchblock" name\="catchblock">// ${todo} Auto-generated catch block\r\nMavenLogger.log(${exception_var});</template><template autoinsert\="true" context\="methodbody_context" deleted\="false" description\="Code in created function stubs" enabled\="true" id\="org.eclipse.wst.jsdt.ui.text.codetemplates.methodbody" name\="methodbody">// ${todo} Auto-generated function stub\r\n${body_statement}</template><template autoinsert\="true" context\="constructorbody_context" deleted\="false" description\="Code in created constructor stubs" enabled\="true" id\="org.eclipse.wst.jsdt.ui.text.codetemplates.constructorbody" name\="constructorbody">${body_statement}\r\n// ${todo} Auto-generated constructor stub</template><template autoinsert\="true" context\="getterbody_context" deleted\="false" description\="Code in created getters" enabled\="true" id\="org.eclipse.wst.jsdt.ui.text.codetemplates.getterbody" name\="getterbody">return ${field};</template><template autoinsert\="true" context\="setterbody_context" deleted\="false" description\="Code in created setters" enabled\="true" id\="org.eclipse.wst.jsdt.ui.text.codetemplates.setterbody" name\="setterbody">${field} \= ${param};</template></templates>
+sp_cleanup.add_default_serial_version_id=true
+sp_cleanup.add_generated_serial_version_id=false
+sp_cleanup.add_missing_annotations=true
+sp_cleanup.add_missing_deprecated_annotations=true
+sp_cleanup.add_missing_methods=false
+sp_cleanup.add_missing_nls_tags=false
+sp_cleanup.add_missing_override_annotations=true
+sp_cleanup.add_missing_override_annotations_interface_methods=true
+sp_cleanup.add_serial_version_id=false
+sp_cleanup.always_use_blocks=true
+sp_cleanup.always_use_parentheses_in_expressions=false
+sp_cleanup.always_use_this_for_non_static_field_access=false
+sp_cleanup.always_use_this_for_non_static_method_access=false
+sp_cleanup.convert_to_enhanced_for_loop=false
+sp_cleanup.correct_indentation=false
+sp_cleanup.format_source_code=false
+sp_cleanup.format_source_code_changes_only=false
+sp_cleanup.make_local_variable_final=false
+sp_cleanup.make_parameters_final=false
+sp_cleanup.make_private_fields_final=true
+sp_cleanup.make_type_abstract_if_missing_method=false
+sp_cleanup.make_variable_declarations_final=true
+sp_cleanup.never_use_blocks=false
+sp_cleanup.never_use_parentheses_in_expressions=true
+sp_cleanup.on_save_use_additional_actions=false
+sp_cleanup.organize_imports=true
+sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
+sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
+sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
+sp_cleanup.qualify_static_member_accesses_with_declaring_class=false
+sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
+sp_cleanup.remove_private_constructors=true
+sp_cleanup.remove_trailing_whitespaces=false
+sp_cleanup.remove_trailing_whitespaces_all=true
+sp_cleanup.remove_trailing_whitespaces_ignore_empty=false
+sp_cleanup.remove_unnecessary_casts=true
+sp_cleanup.remove_unnecessary_nls_tags=false
+sp_cleanup.remove_unused_imports=false
+sp_cleanup.remove_unused_local_variables=false
+sp_cleanup.remove_unused_private_fields=true
+sp_cleanup.remove_unused_private_members=false
+sp_cleanup.remove_unused_private_methods=true
+sp_cleanup.remove_unused_private_types=true
+sp_cleanup.sort_members=false
+sp_cleanup.sort_members_all=false
+sp_cleanup.use_blocks=false
+sp_cleanup.use_blocks_only_for_return_and_throw=false
+sp_cleanup.use_parentheses_in_expressions=false
+sp_cleanup.use_this_for_non_static_field_access=false
+sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
+sp_cleanup.use_this_for_non_static_method_access=false
+sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
View
3  org.jboss.tools.maven.apt.core/META-INF/MANIFEST.MF
@@ -4,7 +4,6 @@ Bundle-Name: %Bundle-Name
Bundle-SymbolicName: org.jboss.tools.maven.apt.core;singleton:=true
Bundle-Version: 1.0.0.qualifier
Bundle-Localization: plugin
-Export-Package: org.jboss.tools.maven.apt
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.core.resources,
org.eclipse.jdt.core,
@@ -15,7 +14,7 @@ Require-Bundle: org.eclipse.core.runtime,
org.eclipse.m2e.maven.runtime,
org.slf4j.api;bundle-version="1.6.1"
Eclipse-LazyStart: true
-Bundle-Activator: org.jboss.tools.maven.apt.MavenJdtAptPlugin
+Bundle-Activator: org.jboss.tools.maven.apt.internal.MavenJdtAptPlugin
Bundle-RequiredExecutionEnvironment: J2SE-1.5,
JavaSE-1.6
Bundle-Vendor: %Bundle-Vendor
View
20 org.jboss.tools.maven.apt.core/lifecycle-mapping-metadata.xml
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<lifecycleMappingMetadata>
-
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
@@ -17,7 +16,24 @@
</pluginExecutionFilter>
<action>
<configurator>
- <id>org.jboss.tools.maven.apt.AptProjectConfigurator</id>
+ <id>org.jboss.tools.maven.apt.MavenCompilerAptProjectConfigurator</id>
+ </configurator>
+ </action>
+ </pluginExecution>
+
+ <pluginExecution>
+ <pluginExecutionFilter>
+ <groupId>org.bsc.maven</groupId>
+ <artifactId>maven-processor-plugin</artifactId>
+ <versionRange>[1.3.0,)</versionRange>
+ <goals>
+ <goal>process</goal>
+ <goal>process-test</goal>
+ </goals>
+ </pluginExecutionFilter>
+ <action>
+ <configurator>
+ <id>org.jboss.tools.maven.apt.MavenProcessorAptProjectConfigurator</id>
</configurator>
</action>
</pluginExecution>
View
13 org.jboss.tools.maven.apt.core/plugin.xml
@@ -11,11 +11,18 @@
<extension
point="org.eclipse.m2e.core.projectConfigurators">
<configurator
- class="org.jboss.tools.maven.apt.AptProjectConfigurator"
- id="org.jboss.tools.maven.apt.AptProjectConfigurator"
- name="%configurator.jdt.apt.name"
+ class="org.jboss.tools.maven.apt.internal.MavenCompilerAptProjectConfigurator"
+ id="org.jboss.tools.maven.apt.MavenCompilerAptProjectConfigurator"
+ name="%configurator.jdt.apt.name compiler"
secondaryTo="org.eclipse.m2e.jdt.javaConfigurator">
</configurator>
+
+ <configurator
+ class="org.jboss.tools.maven.apt.internal.MavenProcessorAptProjectConfigurator"
+ id="org.jboss.tools.maven.apt.MavenProcessorAptProjectConfigurator"
+ name="%configurator.jdt.apt.name processor"
+ >
+ </configurator>
</extension>
<extension
point="org.eclipse.m2e.core.lifecycleMappingMetadataSource">
View
399 ...jboss/tools/maven/apt/AptProjectConfigurator.java → .../apt/internal/AbstractAptProjectConfigurator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011 Knowledge Computing Corp.
+ * Copyright (c) 2011 Knowledge Computing Corp. and others
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,28 +7,28 @@
*
* Contributors:
* Karl M. Davis (Knowledge Computing Corp.) - initial API and implementation
+ * Red Hat, Inc - refactoring and abstraction of the logic
*******************************************************************************/
-package org.jboss.tools.maven.apt;
+package org.jboss.tools.maven.apt.internal;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
+import java.util.LinkedHashSet;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter;
import org.apache.maven.execution.MavenSession;
-import org.apache.maven.plugin.MojoExecution;
import org.apache.maven.project.MavenProject;
-import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -38,13 +38,12 @@
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.m2e.core.project.IMavenProjectFacade;
-import org.eclipse.m2e.core.project.MavenProjectChangedEvent;
import org.eclipse.m2e.core.project.configurator.AbstractProjectConfigurator;
import org.eclipse.m2e.core.project.configurator.ProjectConfigurationRequest;
import org.eclipse.m2e.jdt.IClasspathDescriptor;
import org.eclipse.m2e.jdt.IClasspathEntryDescriptor;
import org.eclipse.m2e.jdt.IJavaProjectConfigurator;
-import org.jboss.tools.maven.apt.AnnotationServiceLocator.ServiceEntry;
+import org.jboss.tools.maven.apt.internal.AnnotationServiceLocator.ServiceEntry;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -69,49 +68,21 @@
* compiler used by Eclipse may not recognize when the generated annotation sources/classes are out of date.</li>
* </ul>
* <p>
- * The {@link AptProjectConfigurator} works around those limitations by configuring Eclipse's built-in annotation
+ * The {@link AbstractAptProjectConfigurator} works around those limitations by configuring Eclipse's built-in annotation
* processing: APT. Unfortunately, the APT configuration will not allow for libraries, such as m2eclipse's
* "Maven Dependencies" to be used in the search path for annotation processors. Instead, the
- * {@link AptProjectConfigurator} adds all of the project's <code>.jar</code> dependencies to the annotation processor
+ * {@link AbstractAptProjectConfigurator} adds all of the project's <code>.jar</code> dependencies to the annotation processor
* search path.
* </p>
*/
-public final class AptProjectConfigurator extends AbstractProjectConfigurator implements IJavaProjectConfigurator {
+abstract class AbstractAptProjectConfigurator extends AbstractProjectConfigurator implements IJavaProjectConfigurator {
+
private static final String M2_REPO = "M2_REPO";
- /**
- * The <code>groupId</code> of the <a href="http://maven.apache.org/plugins/maven-compiler-plugin/">Maven Compiler
- * Plugin</a>.
- */
- private static final String COMPILER_PLUGIN_GROUP_ID = "org.apache.maven.plugins";
-
- /**
- * The <code>artifactId</code> of the <a href="http://maven.apache.org/plugins/maven-compiler-plugin/">Maven Compiler
- * Plugin</a>.
- */
- private static final String COMPILER_PLUGIN_ARTIFACT_ID = "maven-compiler-plugin";
-
- /**
- * The name of the <a href="http://maven.apache.org/plugins/maven-compiler-plugin/">Maven Compiler Plugin</a>'s
- * "compile" goal.
- */
- private static final String GOAL_COMPILE = "compile";
-
- /**
- * The {@link IMarker#setAttribute(String, Object)} key used for all {@link IMarker}s created by
- * {@link AptProjectConfigurator}, to identify the reason it was created.
- */
- private static final String MARKER_ATTRIB_TYPE = AptProjectConfigurator.class.getName() + ".type";
-
- /**
- * The {@link IMarker#setAttribute(String, Object)} value used to identify "update your project" markers.
- *
- * @see #MARKER_ATTRIB_TYPE
- */
- private static final String MARKER_ATTRIB_TYPE_UPDATE = "updateProject";
+ private static final Logger LOG = LoggerFactory.getLogger(AbstractAptProjectConfigurator.class);
- private static final Logger log = LoggerFactory.getLogger(AptProjectConfigurator.class);
+ protected abstract AnnotationProcessorConfiguration getAnnotationProcessorConfiguration(IMavenProjectFacade mavenProjectFacade, MavenSession mavenSession, IProgressMonitor monitor) throws CoreException;
/**
* {@inheritDoc}
@@ -123,130 +94,22 @@ public void configure(ProjectConfigurationRequest request, IProgressMonitor moni
if(request == null || monitor == null)
return;
- // Clear any old "update your project" markers
- IResource pomResource = findPomResource(request.getMavenProjectFacade());
- clearUpdateWarnings(pomResource);
-
// Get the objects needed for APT configuration
IMavenProjectFacade mavenProjectFacade = request.getMavenProjectFacade();
IProject eclipseProject = mavenProjectFacade.getProject();
MavenSession mavenSession = request.getMavenSession();
-
- // Configure APT
- configureAptForProject(eclipseProject, mavenSession, mavenProjectFacade, monitor);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void mavenProjectChanged(MavenProjectChangedEvent event, IProgressMonitor monitor) throws CoreException {
- super.mavenProjectChanged(event, monitor);
- /*
- * I'm not sure we want to re-configure the Eclipse project every time the POM
- * changes-- might end up overwriting the user's manual changes to the Eclipse
- * project. If we do decide to do that, we'll need to create a new MavenSession,
- * as done in ProjectConfigurationManager.createMavenSession(...).
- */
- // configureAptForProject(eclipseProject, mavenSession, mavenProjectFacade, monitor);
-
- /*
- * Additionally, it doesn't seem that applying an update warning here works correctly: the
- * mavenProjectChanged(...) event seems to be fired after every configure(...) event. This
- * causes any markers to be removed and then added again every time APT is configured.
- */
- // IResource pomResource = findPomResource(event.getMavenProject());
- // applyUpdateWarning(pomResource);
- }
-
- /**
- * {@inheritDoc}
- */
- public void configureClasspath(IMavenProjectFacade facade, IClasspathDescriptor classpath, IProgressMonitor monitor) {
- /*
- * Implementations of this method are supposed to configure the Maven project
- * classpath: the "Maven Dependencies" container. We don't have any need to do
- * that here.
- */
- }
-
- /**
- * {@inheritDoc}
- */
- public void configureRawClasspath(ProjectConfigurationRequest request, IClasspathDescriptor classpath,
- IProgressMonitor monitor) throws CoreException {
- /*
- * We need to prevent/recover from the JavaProjectConfigurator removing the
- * generated annotation sources directory from the classpath: it will be added
- * when we configure the Eclipse APT preferences and then removed when the
- * JavaProjectConfigurator runs.
- */
-
- // Get the various project references we'll need
- IProject eclipseProject = request.getProject();
- MavenProject mavenProject = request.getMavenProject();
- IMavenProjectFacade projectFacade = request.getMavenProjectFacade();
-
- // If this isn't a Java project, we have nothing to do
- if(!eclipseProject.hasNature(JavaCore.NATURE_ID))
- return;
-
- //If APT is not enabled, nothing to do either
- IJavaProject javaProject = JavaCore.create(eclipseProject);
- if (!AptConfig.isEnabled(javaProject)) {
- return;
- }
- // If this project has no valid compiler plugin config, we have nothing to do
- File generatedSourcesDirectory = getGeneratedSourcesDirectory(request.getMavenSession(), projectFacade, monitor);
- if(generatedSourcesDirectory == null)
+ if (ignoreConfigurator(mavenProjectFacade, monitor)) {
return;
-
- // Get the generated annotation sources directory as an IFolder
- File generatedSourcesRelativeDirectory = convertToProjectRelativePath(eclipseProject, generatedSourcesDirectory);
- String generatedSourcesRelativeDirectoryPath = generatedSourcesRelativeDirectory.getPath();
- IFolder generatedSourcesFolder = eclipseProject.getFolder(generatedSourcesRelativeDirectoryPath);
-
- // Get the output folder to use as an IPath
- File outputFile = new File(mavenProject.getBuild().getOutputDirectory());
- File outputRelativeFile = convertToProjectRelativePath(eclipseProject, outputFile);
- IFolder outputFolder = eclipseProject.getFolder(outputRelativeFile.getPath());
- IPath outputPath = outputFolder.getFullPath();
-
- // Create the includes & excludes specifiers
- IPath[] includes = new IPath[] {};
- IPath[] excludes = new IPath[] {};
-
- // If the source folder exists and is non-nested, add it
- if(generatedSourcesFolder != null && generatedSourcesFolder.exists()
- && generatedSourcesFolder.getProject().equals(eclipseProject)) {
- IClasspathEntryDescriptor cped = getEnclosingEntryDescriptor(classpath, generatedSourcesFolder.getFullPath());
- if(cped == null) {
- classpath.addSourceEntry(generatedSourcesFolder.getFullPath(), outputPath, includes, excludes, false);
- }
- } else {
- if(generatedSourcesFolder != null) {
- classpath.removeEntry(generatedSourcesFolder.getFullPath());
- }
}
+
+ AnnotationProcessorConfiguration configuration = getAnnotationProcessorConfiguration(mavenProjectFacade, mavenSession, monitor);
+ // Configure APT
+ configureAptForProject(eclipseProject, mavenProjectFacade, configuration, monitor);
}
- /**
- * Returns the {@link IClasspathEntryDescriptor} in the specified {@link IClasspathDescriptor} that is a prefix of the
- * specified {@link IPath}.
- *
- * @param classpath the {@link IClasspathDescriptor} to be searched for a matching {@link IClasspathEntryDescriptor}
- * @param path the {@link IPath} to find a matching {@link IClasspathEntryDescriptor} for
- * @return the {@link IClasspathEntryDescriptor} in the specified {@link IClasspathDescriptor} that is a prefix of the
- * specified {@link IPath}
- */
- private static IClasspathEntryDescriptor getEnclosingEntryDescriptor(IClasspathDescriptor classpath, IPath path) {
- for(IClasspathEntryDescriptor cped : classpath.getEntryDescriptors()) {
- if(cped.getPath().isPrefixOf(path)) {
- return cped;
- }
- }
- return null;
+ protected boolean ignoreConfigurator(IMavenProjectFacade mavenProjectFacade, IProgressMonitor monitor) throws CoreException {
+ return false;
}
/**
@@ -255,33 +118,39 @@ private static IClasspathEntryDescriptor getEnclosingEntryDescriptor(IClasspathD
* @param eclipseProject an {@link IProject} reference to the Eclipse project being configured
* @param mavenProject {@link IMavenProjectFacade} reference to the Maven project being configured
* @param monitor the {@link IProgressMonitor} to use
+ * @param mavenProjectFacade
* @throws CoreException Any {@link CoreException}s thrown will be passed through.
*/
- private void configureAptForProject(IProject eclipseProject, MavenSession mavenSession,
- IMavenProjectFacade mavenProjectFacade, IProgressMonitor monitor) throws CoreException {
- IJavaProject javaProject = JavaCore.create(eclipseProject);
- File generatedSourcesDirectory = getGeneratedSourcesDirectory(mavenSession, mavenProjectFacade, monitor);
+ private void configureAptForProject(IProject eclipseProject, IMavenProjectFacade mavenProjectFacade, AnnotationProcessorConfiguration configuration, IProgressMonitor monitor) throws CoreException {
- // If this isn't a Java project, we have nothing to do
- if(!eclipseProject.hasNature(JavaCore.NATURE_ID))
- return;
+ // In case the Javaconfigurator was not called yet (eg. maven-processor-plugin being bound to process-sources,
+ // that project configurator runs first) We need to add the Java Nature before setting the APT config.
+ if(!eclipseProject.hasNature(JavaCore.NATURE_ID)) {
+ addNature(eclipseProject, JavaCore.NATURE_ID, monitor);
+ }
+
+ File generatedSourcesDirectory = configuration.getOutputDirectory();
- // If this project has no valid compiler plugin config, we have nothing to do
+ // If this project has no valid generatedSourcesDirectory, we have nothing to do
if(generatedSourcesDirectory == null)
return;
+ IJavaProject javaProject = JavaCore.create(eclipseProject);
+
+ //The plugin dependencies are added first to the classpath
+ LinkedHashSet<File> resolvedJarArtifacts = new LinkedHashSet<File>(configuration.getDependencies());
// Get the project's dependencies
List<Artifact> artifacts = getProjectArtifacts(mavenProjectFacade);
- List<File> resolvedJarArtifacts = filterToResolvedJars(artifacts);
-
+ resolvedJarArtifacts.addAll(filterToResolvedJars(artifacts));
+
// Inspect the dependencies to see if any contain APT processors
- boolean isAnnotationProcessingEnabled = !isProcNone()//Will be ignored when org.bsc.maven:maven-processor-plugin is used
+ boolean isAnnotationProcessingEnabled = configuration.isAnnotationProcessingEnabled()
&& containsAptProcessors(resolvedJarArtifacts);
// Enable/Disable APT (depends on whether APT processors were found)
AptConfig.setEnabled(javaProject, isAnnotationProcessingEnabled);
- //If no annotation processor were found, we should leave.
+ //If no annotation processor is disabled, we can leave.
if (!isAnnotationProcessingEnabled) {
return;
}
@@ -289,6 +158,8 @@ private void configureAptForProject(IProject eclipseProject, MavenSession mavenS
// Configure APT output path
File generatedSourcesRelativeDirectory = convertToProjectRelativePath(eclipseProject, generatedSourcesDirectory);
String generatedSourcesRelativeDirectoryPath = generatedSourcesRelativeDirectory.getPath();
+
+ //createFolder(eclipseProject.getFolder(generatedSourcesRelativeDirectoryPath), monitor);
AptConfig.setGenSrcDir(javaProject, generatedSourcesRelativeDirectoryPath);
/*
@@ -312,23 +183,27 @@ private void configureAptForProject(IProject eclipseProject, MavenSession mavenS
for(File resolvedJarArtifact : resolvedJarArtifactsInReverseOrder) {
IPath absolutePath = new Path(resolvedJarArtifact.getAbsolutePath());
+ //reference jars in a portable way
if (m2RepoPath != null && m2RepoPath.isPrefixOf(absolutePath)) {
IPath relativePath = absolutePath.removeFirstSegments(m2RepoPath.segmentCount()).makeRelative().setDevice(null);
IPath variablePath = new Path(M2_REPO).append(relativePath);
factoryPath.addVarJar(variablePath);
} else {
+ //fall back on using absolute references.
factoryPath.addExternalJar(resolvedJarArtifact);
}
}
+ Map<String, String> currentOptions = AptConfig.getProcessorOptions(javaProject);
+ Map<String, String> newOptions = configuration.getAnnotationProcessorOptions();
+ if (!currentOptions.equals(newOptions)) {
+ AptConfig.setProcessorOptions(newOptions, javaProject);
+ }
+
// Apply that IFactoryPath to the project
AptConfig.setFactoryPath(javaProject, factoryPath);
}
- private boolean isProcNone() {
- // TODO Check if annotation processing is disabled with -proc:none
- return false;
- }
/**
* @param mavenProjectFacade the {@link IMavenProjectFacade} to get the {@link Artifact}s for
@@ -349,32 +224,6 @@ private boolean isProcNone() {
return orderedArtifacts;
}
- /**
- * Returns the <code>generatedSourcesDirectory</code> configuration parameter of the
- * {@link #COMPILER_PLUGIN_ARTIFACT_ID} plugin, or <code>null</code> if the {@link #GOAL_COMPILE} is not being
- * executed for this project.
- *
- * @param mavenSession the {@link MavenSession} being used
- * @param mavenProjectFacade the {@link IMavenProjectFacade} of the project to get the
- * <code>generatedSourcesDirectory</code> configuration parameter from
- * @param monitor the {@link IProgressMonitor} for this operation
- * @return the <code>generatedSourcesDirectory</code> configuration parameter of the
- * {@link #COMPILER_PLUGIN_ARTIFACT_ID} plugin, or <code>null</code> if the {@link #GOAL_COMPILE} is not being
- * executed for this project
- * @throws CoreException Any {@link CoreException}s encountered will be passed through.
- */
- private File getGeneratedSourcesDirectory(MavenSession mavenSession, IMavenProjectFacade mavenProjectFacade,
- IProgressMonitor monitor) throws CoreException {
- for(MojoExecution mojoExecution : mavenProjectFacade.getMojoExecutions(COMPILER_PLUGIN_GROUP_ID,
- COMPILER_PLUGIN_ARTIFACT_ID, monitor, GOAL_COMPILE)) {
- File generatedSourcesDirectory = maven.getMojoParameterValue(mavenSession, mojoExecution,
- "generatedSourcesDirectory", File.class);
- if(generatedSourcesDirectory != null)
- return generatedSourcesDirectory;
- }
-
- return null;
- }
/**
* <p>
@@ -392,7 +241,7 @@ private File getGeneratedSourcesDirectory(MavenSession mavenSession, IMavenProje
*/
private static List<File> filterToResolvedJars(List<Artifact> artifacts) {
List<File> resolvedJarArtifacts = new ArrayList<File>();
- ScopeArtifactFilter filter = new ScopeArtifactFilter(Artifact.SCOPE_COMPILE);
+ ScopeArtifactFilter filter = new ScopeArtifactFilter(Artifact.SCOPE_COMPILE_PLUS_RUNTIME);
for(Artifact artifact : artifacts) {
// Ensure that this Artifact should be included
@@ -447,7 +296,7 @@ private static boolean containsAptProcessors(Collection<File> resolvedJarArtifac
* @param fileToConvert the relative or absolute {@link File} to convert
* @return a {@link File} that is relative to the base directory of the specified {@link IProject}
*/
- private File convertToProjectRelativePath(IProject project, File fileToConvert) {
+ protected File convertToProjectRelativePath(IProject project, File fileToConvert) {
// Get an absolute version of the specified file
File absoluteFile = fileToConvert.getAbsoluteFile();
String absoluteFilePath = absoluteFile.getAbsolutePath();
@@ -468,65 +317,119 @@ private File convertToProjectRelativePath(IProject project, File fileToConvert)
}
/**
- * Returns the {@link IResource} for the specified {@link IMavenProjectFacade}'s POM.
- *
- * @param mavenProjectFacade the {@link IMavenProjectFacade} to get the POM for
- * @return the {@link IResource} for the specified {@link IMavenProjectFacade}'s POM
+ * {@inheritDoc}
*/
- private static IResource findPomResource(IMavenProjectFacade mavenProjectFacade) {
- IFile pomFile = mavenProjectFacade.getPom();
- IResource pomResource = pomFile;
- return pomResource;
+ public void configureClasspath(IMavenProjectFacade facade, IClasspathDescriptor classpath, IProgressMonitor monitor) {
+ /*
+ * Implementations of this method are supposed to configure the Maven project
+ * classpath: the "Maven Dependencies" container. We don't have any need to do
+ * that here.
+ */
}
/**
- * Returns the update warning {@link IMarker}s attached to the specified {@link IResource}.
- *
- * @param resource the {@link IResource} to find the update warning {@link IMarker}s of
- * @return the update warning {@link IMarker}s attached to the specified {@link IResource}
- * @throws CoreException Any {@link CoreException}s encountered will be passed through.
+ * {@inheritDoc}
*/
- private static List<IMarker> findUpdateWarnings(IResource resource) throws CoreException {
- IMarker[] problemMarkers = resource.findMarkers(IMarker.PROBLEM, false, IResource.DEPTH_ZERO);
- List<IMarker> updateWarningMarkers = new ArrayList<IMarker>();
- for(IMarker problemMarker : problemMarkers)
- if(MARKER_ATTRIB_TYPE_UPDATE.equals(problemMarker.getAttribute(MARKER_ATTRIB_TYPE)))
- updateWarningMarkers.add(problemMarker);
- return updateWarningMarkers;
- }
+ public void configureRawClasspath(ProjectConfigurationRequest request, IClasspathDescriptor classpath,
+ IProgressMonitor monitor) throws CoreException {
+ /*
+ * We need to prevent/recover from the JavaProjectConfigurator removing the
+ * generated annotation sources directory from the classpath: it will be added
+ * when we configure the Eclipse APT preferences and then removed when the
+ * JavaProjectConfigurator runs.
+ */
- /**
- * Applies an update warning {@link IMarker} to the specified {@link IResource}. If one is already present, this
- * method does nothing.
- *
- * @param resource the {@link IResource} to apply the update warning {@link IMarker} to
- * @throws CoreException Any {@link CoreException}s encountered will be passed through.
- */
- @SuppressWarnings("unused")
- private static void applyUpdateWarning(IResource resource) throws CoreException {
- // No need to add the same marker twice to the same resource
- if(!findUpdateWarnings(resource).isEmpty())
+ // Get the various project references we'll need
+ IProject eclipseProject = request.getProject();
+ MavenProject mavenProject = request.getMavenProject();
+ IMavenProjectFacade projectFacade = request.getMavenProjectFacade();
+ MavenSession mavenSession = request.getMavenSession();
+
+ // If this isn't a Java project, we have nothing to do
+ if(!eclipseProject.hasNature(JavaCore.NATURE_ID))
return;
- IMarker warningMarker = resource.createMarker(IMarker.PROBLEM);
- warningMarker.setAttribute(MARKER_ATTRIB_TYPE, MARKER_ATTRIB_TYPE_UPDATE);
- warningMarker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_WARNING);
- warningMarker.setAttribute(IMarker.MESSAGE,
- "The Maven POM has changed, but the Eclipse project's APT configuration was not updated."
- + " Run \"Maven > Update Project Configuration\" to resolve this.");
- log.debug("applied warning marker");
+ if (ignoreConfigurator(projectFacade, monitor)) {
+ return;
+ }
+
+ //If APT is not enabled, nothing to do either
+ IJavaProject javaProject = JavaCore.create(eclipseProject);
+ if (!AptConfig.isEnabled(javaProject)) {
+ return;
+ }
+
+ AnnotationProcessorConfiguration configuration = getAnnotationProcessorConfiguration(projectFacade, mavenSession, monitor);
+ if (!configuration.isAnnotationProcessingEnabled()) {
+ return;
+ }
+
+ // If this project has no valid compiler plugin config, we have nothing to do
+ File generatedSourcesDirectory = configuration.getOutputDirectory();
+ if(generatedSourcesDirectory == null)
+ return;
+
+ // Get the generated annotation sources directory as an IFolder
+ File generatedSourcesRelativeDirectory = convertToProjectRelativePath(eclipseProject, generatedSourcesDirectory);
+ String generatedSourcesRelativeDirectoryPath = generatedSourcesRelativeDirectory.getPath();
+ IFolder generatedSourcesFolder = eclipseProject.getFolder(generatedSourcesRelativeDirectoryPath);
+
+ // Get the output folder to use as an IPath
+ File outputFile = new File(mavenProject.getBuild().getOutputDirectory());
+ File outputRelativeFile = convertToProjectRelativePath(eclipseProject, outputFile);
+ IFolder outputFolder = eclipseProject.getFolder(outputRelativeFile.getPath());
+ IPath outputPath = outputFolder.getFullPath();
+
+ // Create the includes & excludes specifiers
+ IPath[] includes = new IPath[] {};
+ IPath[] excludes = new IPath[] {};
+
+ // If the source folder exists and is non-nested, add it
+ if(generatedSourcesFolder != null && generatedSourcesFolder.exists()
+ && generatedSourcesFolder.getProject().equals(eclipseProject)) {
+ IClasspathEntryDescriptor cped = getEnclosingEntryDescriptor(classpath, generatedSourcesFolder.getFullPath());
+ if(cped == null) {
+ classpath.addSourceEntry(generatedSourcesFolder.getFullPath(), outputPath, includes, excludes, false);
+ }
+ } else {
+ if(generatedSourcesFolder != null) {
+ classpath.removeEntry(generatedSourcesFolder.getFullPath());
+ }
+ }
}
/**
- * Clears all update warning {@link IMarker}s attached to the specified {@link IResource}.
+ * Returns the {@link IClasspathEntryDescriptor} in the specified {@link IClasspathDescriptor} that is a prefix of the
+ * specified {@link IPath}.
*
- * @param resource the {@link IResource} to clear update warning {@link IMarker}s from
- * @throws CoreException Any {@link CoreException}s encountered will be passed through.
+ * @param classpath the {@link IClasspathDescriptor} to be searched for a matching {@link IClasspathEntryDescriptor}
+ * @param path the {@link IPath} to find a matching {@link IClasspathEntryDescriptor} for
+ * @return the {@link IClasspathEntryDescriptor} in the specified {@link IClasspathDescriptor} that is a prefix of the
+ * specified {@link IPath}
*/
- private static void clearUpdateWarnings(IResource resource) throws CoreException {
- List<IMarker> warningMarkers = findUpdateWarnings(resource);
- for(IMarker warningMarker : warningMarkers)
- warningMarker.delete();
- log.debug("cleared warning markers");
+ private static IClasspathEntryDescriptor getEnclosingEntryDescriptor(IClasspathDescriptor classpath, IPath path) {
+ for(IClasspathEntryDescriptor cped : classpath.getEntryDescriptors()) {
+ if(cped.getPath().isPrefixOf(path)) {
+ return cped;
+ }
+ }
+ return null;
}
+
+ private void createFolder(final IFolder folder, IProgressMonitor monitor)
+ throws CoreException {
+ if (!folder.exists()) {
+ if (folder.getParent() instanceof IFolder) {
+ createFolder((IFolder) folder.getParent(), monitor);
+ }
+ folder.create(true /* force */, true /* local */, monitor);
+ } else {
+ IContainer x = folder;
+ while (x instanceof IFolder && x.isDerived()) {
+ x.setDerived(false, monitor);
+ x = x.getParent();
+ }
+ }
+ }
+
}
View
31 org.jboss.tools.maven.apt.core/src/org/jboss/tools/maven/apt/internal/AnnotationProcessorConfiguration.java
@@ -0,0 +1,31 @@
+/*************************************************************************************
+ * Copyright (c) 2008-2012 Red Hat, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc - Initial implementation.
+ ************************************************************************************/
+
+package org.jboss.tools.maven.apt.internal;
+
+import java.io.File;
+import java.util.List;
+import java.util.Map;
+
+
+public interface AnnotationProcessorConfiguration {
+
+ boolean isAnnotationProcessingEnabled();
+
+ Map<String, String> getAnnotationProcessorOptions();
+
+ List<File> getDependencies();
+
+ File getOutputDirectory();
+
+ List<String> getAnnotationProcessors();
+
+}
View
2  ...oss/tools/maven/apt/AnnotationServiceLocator.java → .../maven/apt/internal/AnnotationServiceLocator.java
@@ -9,7 +9,7 @@
* Karl M. Davis (Knowledge Computing Corp.) - initial API and implementation
*******************************************************************************/
-package org.jboss.tools.maven.apt;
+package org.jboss.tools.maven.apt.internal;
import java.io.BufferedReader;
import java.io.File;
View
81 ...tools.maven.apt.core/src/org/jboss/tools/maven/apt/internal/DefaultAnnotationProcessorConfiguration.java
@@ -0,0 +1,81 @@
+package org.jboss.tools.maven.apt.internal;
+
+import java.io.File;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+
+/*************************************************************************************
+ * Copyright (c) 2008-2012 Red Hat, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - Initial implementation.
+ ************************************************************************************/
+public class DefaultAnnotationProcessorConfiguration implements AnnotationProcessorConfiguration {
+
+ private boolean isAnnotationProcessingEnabled = false;
+
+ private File outputDirectory = null;
+
+ private Map<String, String> annotationProcessorOptions;
+
+ private List<String> annotationProcessors;
+
+ private List<File> dependencies;
+
+ public File getOutputDirectory() {
+ return outputDirectory;
+ }
+
+ public void setOutputDirectory(File generatedOutputDirectory) {
+ this.outputDirectory = generatedOutputDirectory;
+ }
+
+ public boolean isAnnotationProcessingEnabled() {
+ return isAnnotationProcessingEnabled;
+ }
+
+ public void setAnnotationProcessingEnabled(boolean enabled) {
+ this.isAnnotationProcessingEnabled = enabled;
+ }
+
+
+ public Map<String, String> getAnnotationProcessorOptions() {
+ if (annotationProcessorOptions == null) {
+ return Collections.emptyMap();
+ }
+ return Collections.unmodifiableMap(annotationProcessorOptions);
+ }
+
+ public void setAnnotationProcessorOptions(Map<String, String> annotationProcessorOptions) {
+ this.annotationProcessorOptions = annotationProcessorOptions;
+ }
+
+ public List<File> getDependencies() {
+ if (dependencies == null) {
+ return Collections.emptyList();
+ }
+ return Collections.unmodifiableList(dependencies);
+ }
+
+ public void setDependencies(List<File> dependencies) {
+ this.dependencies = dependencies;
+ }
+
+ public List<String> getAnnotationProcessors() {
+ if (annotationProcessors == null) {
+ return Collections.emptyList();
+ }
+ return Collections.unmodifiableList(annotationProcessors);
+ }
+
+ public void setAnnotationProcessors(List<String> annotationProcessors) {
+ this.annotationProcessors = annotationProcessors;
+ }
+
+}
View
86 ...oss.tools.maven.apt.core/src/org/jboss/tools/maven/apt/internal/MavenCompilerAptProjectConfigurator.java
@@ -0,0 +1,86 @@
+/*************************************************************************************
+ * Copyright (c) 2008-2012 Red Hat, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * JBoss by Red Hat - Initial implementation.
+ * Karl M. Davis (Knowledge Computing Corp.) - initial implementation
+ ************************************************************************************/
+package org.jboss.tools.maven.apt.internal;
+
+import java.io.File;
+import java.util.List;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+
+import org.apache.maven.execution.MavenSession;
+import org.apache.maven.plugin.MojoExecution;
+
+import org.eclipse.m2e.core.project.IMavenProjectFacade;
+
+public class MavenCompilerAptProjectConfigurator extends AbstractAptProjectConfigurator {
+
+ /**
+ * The <code>groupId</code> of the <a href="http://maven.apache.org/plugins/maven-compiler-plugin/">Maven Compiler
+ * Plugin</a>.
+ */
+ private static final String COMPILER_PLUGIN_GROUP_ID = "org.apache.maven.plugins";
+
+ /**
+ * The <code>artifactId</code> of the <a href="http://maven.apache.org/plugins/maven-compiler-plugin/">Maven Compiler
+ * Plugin</a>.
+ */
+ private static final String COMPILER_PLUGIN_ARTIFACT_ID = "maven-compiler-plugin";
+
+ /**
+ * The name of the <a href="http://maven.apache.org/plugins/maven-compiler-plugin/">Maven Compiler Plugin</a>'s
+ * "compile" goal.
+ */
+ private static final String GOAL_COMPILE = "compile";
+
+ @Override
+ protected AnnotationProcessorConfiguration getAnnotationProcessorConfiguration(
+ IMavenProjectFacade mavenProjectFacade, MavenSession mavenSession, IProgressMonitor monitor) throws CoreException {
+
+ for(MojoExecution mojoExecution : mavenProjectFacade.getMojoExecutions(COMPILER_PLUGIN_GROUP_ID,
+ COMPILER_PLUGIN_ARTIFACT_ID, monitor, GOAL_COMPILE)) {
+ File generatedOutputDirectory = maven.getMojoParameterValue(mavenSession, mojoExecution, "generatedSourcesDirectory", File.class);
+ String compilerArgument = maven.getMojoParameterValue(mavenSession, mojoExecution, "compilerArgument", String.class);
+
+ boolean isAnnotationProcessingEnabled = compilerArgument == null || !compilerArgument.contains("-proc:none");
+ if (isAnnotationProcessingEnabled ) {
+ String proc = maven.getMojoParameterValue(mavenSession, mojoExecution, "proc", String.class);
+ isAnnotationProcessingEnabled = !"none".equals(proc);
+ }
+
+ PluginDependencyResolver dependencyResolver = new PluginDependencyResolver();
+ List<File> dependencies = dependencyResolver.getResolvedPluginDependencies(mavenSession,
+ mavenProjectFacade.getMavenProject(),
+ mojoExecution.getPlugin(),
+ monitor);
+
+
+
+ DefaultAnnotationProcessorConfiguration configuration = new DefaultAnnotationProcessorConfiguration();
+ configuration.setOutputDirectory(generatedOutputDirectory);
+ configuration.setAnnotationProcessingEnabled(isAnnotationProcessingEnabled);
+ configuration.setDependencies(dependencies);
+ return configuration;
+ }
+
+ return null;
+ }
+
+ @Override
+ protected boolean ignoreConfigurator(IMavenProjectFacade mavenProjectFacade, IProgressMonitor monitor) throws CoreException {
+ return !mavenProjectFacade.getMojoExecutions(MavenProcessorAptProjectConfigurator.PROCESSOR_PLUGIN_GROUP_ID,
+ MavenProcessorAptProjectConfigurator.PROCESSOR_PLUGIN_ARTIFACT_ID,
+ monitor,
+ MavenProcessorAptProjectConfigurator.GOAL_PROCESS).isEmpty();
+ }
+
+}
View
4 .../org/jboss/tools/maven/apt/MavenJdtAptPlugin.java → ...s/tools/maven/apt/internal/MavenJdtAptPlugin.java
@@ -9,7 +9,7 @@
* Karl M. Davis (Knowledge Computing Corp.) - initial API and implementation
*******************************************************************************/
-package org.jboss.tools.maven.apt;
+package org.jboss.tools.maven.apt.internal;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
@@ -22,7 +22,7 @@
/**
- * This is the {@link BundleActivator} for the Eclipse plugin providing the {@link AptProjectConfigurator}
+ * This is the {@link BundleActivator} for the Eclipse plugin providing the {@link AbstractAptProjectConfigurator}
* {@link AbstractProjectConfigurator} implementation.
*/
public class MavenJdtAptPlugin implements BundleActivator {
View
64 ...ss.tools.maven.apt.core/src/org/jboss/tools/maven/apt/internal/MavenProcessorAptProjectConfigurator.java
@@ -0,0 +1,64 @@
+/*************************************************************************************
+ * Copyright (c) 2008-2012 Red Hat, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - Initial implementation.
+ ************************************************************************************/
+package org.jboss.tools.maven.apt.internal;
+
+import java.io.File;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.maven.execution.MavenSession;
+import org.apache.maven.plugin.MojoExecution;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.m2e.core.project.IMavenProjectFacade;
+
+public class MavenProcessorAptProjectConfigurator extends AbstractAptProjectConfigurator {
+
+ static final String PROCESSOR_PLUGIN_GROUP_ID = "org.bsc.maven";
+
+ static final String PROCESSOR_PLUGIN_ARTIFACT_ID = "maven-processor-plugin";
+
+ static final String GOAL_PROCESS = "process";
+
+ @Override
+ protected AnnotationProcessorConfiguration getAnnotationProcessorConfiguration(
+ IMavenProjectFacade mavenProjectFacade, MavenSession mavenSession, IProgressMonitor monitor) throws CoreException {
+
+ for(MojoExecution mojoExecution : mavenProjectFacade.getMojoExecutions(PROCESSOR_PLUGIN_GROUP_ID,
+ PROCESSOR_PLUGIN_ARTIFACT_ID,
+ monitor,
+ GOAL_PROCESS)) {
+
+ File generatedOutputDirectory = maven.getMojoParameterValue(mavenSession, mojoExecution, "defaultOutputDirectory", File.class);
+
+ PluginDependencyResolver dependencyResolver = new PluginDependencyResolver();
+ List<File> dependencies = dependencyResolver.getResolvedPluginDependencies(mavenSession,
+ mavenProjectFacade.getMavenProject(),
+ mojoExecution.getPlugin(),
+ monitor);
+
+ Map<String, String> options = maven.getMojoParameterValue(mavenSession, mojoExecution, "optionMap", Map.class);
+
+
+ DefaultAnnotationProcessorConfiguration configuration = new DefaultAnnotationProcessorConfiguration();
+ configuration.setOutputDirectory(generatedOutputDirectory);
+ configuration.setAnnotationProcessingEnabled(true);
+ configuration.setDependencies(dependencies);
+ configuration.setAnnotationProcessorOptions(options);
+ return configuration;
+ }
+
+
+ return null;
+ }
+
+
+}
View
106 org.jboss.tools.maven.apt.core/src/org/jboss/tools/maven/apt/internal/PluginDependencyResolver.java
@@ -0,0 +1,106 @@
+/*************************************************************************************
+ * Copyright (c) 2008-2012 Red Hat, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - Initial implementation.
+ ************************************************************************************/
+package org.jboss.tools.maven.apt.internal;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.maven.RepositoryUtils;
+import org.apache.maven.execution.MavenSession;
+import org.apache.maven.model.Plugin;
+import org.apache.maven.project.MavenProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.m2e.core.MavenPlugin;
+import org.eclipse.m2e.core.embedder.IMaven;
+import org.eclipse.m2e.core.embedder.MavenModelManager;
+import org.eclipse.m2e.core.internal.MavenPluginActivator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.sonatype.aether.RepositorySystem;
+import org.sonatype.aether.artifact.ArtifactTypeRegistry;
+import org.sonatype.aether.collection.CollectRequest;
+import org.sonatype.aether.collection.DependencyGraphTransformer;
+import org.sonatype.aether.graph.DependencyFilter;
+import org.sonatype.aether.resolution.ArtifactResult;
+import org.sonatype.aether.resolution.DependencyRequest;
+import org.sonatype.aether.resolution.DependencyResolutionException;
+import org.sonatype.aether.util.DefaultRepositorySystemSession;
+import org.sonatype.aether.util.artifact.JavaScopes;
+import org.sonatype.aether.util.filter.DependencyFilterUtils;
+import org.sonatype.aether.util.graph.transformer.ChainedDependencyGraphTransformer;
+import org.sonatype.aether.util.graph.transformer.JavaEffectiveScopeCalculator;
+import org.sonatype.aether.util.graph.transformer.NearestVersionConflictResolver;
+
+public class PluginDependencyResolver {
+
+ private static final Logger log = LoggerFactory.getLogger(PluginDependencyResolver.class);
+
+ /**
+ * Looks up a plugin's dependencies (including the transitive ones) and return them as a list of {@link File}
+ * <br/>
+ * Some of {@link MavenModelManager#readDependencyTree(org.eclipse.m2e.core.project.IMavenProjectFacade, MavenProject, String, IProgressMonitor)}'s logic has been copied and reused in this implementation.
+ */
+ public synchronized List<File> getResolvedPluginDependencies(MavenSession mavenSession, MavenProject mavenProject, Plugin plugin, IProgressMonitor monitor) throws CoreException {
+
+ monitor.setTaskName("Resolve plugin dependency");
+
+ IMaven maven = MavenPlugin.getMaven();
+
+ DefaultRepositorySystemSession session = new DefaultRepositorySystemSession(mavenSession.getRepositorySession());
+
+ DependencyGraphTransformer transformer = new ChainedDependencyGraphTransformer(new JavaEffectiveScopeCalculator(),
+ new NearestVersionConflictResolver());
+ session.setDependencyGraphTransformer(transformer);
+
+ ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
+ List<File> files = new ArrayList<File>();
+ try {
+ Thread.currentThread().setContextClassLoader(maven.getProjectRealm(mavenProject));
+
+ ArtifactTypeRegistry stereotypes = session.getArtifactTypeRegistry();
+
+ CollectRequest request = new CollectRequest();
+ request.setRequestContext("plugin"); //$NON-NLS-1$
+ request.setRepositories(mavenProject.getRemoteProjectRepositories());
+
+ for(org.apache.maven.model.Dependency dependency : plugin.getDependencies()) {
+ request.addDependency(RepositoryUtils.toDependency(dependency, stereotypes));
+ }
+
+ DependencyFilter classpathFilter = DependencyFilterUtils.classpathFilter( JavaScopes.COMPILE, JavaScopes.RUNTIME);
+
+ DependencyRequest dependencyRequest = new DependencyRequest( request, classpathFilter );
+ try {
+ RepositorySystem system = MavenPluginActivator.getDefault().getRepositorySystem();
+ List<ArtifactResult> artifactResults = system.resolveDependencies( session, dependencyRequest ).getArtifactResults();
+
+ for ( ArtifactResult artifactResult : artifactResults )
+ {
+ files.add(artifactResult.getArtifact().getFile() );
+ }
+ } catch(DependencyResolutionException e) {
+ String msg = "Unable to collect dependencies for plugin";
+ log.error(msg, e);
+ throw new CoreException(new Status(IStatus.ERROR, MavenJdtAptPlugin.PLUGIN_ID, -1, msg, e));
+ }
+
+ } finally {
+ Thread.currentThread().setContextClassLoader(oldClassLoader);
+ }
+ return files;
+ }
+
+
+}
View
74 org.jboss.tools.maven.apt.tests/.settings/org.eclipse.jdt.core.prefs
@@ -1,7 +1,81 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
+org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
+org.eclipse.jdt.core.compiler.problem.deadCode=warning
+org.eclipse.jdt.core.compiler.problem.deprecation=warning
+org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
+org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
+org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
+org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
+org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled
+org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
+org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
+org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
+org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
+org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled
+org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
+org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore
+org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
+org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
+org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
+org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
+org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
+org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
+org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
+org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
+org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
+org.eclipse.jdt.core.compiler.problem.nullReference=warning
+org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
+org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
+org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore
+org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore
+org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
+org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
+org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore
+org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore
+org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
+org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
+org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
+org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
+org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
+org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
+org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
+org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
+org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled
+org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
+org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
+org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
+org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore
+org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
+org.eclipse.jdt.core.compiler.problem.unusedImport=error
+org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
+org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
+org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore
+org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
+org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
+org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
+org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
org.eclipse.jdt.core.compiler.source=1.6
View
56 org.jboss.tools.maven.apt.tests/.settings/org.eclipse.jdt.ui.prefs
@@ -0,0 +1,56 @@
+eclipse.preferences.version=1
+editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
+org.eclipse.jdt.ui.javadoc=true
+org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?><templates><template autoinsert\="true" context\="gettercomment_context" deleted\="false" description\="Comment for getter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.gettercomment" name\="gettercomment">/**\r\n * @return the ${bare_field_name}\r\n */</template><template autoinsert\="true" context\="settercomment_context" deleted\="false" description\="Comment for setter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.settercomment" name\="settercomment">/**\r\n * @param ${param} the ${bare_field_name} to set\r\n */</template><template autoinsert\="true" context\="constructorcomment_context" deleted\="false" description\="Comment for created constructors" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name\="constructorcomment">/**\r\n * ${tags}\r\n */</template><template autoinsert\="false" context\="filecomment_context" deleted\="false" description\="Comment for created Java files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.filecomment" name\="filecomment">/*************************************************************************************\r\n * Copyright (c) ${year} Red Hat, Inc. and others.\r\n * All rights reserved. This program and the accompanying materials \r\n * are made available under the terms of the Eclipse Public License v1.0\r\n * which accompanies this distribution, and is available at\r\n * http\://www.eclipse.org/legal/epl-v10.html\r\n * \r\n * Contributors\:\r\n * Red Hat, Inc. - Initial implementation.\r\n ************************************************************************************/\r\n</template><template autoinsert\="true" context\="typecomment_context" deleted\="false" description\="Comment for created types" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.typecomment" name\="typecomment">/**\r\n * @author ${user}\r\n *\r\n * ${tags}\r\n */</template><template autoinsert\="true" context\="fieldcomment_context" deleted\="false" description\="Comment for fields" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" name\="fieldcomment">/**\r\n * \r\n */</template><template autoinsert\="true" context\="methodcomment_context" deleted\="false" description\="Comment for non-overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodcomment" name\="methodcomment">/**\r\n * ${tags}\r\n */</template><template autoinsert\="true" context\="overridecomment_context" deleted\="false" description\="Comment for overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.overridecomment" name\="overridecomment">/* (non-Javadoc)\r\n * ${see_to_overridden}\r\n */</template><template autoinsert\="true" context\="delegatecomment_context" deleted\="false" description\="Comment for delegate methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.delegatecomment" name\="delegatecomment">/**\r\n * ${tags}\r\n * ${see_to_target}\r\n */</template><template autoinsert\="true" context\="newtype_context" deleted\="false" description\="Newly created files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.newtype" name\="newtype">${filecomment}\r\n${package_declaration}\r\n\r\n${typecomment}\r\n${type_declaration}</template><template autoinsert\="true" context\="classbody_context" deleted\="false" description\="Code in new class type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.classbody" name\="classbody">\r\n</template><template autoinsert\="true" context\="interfacebody_context" deleted\="false" description\="Code in new interface type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.interfacebody" name\="interfacebody">\r\n</template><template autoinsert\="true" context\="enumbody_context" deleted\="false" description\="Code in new enum type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.enumbody" name\="enumbody">\r\n</template><template autoinsert\="true" context\="annotationbody_context" deleted\="false" description\="Code in new annotation type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.annotationbody" name\="annotationbody">\r\n</template><template autoinsert\="true" context\="catchblock_context" deleted\="false" description\="Code in new catch blocks" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.catchblock" name\="catchblock">// ${todo} Auto-generated catch block\r\n${exception_var}.printStackTrace();</template><template autoinsert\="true" context\="methodbody_context" deleted\="false" description\="Code in created method stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodbody" name\="methodbody">// ${todo} Auto-generated method stub\r\n${body_statement}</template><template autoinsert\="true" context\="constructorbody_context" deleted\="false" description\="Code in created constructor stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorbody" name\="constructorbody">${body_statement}\r\n// ${todo} Auto-generated constructor stub</template><template autoinsert\="true" context\="getterbody_context" deleted\="false" description\="Code in created getters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.getterbody" name\="getterbody">return ${field};</template><template autoinsert\="true" context\="setterbody_context" deleted\="false" description\="Code in created setters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.setterbody" name\="setterbody">${field} \= ${param};</template></templates>
+sp_cleanup.add_default_serial_version_id=true
+sp_cleanup.add_generated_serial_version_id=false
+sp_cleanup.add_missing_annotations=true
+sp_cleanup.add_missing_deprecated_annotations=true
+sp_cleanup.add_missing_methods=false
+sp_cleanup.add_missing_nls_tags=false
+sp_cleanup.add_missing_override_annotations=true
+sp_cleanup.add_missing_override_annotations_interface_methods=true
+sp_cleanup.add_serial_version_id=false
+sp_cleanup.always_use_blocks=true
+sp_cleanup.always_use_parentheses_in_expressions=false
+sp_cleanup.always_use_this_for_non_static_field_access=false
+sp_cleanup.always_use_this_for_non_static_method_access=false
+sp_cleanup.convert_to_enhanced_for_loop=false
+sp_cleanup.correct_indentation=false
+sp_cleanup.format_source_code=false
+sp_cleanup.format_source_code_changes_only=false
+sp_cleanup.make_local_variable_final=false
+sp_cleanup.make_parameters_final=false
+sp_cleanup.make_private_fields_final=true
+sp_cleanup.make_type_abstract_if_missing_method=false
+sp_cleanup.make_variable_declarations_final=true
+sp_cleanup.never_use_blocks=false
+sp_cleanup.never_use_parentheses_in_expressions=true
+sp_cleanup.on_save_use_additional_actions=false
+sp_cleanup.organize_imports=true
+sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
+sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
+sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
+sp_cleanup.qualify_static_member_accesses_with_declaring_class=false
+sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
+sp_cleanup.remove_private_constructors=true
+sp_cleanup.remove_trailing_whitespaces=false
+sp_cleanup.remove_trailing_whitespaces_all=true
+sp_cleanup.remove_trailing_whitespaces_ignore_empty=false
+sp_cleanup.remove_unnecessary_casts=true
+sp_cleanup.remove_unnecessary_nls_tags=false
+sp_cleanup.remove_unused_imports=false
+sp_cleanup.remove_unused_local_variables=false
+sp_cleanup.remove_unused_private_fields=true
+sp_cleanup.remove_unused_private_members=false
+sp_cleanup.remove_unused_private_methods=true
+sp_cleanup.remove_unused_private_types=true
+sp_cleanup.sort_members=false
+sp_cleanup.sort_members_all=false
+sp_cleanup.use_blocks=false
+sp_cleanup.use_blocks_only_for_return_and_throw=false
+sp_cleanup.use_parentheses_in_expressions=false
+sp_cleanup.use_this_for_non_static_field_access=false
+sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
+sp_cleanup.use_this_for_non_static_method_access=false
+sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
View
3  org.jboss.tools.maven.apt.tests/.settings/org.hibernate.eclipse.console.prefs
@@ -0,0 +1,3 @@
+default.configuration=
+eclipse.preferences.version=1
+hibernate3.enabled=false
View
53 org.jboss.tools.maven.apt.tests/projects/eclipselink/pom.xml
@@ -0,0 +1,53 @@
+<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>foo.bar</groupId>
+ <artifactId>eclipselink</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.eclipse.persistence</groupId>
+ <artifactId>javax.persistence</artifactId>
+ <version>2.0.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.persistence</groupId>
+ <artifactId>eclipselink</artifactId>
+ <version>2.0.1</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <inherited>true</inherited>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ <dependencies>
+ <dependency>
+ <groupId>org.eclipse.persistence</groupId>
+ <artifactId>org.eclipse.persistence.jpa.modelgen</artifactId>
+ <version>2.3.2</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ </plugins>
+ </build>
+ <repositories>
+ <repository>
+ <id>eclipse</id>
+ <url>http://maven.eclipse.org/nexus/content/groups/build/</url>
+ </repository>
+ </repositories>
+ <pluginRepositories>
+ <pluginRepository>
+ <id>eclipse</id>
+ <url>http://maven.eclipse.org/nexus/content/groups/build/</url>
+ </pluginRepository>
+ </pluginRepositories>
+</project>
View
28 org.jboss.tools.maven.apt.tests/projects/eclipselink/src/main/java/foo/bar/Dummy.java
@@ -0,0 +1,28 @@
+package foo.bar;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+
+@Entity
+public class Dummy {
+ private long id;
+ @Id
+ public long getId() {
+ return this.id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ private String name;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+}
View
8 org.jboss.tools.maven.apt.tests/projects/eclipselink/src/main/java/foo/bar/DummyStuff.java
@@ -0,0 +1,8 @@
+package foo.bar;
+
+public class DummyStuff {
+
+ public void nonSense() {
+ System.err.println(Dummy_.name);
+ }
+}
View
5 org.jboss.tools.maven.apt.tests/projects/eclipselink/src/main/resources/META-INF/persistence.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
+ <persistence-unit name="jpa">
+ </persistence-unit>
+</persistence>
View
34 org.jboss.tools.maven.apt.tests/projects/p2/pom.xml
@@ -0,0 +1,34 @@
+<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>foo.bar</groupId>
+ <artifactId>p2</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.3.2</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ <generatedSourcesDirectory>target/generated-sources/m2e-apt/</generatedSourcesDirectory>
+ </configuration>
+ <dependencies>
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-jpamodelgen</artifactId>
+ <version>1.1.1.Final</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>org.hibernate.javax.persistence</groupId>
+ <artifactId>hibernate-jpa-2.0-api</artifactId>
+ <version>1.0.0.Final</version>
+ </dependency>
+ </dependencies>
+</project>
View
18 org.jboss.tools.maven.apt.tests/projects/p2/src/main/java/foo/bar/Dummy.java
@@ -0,0 +1,18 @@
+package foo.bar;
+
+import javax.persistence.Entity;
+
+@Entity
+public class Dummy {
+
+ private String name;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+}
View
8 org.jboss.tools.maven.apt.tests/projects/p2/src/main/java/foo/bar/DummyStuff.java
@@ -0,0 +1,8 @@
+package foo.bar;
+
+public class DummyStuff {
+
+ public void nonSense() {
+ System.err.println(Dummy_.name);
+ }
+}
View
51 org.jboss.tools.maven.apt.tests/projects/p3/pom.xml
@@ -0,0 +1,51 @@
+<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>foo.bar</groupId>
+ <artifactId>p3</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.3.2</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ <compilerArgument>-proc:none</compilerArgument>
+ </configuration>
+ </plugin>
+ <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>
+ </executions>
+ <configuration>
+
+ </configuration>
+ <dependencies>
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-jpamodelgen</artifactId>
+ <version>1.1.1.Final</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>org.hibernate.javax.persistence</groupId>
+ <artifactId>hibernate-jpa-2.0-api</artifactId>
+ <version>1.0.0.Final</version>
+ </dependency>
+ </dependencies>
+</project>
View
18 org.jboss.tools.maven.apt.tests/projects/p3/src/main/java/foo/bar/Dummy.java
@@ -0,0 +1,18 @@
+package foo.bar;
+
+import javax.persistence.Entity;
+
+@Entity
+public class Dummy {
+
+ private String name;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+}
View
8 org.jboss.tools.maven.apt.tests/projects/p3/src/main/java/foo/bar/DummyStuff.java
@@ -0,0 +1,8 @@
+package foo.bar;
+
+public class DummyStuff {
+
+ public void nonSense() {
+ System.err.println(Dummy_.name);
+ }
+}
View
34 org.jboss.tools.maven.apt.tests/projects/p4/pom.xml
@@ -0,0 +1,34 @@
+<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>foo.bar</groupId>
+ <artifactId>p4</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.3.2</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ <compilerArgument>-proc:none -AdumbArgument=value</compilerArgument>
+ </configuration>
+ <dependencies>
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-jpamodelgen</artifactId>
+ <version>1.1.1.Final</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>org.hibernate.javax.persistence</groupId>
+ <artifactId>hibernate-jpa-2.0-api</artifactId>
+ <version>1.0.0.Final</version>
+ </dependency>
+ </dependencies>
+</project>
View
18 org.jboss.tools.maven.apt.tests/projects/p4/src/main/java/foo/bar/Dummy.java
@@ -0,0 +1,18 @@
+package foo.bar;
+
+import javax.persistence.Entity;
+
+@Entity
+public class Dummy {
+
+ private String name;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+}
View
8 org.jboss.tools.maven.apt.tests/projects/p4/src/main/java/foo/bar/DummyStuff.java
@@ -0,0 +1,8 @@
+package foo.bar;
+
+public class DummyStuff {
+
+ public void nonSense() {
+ System.err.println(Dummy_.name);
+ }
+}
View
35 org.jboss.tools.maven.apt.tests/projects/p5/pom.xml
@@ -0,0 +1,35 @@
+<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>foo.bar</groupId>
+ <artifactId>p5</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.3.2</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ <compilerArgument>-AdumbArgument=value</compilerArgument>
+ <proc>none</proc>
+ </configuration>
+ <dependencies>
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-jpamodelgen</artifactId>
+ <version>1.1.1.Final</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>org.hibernate.javax.persistence</groupId>
+ <artifactId>hibernate-jpa-2.0-api</artifactId>
+ <version>1.0.0.Final</version>
+ </dependency>
+ </dependencies>
+</project>
View
18 org.jboss.tools.maven.apt.tests/projects/p5/src/main/java/foo/bar/Dummy.java
@@ -0,0 +1,18 @@
+package foo.bar;
+
+import javax.persistence.Entity;
+
+@Entity
+public class Dummy {
+
+ private String name;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+}
View
8 org.jboss.tools.maven.apt.tests/projects/p5/src/main/java/foo/bar/DummyStuff.java
@@ -0,0 +1,8 @@
+package foo.bar;
+
+public class DummyStuff {
+
+ public void nonSense() {
+ System.err.println(Dummy_.name);
+ }
+}
View
106 org.jboss.tools.maven.apt.tests/src/org/jboss/tools/maven/apt/tests/M2eAptProjectconfiguratorTest.java
@@ -6,11 +6,12 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * JBoss by Red Hat - Initial implementation.
+ * Red Hat, Inc - Initial implementation.
************************************************************************************/
package org.jboss.tools.maven.apt.tests;
import java.util.Iterator;
+import java.util.Map;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
@@ -27,9 +28,26 @@
@SuppressWarnings("restriction")
public class M2eAptProjectconfiguratorTest extends AbstractMavenProjectTestCase {
- public void testJdtAptSupport() throws Exception {
+ public void testMavenCompilerPluginSupport() throws Exception {
+ defaultTest("p1", "target/generated-sources/annotations");
+ }
+
+ public void testMavenCompilerPluginDependencies() throws Exception {
+ defaultTest("p2", "target/generated-sources/m2e-apt");
+ }
- IProject p = importProject("projects/p1/pom.xml");
+ public void testMavenProcessorPluginSupport() throws Exception {
+ defaultTest("p3", "target/generated-sources/apt");
+ }
+
+ public void testDisabledAnnotationProcessing() throws Exception {
+ testDisabledAnnotationProcessing("p4");//using <compilerArgument>-proc:none</compilerArgument>
+ testDisabledAnnotationProcessing("p5");//using <proc>none</proc>
+ }
+
+ public void testRuntimePluginDependency() throws Exception {
+
+ IProject p = importProject("projects/eclipselink/pom.xml");
waitForJobsToComplete();
// Import doesn't build, so we trigger it manually
@@ -39,8 +57,84 @@ public void testJdtAptSupport() throws Exception {
IJavaProject javaProject = JavaCore.create(p);
assertNotNull(javaProject);
+ assertTrue("Annotation processing is disabled for "+p, AptConfig.isEnabled(javaProject));
+ String expectedOutputFolder = "target/generated-sources/annotations";
+ IFolder annotationsFolder = p.getFolder(expectedOutputFolder );
+ assertTrue(annotationsFolder + " was not generated", annotationsFolder.exists());
+
+ FactoryPath factoryPath = (FactoryPath) AptConfig.getFactoryPath(javaProject);
+ String modelGen = "org.eclipse.persistence.jpa.modelgen.processor-2.3.2.jar";
+ boolean foundRuntimeDependency = false;
+ for (FactoryContainer container : factoryPath.getEnabledContainers().keySet()) {
+ if (("M2_REPO/org/eclipse/persistence/org.eclipse.persistence.jpa.modelgen.processor/2.3.2/" + modelGen).equals(container.getId())){
+ foundRuntimeDependency = true;
+ break;
+ }
+ }
+ assertTrue(modelGen + " was not found", foundRuntimeDependency);
+
+ /*
+ There's an ugly bug in Tycho which makes
+ JavaModelManager.getJavaModelManager().createAnnotationProcessorManager() return null
+ as a consequence, no annotation processors are run during Tycho builds
+ See http://dev.eclipse.org/mhonarc/lists/tycho-user/msg02344.html
+
+ For the time being, only APT configuration can be tested, not APT build outcomes
+ */
+ if (JavaModelManager.getJavaModelManager().createAnnotationProcessorManager() == null) {
+ return;
+ }
+
+ IFile generatedFile = p.getFile(expectedOutputFolder + "/foo/bar/Dummy_.java");
+ if (!generatedFile.exists()) {
+ //APT was triggered during project configuration, i.e. before META-INF/persistence.xml was copied to
+ //target/classes by the maven-resource-plugin build participant. eclipselink modelgen could not find it
+ // and skipped model generation. Pretty annoying and I dunno how to fix that ... yet.
+
+ //Let's check a nudge to Dummy.java fixes this.
+ IFile dummy = p.getFile("src/main/java/foo/bar/Dummy.java");
+ dummy.touch(monitor);
+ p.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, monitor);
+ waitForJobsToComplete();
+ }
+
+ assertTrue(generatedFile + " was not generated", generatedFile.exists());
+ assertNoErrors(p);
+ }
+
+ private void testDisabledAnnotationProcessing(String projectName) throws Exception {
+ IProject p = importProject("projects/"+projectName+"/pom.xml");
+ waitForJobsToComplete();
+ IJavaProject javaProject = JavaCore.create(p);
+ assertNotNull(javaProject);
+ assertFalse(AptConfig.isEnabled(javaProject));
+ }
+
+ private void testAnnotationProcessorArguments(String projectName, Map<String, String> expectedOptions) throws Exception {
+ IProject p = importProject("projects/"+projectName+"/pom.xml");
+ waitForJobsToComplete();
+ IJavaProject javaProject = JavaCore.create(p);
+ assertNotNull(javaProject);
assertTrue(AptConfig.isEnabled(javaProject));
- IFolder annotationsFolder = p.getFolder("target/generated-sources/annotations/");
+ Map<String, String> options = AptConfig.getProcessorOptions(javaProject);
+ for (Map.Entry<String, String> option : expectedOptions.entrySet()) {
+ assertEquals(option.getValue(), options.get(option.getKey()));
+ }
+ }
+
+ private void defaultTest(String projectName, String expectedOutputFolder) throws Exception {
+
+ IProject p = importProject("projects/"+projectName+"/pom.xml");
+ waitForJobsToComplete();
+
+ p.build(IncrementalProjectBuilder.FULL_BUILD, monitor);
+ waitForJobsToComplete();
+
+ IJavaProject javaProject = JavaCore.create(p);
+ assertNotNull(javaProject);
+
+ assertTrue("Annotation processing is disabled for "+p, AptConfig.isEnabled(javaProject));
+ IFolder annotationsFolder = p.getFolder(expectedOutputFolder);
assertTrue(annotationsFolder + " was not generated", annotationsFolder.exists());
FactoryPath factoryPath = (FactoryPath) AptConfig.getFactoryPath(javaProject);
@@ -65,9 +159,11 @@ public void testJdtAptSupport() throws Exception {
return;
}
- IFile generatedFile = p.getFile("target/generated-sources/annotations/foo/bar/Dummy_.java");
+ IFile generatedFile = p.getFile(expectedOutputFolder + "/foo/bar/Dummy_.java");
assertTrue(generatedFile + " was not generated", generatedFile.exists());
assertNoErrors(p);
}
+
+
}
Please sign in to comment.
Something went wrong with that request. Please try again.