How to set up Eclipse PDE/Build with Indigo? - eclipse

In my project I use PDE/Build to build my RCP application on a remote server in Hudson.
The current version is a package based on Eclipse Galileo and it works fine both as a builder application and as a target platform.
Now I want to upgrade it to Indigo and I need some help here.
First, the old method of unpacking number of zips to form a target platform does not work.
(I used Platform Runtime Binary, Delta pack, PDE Runtime Binary and JDT Runtime Binary - a set that I came up with that can be used both as a builder and as a target platform).
Ok, there is new target definition for that.
How would I configure it so that it corresponds to my Galileo set up?
(And of course I wouldn't mind if it was simpler/cleaner).
I tried the following:
Added Eclipse RCP, Eclipse RCP Plug-in Developer Resources (for source), PDE/API Tools Environment from download.eclipse.org/eclipse/updates/3.7
Added Eclipse Java Development from download.eclipse.org/releases/indigo
Downloaded delta pack manually from download.eclipse.org/eclipse/downloads/drops/R-3.7-201106131736/download.php?dropFile=eclipse-3.7-delta-pack.zip, unpacked it and added the resulting directory (as Directory) to target definition. By the way, is there an update site for Indigo delta pack?
Added a couple of third party plug-ins from Eclipse Orbit p2 site: download.eclipse.org/tools/orbit/downloads/drops/R20110523182458/repository
I then used the definition's 'Set as Target Platform' - and my project builds fine in my workspace - that's nice!
Then I exported the platform to .
Now, if I try to execute my build like this:
java -jar <target-platform>\plugins\org.eclipse.equinox.launcher_1.2.0.v20110502.jar -application org.eclipse.ant.core.antRunner -buildfile <target-platform>/plugins/org.eclipse.pde.build_3.7.0.v20110512-1320/scripts/productBuild/productBuild.xml -Dbuilder=<pdebuild-folder>
or even
java -jar <target-platform>\plugins\org.eclipse.equinox.launcher_1.2.0.v20110502.jar
I get the following error:
An error has occurred. See the log file \configuration\1316517334675.log
The log contains the following:
!SESSION 2011-09-20 15:15:34.269
eclipse.buildId=unknown
java.version=1.7.0
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_US
!ENTRY org.eclipse.osgi 4 0 2011-09-20 15:15:35.175
!MESSAGE Application error
!STACK 1
java.lang.IllegalStateException: Unable to acquire application service. Ensure that the org.eclipse.core.runtime bundle is resolved and started (see config.ini).
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:74)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577)
at org.eclipse.equinox.launcher.Main.run(Main.java:1410)
at org.eclipse.equinox.launcher.Main.main(Main.java:1386)

Ended up with Maven based build against "Eclipse for RCP and RAP Developers" plus delta pack plus SWTBot.
Both were deployed to my Maven repository and are unpacked during the build (if required). Therefore, I no longer care about the size of the target platform.
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.4</version>
<executions>
<!-- Deploy target platform if required -->
<execution>
<id>unpack-target-platform</id>
<phase>initialize</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<markersDirectory>${target.platform.dir}</markersDirectory>
<artifactItems>
<artifactItem>
<groupId>org.eclipse</groupId>
<artifactId>rcp-target-platform</artifactId>
<version>3.7.2-win32-x86_64</version>
<type>zip</type>
<outputDirectory>${target.platform.dir.sdk}</outputDirectory>
</artifactItem>
<artifactItem>
<groupId>org.eclipse</groupId>
<artifactId>rcp-target-platform-delta-pack</artifactId>
<version>3.7.2</version>
<type>zip</type>
<outputDirectory>${target.platform.dir.deltapack}</outputDirectory>
</artifactItem>
<artifactItem>
<groupId>org.eclipse</groupId>
<artifactId>swtbot.eclipse</artifactId>
<version>2.0.5.20111003_1754-3676ac8-dev-e36</version>
<type>zip</type>
<outputDirectory>${target.platform.dir.swtbot}</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<properties>
<!-- Build system properties -->
<target.platform.dir>/rcp-target-platform-3.7.2</target.platform.dir>
<target.platform.dir.swtbot>${target.platform.dir}/swtbot</target.platform.dir.swtbot>
<target.platform.dir.swtbot.plugins>${target.platform.dir.swtbot}/eclipse/plugins</target.platform.dir.swtbot.plugins>
<target.platform.dir.sdk>${target.platform.dir}/sdk</target.platform.dir.sdk>
<target.platform.dir.sdk.plugins>${target.platform.dir.sdk}/eclipse/plugins</target.platform.dir.sdk.plugins>
<target.platform.dir.deltapack>${target.platform.dir}/deltapack</target.platform.dir.deltapack>
<target.platform.dir.deltapack.plugins>${target.platform.dir.deltapack}/eclipse/plugins</target.platform.dir.deltapack.plugins>
<pdebuild.launcherVersion>1.2.0.v20110502</pdebuild.launcherVersion>
<pdebuild.plugin.version>3.7.0.v20111116-2009</pdebuild.plugin.version>
<pdebuild.antDelegateBuildfile>${pdebuild.configDirectory}/pdebuild-ant-from-mvn.xml</pdebuild.antDelegateBuildfile>
<pdebuild.configDirectory>${basedir}/pdebuild</pdebuild.configDirectory>
<pdebuild.buildDirectory>${project.build.directory}/${pdebuild.directory}</pdebuild.buildDirectory>
<pdebuild.directory>pde-build</pdebuild.directory>
</properties>
I then call ant build from Maven like this:
<!-- Delegate execution to PDE/Build via ant -->
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<phase>compile</phase>
<configuration>
<target>
<ant antfile="${pdebuild.antDelegateBuildfile}">
<property name="equinoxLauncherPluginVersion" value="${pdebuild.launcherVersion}" />
<property name="pdeBuildPluginVersion" value="${pdebuild.plugin.version}" />
<property name="projectsDirectory" value="${basedir}" />
<property name="baseLocation" value="${target.platform.dir}" />
<property name="buildDirectory" value="${pdebuild.buildDirectory}" />
<property name="builder" value="${pdebuild.configDirectory}" />
<property name="product" value="${gui.product}"/>
<property name="runPackager" value="${pdebuild.runPackager}"/>
</ant>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
I am happy with the set up now.

Related

Exclude Maven Dependency during Eclipse Application Runtime

When I try to run a Java Application on Eclipse, a conflict between two dependencies is causing the application to fail.
I am trying to upgrade my project Java version from OracleJDK 8 to OpenJDK 11. As a result, I also had to also needed to update a GWT dependency from 2.6.0 to 2.8.2, as well as switch from MOJO gwt-maven-plugin to the tboyer version as well. Additionally, the build is done on Maven 4.0.0 on Eclipse IDE 4.9.0.
Snippet of the pom.xml
<properties>
<gwt.version>2.8.2</gwt.version>
...
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt</artifactId>
<version>${gwt.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-dev</artifactId>
<scope>provided</scope>
</dependency>
...
<build>
<plugins>
<plugin>
<groupId>net.ltgt.gwt.maven</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>1.0-rc-10</version>
<executions>
<execution>
<id>compile-common</id>
<goals>
<goal>compile</goal>
<goal>test</goal>
</goals>
<configuration>
<moduleName>XXXXModule</moduleName>
</configuration>
</execution>
<execution>
<id>XXXX</id>
<goals>
<goal>compile</goal>
<goal>test</goal>
</goals>
<configuration>
<moduleName>XXXXModule</moduleName>
</configuration>
</execution>
<execution>
<id>XXXX</id>
<goals>
<goal>compile</goal>
<goal>test</goal>
</goals>
<configuration>
<moduleName>XXXXModule</moduleName>
</configuration>
</execution>
<execution>
<id>XXXX</id>
<goals>
<goal>compile</goal>
<goal>test</goal>
</goals>
<configuration>
<moduleName>XXXXModule</moduleName>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
So when I run the application on Eclipse, I get the following error:
SEVERE: Application encountered an exception during Start.
XXXX.ApplicationException: Failed to reflect on start method.
at XXXX.ApplicationLauncher.startApplication(ApplicationLauncher.java:471)
at XXXX.ApplicationLauncher.doRun(ApplicationLauncher.java:185)
at XXXX.ApplicationLauncher.main(ApplicationLauncher.java:67)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at XXXX.ApplicationLauncher.startApplication(ApplicationLauncher.java:469)
... 2 more
Caused by: java.lang.NoSuchMethodError: org.apache.tomcat.util.ExceptionUtils.preload()V
at org.apache.catalina.startup.Tomcat.<init>(Tomcat.java:181)
....
After investigating, I discovered that two of my dependencies tomcat-embed-core-7.0.91 & apache-jsp-8.0.9.M3 both contain ExceptionUtils with several difference, hence the Exception. Furthermore, the apache-jsp is being pulled by the gwt-dev dependency which is only required during the Maven build to run the gwt-maven-plugin.
gwt-dev:2.8.2
apache-jsp:9.2.14.v20151106
apache-jsp:8.0.9.M3
But for some reason, Eclipse is including gwt-dev and it's dependency as part of the runtime path even though I have the 'provided' scope tag in the pom.xml.
I have tried excluding the apache-jsp dependency, but a compile issue occurs because apparently gwt-dev is still being added which depends on apache-jsp.
Summary
The TBroyer GWT-Maven-Plugin requires the pom file to include gwt-dev as a dependency in order to run correctly during a build.
However, when running the application on Eclipse, a NoSuchMethodException occurs on org.apache.tomcat.util.ExceptionUtils.preload()V
The issue is there are two ExceptionUtil classes with same package from different jars and methods.
One of the jars is apache-jsp which is a dependency of gwt-dev. Gwt-dev and it's dependencies should not be part of the runtime classpath.
Question: Is there a way to ensure the gwt-dev is only used during the Maven build and not part of the Eclipse Java Application runtime classpath?
Yes, you can ensure isolated classpath for client and server sides. You need to apply the multimodule layout. This is also the main difference between the old MOJO gwt maven plugin and the new generation tbroyer gwt maven plugin, the new one support multimodule correctly. Check this archetype as a reference for the multimodule layout. Also, use the packaging:gwt-app to configure the gwt maven plugin executions automatically.
Making it work with eclipse run action (tomcat or gwt) is a bit more difficult. Until you correctly apply the tbroyer gwt maven plugin and the multimodule layout, you will be able to use mvn tomcat7:run and mvn gwt:codeserver in the terminal. Then, the recommended strategy to use it in your IDE is to configure this maven goal and run it using the maven tooling of your IDE. This makes it work exactly the same in all your environments (terminal, CI, eclipse, intellij, etc).

Checkstyle config used by Maven and Eclipse

I am try to use the same Checkstyle configuration file with both Maven and Eclipse. The module SuppressionCommentFilter works as expected in Eclipse, but Maven reports
TreeWalker is not allowed as a parent of SuppressionCommentFilter
If I move it from TreeWalker to Checker the error goes away, but Checkstyle does not process the ignore comments. I am using Checkstyle 8.12 with Eclipse, but have not found a way to use other than 6.18 with Maven. Since this module had been part of Checkstyle since 3.5 I don't see how that could be the problem. Any suggestions what is wrong?
<module name="Checker">
<property name="severity" value="warning" />
<module name="TreeWalker">
<property name="tabWidth" value="4" />
<module name="SuppressionCommentFilter" />
Mark asked what the looks like, so here is that piece of code.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>verify-style</id>
<phase>process-classes</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
The pom and Checkstyle config file are all working correctly other than the
If it is a child of Treewalker I get the error from the Maven plugin, but not from the Eclipse plugin, however I can only get it to work with the Eclipse plugin.
I am using Checkstyle 8.12 with Eclipse, but have not found a way to use other than 6.18 with Maven
You must override the dependency in maven to bring in newer versions of Checkstyle. By default, the maven plugin will only use 6.18 but it can be overridden for newer versions.
See https://maven.apache.org/plugins/maven-checkstyle-plugin/examples/upgrading-checkstyle.html
It appears that you have defined checkstyle as dependency and not as plugin.
Using the guide at Apache Maven Checkstyle I was able to use checkstyle for my personal projects. This is a snippet from the plugins section of my pom.xml:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>verify-style</id>
<phase>process-classes</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
<configuration>
<logViolationsToConsole>true</logViolationsToConsole>
<configLocation>yourcheckstylexmlhere.xml</configLocation>
</configuration>
</plugin>
Maskime on GitHub says:
Dear reader if you googled your way here, like I did, the solution is
to move the <module name="SuppressionCommentFilter"/> under the
TreeWalker module.
I have tried this fix with the version you're using aswell and it does not give the error anymore.

Make Eclipse Respect Maven-Dependency-Plugin

How can I have Eclipse recognise my use of the maven-dependency-plugin and execute it before deploying resources to Tomcat via WTP?
In a previous question I configured Maven to copy some artifacts into a war application, so I could serve them to web clients. The approach of copying them to target/${project.artifactId}-${project.version} works when packaging via the Maven command line. Sadly there's no such luck when using Eclipse's Tomcat integration.
Maven plugin configuration:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.8</version>
<executions>
<execution>
<id>copy</id>
<phase>compile</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<type>jar</type>
<overWrite>false</overWrite>
<destFileName>optional-new-name.jar</destFileName>
</artifactItem>
</artifactItems>
<outputDirectory>${project.build.directory}/${project.artifactId}-${project.version}/</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>true</overWriteSnapshots>
</configuration>
</execution>
</executions>
This answer assumes you're using Eclipse Java EE Kepler SR1 (or more recent), which comes with the Maven integration plugins (m2e and m2e-wtp).
m2e-wtp, the Maven Integration for WTP plugin ignores maven CLI builds and configures WTP to publish resources from known locations.
So you need to do 2 things :
configure the dependency plugin to copy jars to a known m2e-wtp location during eclipse builds
tell m2e to actually run the dependency plugin during project configuration updates.
First, define a new maven property, in your properties section :
<jars.directory>${project.build.directory}/${project.artifactId}-${project.version}/</jars.directory>
In your maven-dependency-plugin configuration, use :
<outputDirectory>${jars.directory}</outputDirectory>
Now that should give you identical build results with Maven CLI. Then you need to use a specific m2e profile, that'll be automatically enabled when run in Eclipse and ignored in all other situations :
<profiles>
<profile>
<id>m2e</id>
<!-- This profile is only activated when building in Eclipse with m2e -->
<activation>
<property>
<name>m2e.version</name>
</property>
</activation>
<properties>
<jars.directory>${project.build.directory}/m2e-wtp/web-resources/</jars.directory>
</properties>
</profile>
</profiles>
Finally, we need to let m2e know it's ok to run maven-dependency-plugin:copy during project configuration. Add the following snippet to your pluginManagement section :
<pluginManagement>
<plugins>
<!--This plugin's configuration is used to store Eclipse m2e settings
only. It has no influence on the Maven build itself. -->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<versionRange>[2.8,)</versionRange>
<goals>
<goal>copy</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute>
<runOnConfiguration>true</runOnConfiguration>
<runOnIncremental>false</runOnIncremental>
</execute>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
Now, make sure m2e knows about all these configuration changes : Hit Alt+F5 to bring up the Update Maven Configuration dialog, and click ok. Once the build completes, you should see your jar under Deployed Resources> web-resources, in the Project Explorer view.
From now on, deployments to Tomcat should contain optional-new-name.jar at the root of your webapp.

M2E and having maven generated source folders as eclipse source folders

I have a maven project in eclipse and have maven goals that run annotation processors to generate code. The output folder for this code is target/generated-sources/apt.
In order for Eclipse to see this generated code I need to add target/generated-sources/apt as a source folder to the Eclipse project.
However, this causes there to be an error of type "Maven Configuration Problem" saying
Project configuration is not up-to-date with pom.xml. Run project
configuration update
I think I understand why this is the case as Eclipse has a different set of source folders to Maven's set. But I need this different set, as I need Eclipse to be able to see the generated source folders...
When doing a pure Maven built, these source folders will be included in the build, by Maven.
BTW, I have upgraded to the official Eclipse release of the Maven Eclipse plugin, m2e 1.0 - what used to be m2eclipse. I'd like to see if I can find a work around/solution to this with the m2e plugin before I have to go back to the old m2eclipse version.
You need to attach the source directory with the build-helper-plugin.
Like so:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${project.build.directory}/generated-sources/java/</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
You will also need to:
Install the "Apt M2E Connector" from the Eclipse Marketplace.
To do so click the error in the Overview tab of your pom.xml and select "Discover".
Ensure there are no plugin execution filters for the build-helper-maven-plugin (see https://www.eclipse.org/m2e/documentation/m2e-execution-not-covered.html)
Right-click the Error message:
Project configuration is not up-to-date with pom.xml Run project
configuration update
in the Problems View and select Quick Fix and click Finish to select the default Update project configuration. This fixes it.
After switching to new versions of m2e/maven/apt,... i had builderrors because of the duplicated files, caused by the added buildpath by the buildhelper, so i needed to remove the "apt-generated"-Folders from the buildhelper.
To fix the Problem in Eclipse, not adding the "apt-generated"-folder via Update Maven Configuration in M2E, i've written a M2E Plugin to fix this problem. It adds the outputDirectories configured in the maven-apt-plugin to the buildpath of the Project.
https://apt-m2e.googlecode.com
In m2e 1.0 the handling of Maven plugins has changed. You might be lacking a specific m2e extension for your code generating plugin. Here is all the documentation I managed to find.
This bug report may also be relevant.
https://bugs.eclipse.org/bugs/show_bug.cgi?id=350081
request on CXF JIRA (see 1) to add lifecycle mappings in the cxf-codegen-plugin itself. This would require m2e 1.1 but I believe it is better approach than having connectors built outside of cxf project, assuming that lifecycle mapping API would change less frequently than cxf-codegen-plugin and cxf.
You can also use the buildhelper m2e connector available in the discovery catalog. I'm using Eclipse 3.7
Eclipse Java EE IDE for Web Developers.
Version: Juno Service Release 1
mvn archetype:generate \
-DarchetypeGroupId=org.codehaus.mojo \
-DarchetypeArtifactId=gwt-maven-plugin \
-DarchetypeVersion=2.5.0
mvn clean install
work perfectly.
But in eclipse I have the same error on Asinc class.
Just press F5 on project. Fix this problem.
This was what I found that worked good using spring 3.1.1 which does have the 3.0.6 version as well in it. Once I got the plugins setup and put into the correct area of the pom and included the argline and endorseddirs to have the java sources put out into the target/generated-sources/cxf folder then maven generated the sources ok.
....
<properties>...
<dependencyManagement>
<dependencies>.....
</dependencyManagement>
<dependencies>
<dependency>....
</dependencies>
<!-- *************************** Build process ************************************* -->
<build>
<finalName>eSurety</finalName>
<plugins>
<!-- Force Java 6 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.4</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<!-- Deployent on AS from console
<plugin>
<groupId>org.jboss.as.plugins</groupId>
<artifactId>jboss-as-maven-plugin</artifactId>
<version>${version.jboss.as.maven.plugin}</version>
</plugin>
-->
<!-- wildbill added tomcat plugin -->
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.0</version>
</plugin>
<!-- Surefire plugin before 2.9 version is buggy. No need to declare here,
it's being referenced below w/ the version
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12</version>
</plugin>
-->
<!-- developer added these -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<compilerArguments>
<endorseddirs>target/generated-sources/cxf</endorseddirs>
</compilerArguments>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12</version>
<configuration>
<forkMode>once</forkMode>
<argLine>-Djava.endorsed.dirs=target/generated-sources/cxf</argLine>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<compilerArguments>
<endorseddirs>target/generated-sources/cxf</endorseddirs>
</compilerArguments>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<forkMode>once</forkMode>
<argLine>-Djava.endorsed.dirs=target/generated-sources/cxf</argLine>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<configuration>
<artifactItems>
<artifactItem>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.2</version>
</artifactItem>
<artifactItem>
<groupId>javax.xml.ws</groupId>
<artifactId>jaxws-api</artifactId>
<version>2.2</version>
</artifactItem>
</artifactItems>
<outputDirectory>target/generated-sources/cxf</outputDirectory>
</configuration>
</plugin>
</plugins>
</build>
<!-- *********************** Profiles ************************************ -->
<profiles>
<profile>
<!-- When built in OpenShift the 'openshift' profile will be
used when invoking mvn. -->
<!-- Use this profile for any OpenShift specific customization
your app will need. -->
<!-- By default that is to put the resulting archive into the
'deployments' folder. -->
<!-- http://maven.apache.org/guides/mini/guide-building-for-different-environments.html -->
<id>projName</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>2.5.2</version>
<executions>
<execution>
<id>process-sources</id>
<phase>generate-sources</phase>
<configuration>
<fork>once</fork>
<additionalJvmArgs>-Djava.endorsed.dirs=target/generated-sources/cxf</additionalJvmArgs>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.2</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-xjc</artifactId>
<version>2.2</version>
</dependency>
</dependencies>
</plugin>
<!-- Actual war created in default target dir -->
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.2</version>
</plugin>
</plugins>
</build>
</profile>
</profiles>
If your wsdl folder is in ${basedir}/src/main/resources it'll find it automatically
Hope this helps!
~wildbill
In case for some reason you can't use the build helper plugin the easiest way (albeit not as convenient and somewhat tedious) I have found to deal with this is:
Separate the generated source code into its own project or sub module.
You will want to keep this project predominately closed or not imported into Eclipse when you are working on the parent project.
In the parent project that needs the generated code make sure to now depend on the generated source code project via Maven pom dependency.
When you need to update the generated code go to the generated code project and run mvn install. Now refresh the parent project by right clicking and selecting Maven->Update Project...
This generally works well for projects that use a semi static source for code generation such as SOAP WSDLs (Apache CXF) or code generated from a database (jOOQ). For APT and other AspectJ-like-code it doesn't work as well because you are editing the source frequently.
For new visitors to this question -
build helper maven plugins and m2e connectors go hand in hand. Older versions
(before 2.0) of build helpers have moved into an eclipse archive link
build helper versions archived
Pick the correct link from the list and add it as an eclipse update site. It should ask you for a bunch (seriously.. a huge bunch ) of eclipse updates . Please accept and you are good to go.
the configuration to the build helper plugin did work for us.
but be aware, that the destination folder always has to be equal to the configuration of the plugin u're using for the annotation processing itself.
for example the maven-processor-plugin uses the target folder ${project.build.directory}/generated-sources/apt as default. if you wish another destination for your generated source files you can set it by the tag as shown below.
<plugin>
<groupId>org.bsc.maven</groupId>
<artifactId>maven-processor-plugin</artifactId>
<version>2.1.1</version>
<executions>
<execution>
<id>process</id>
<goals>
<goal>process</goal>
</goals>
<phase>process-sources</phase>
<configuration>
<defaultOutputDirectory>apt_generated</defaultOutputDirectory>
<processors>
<processor>com.any.processor.invoker</processor>
</processors>
</configuration>
</execution>
</executions>
</plugin>
Here is the solution
Open Marker View (Window > Show View
Right-click on the Error message
Select Quick Fix
Click Finish

maven-dependency-plugin:unpack fails in Eclipse

I have a library of JavaScript in dependency globalmentor-core.jar, and I use maven-dependency in another project to transfer the JavaScript to a web directory:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.1</version>
<executions>
<execution>
<id>unpack</id>
<phase>process-resources</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>com.globalmentor</groupId>
<artifactId>globalmentor-core</artifactId>
<overWrite>true</overWrite>
<outputDirectory>${project.build.outputDirectory}/com/guiseframework/assets/javascript</outputDirectory>
<includes>**/*.js</includes>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
That works wonderfully on the command-line. In Eclipse using m2eclipse I get:
2/4/11 5:26:53 AM PST: Build errors for guiseframework; org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-dependency-plugin:2.1:unpack (unpack) on project guiseframework: Error unpacking file: R:\java\trunk\globalmentor-core\target\classes to: R:\java\trunk\guiseframework\target\classes\com\guiseframework\assets\javascript
org.codehaus.plexus.archiver.ArchiverException: The source must not be a directory.
The closest thing I can find is http://jira.codehaus.org/browse/MDEP-187, where someone claims they will "provide trivial patch shortly. That was in 2008.
Is there a fix for this, or am I stuck?
I've found a solution/workaround for this problem.
My configuration: Windows XP SP 3, Maven 3, JDK 1.6.0_24, Maven repository under "C:\Documents and Settings\<YOUR_ID>\.m2" folder.
Follow these steps:
Run ‘dir c:\ /X’ and look for the string with ~ in it
08/01/2011 04:53 PM DOCUME~1 Documents and Settings
Open your settings.xml file and under the <settings> tag add a localRepository tag:
<localRepository>C:/DOCUME~1/<YOUR_ID>/.m2/repository<\localRepository>
This should make the plugin work. Apparently, maven-dependency-plugin (up to version 2.3) has problems with paths including spaces in it.
Regards,
Cutberto.