Add generated sources to source path with maven

I frequently use maven plugins to generate sources from artifacts like wsdls or xsds as part of a maven project. When working those projects in eclipse, the sources are usually not immediately visible. Fortunately the maven build helper plugin offers a solution.

In order to add generated sources to the sources pathes of a project the add-sources goal from the manve helper plugin can be used. When the sources are generated they are immediately picked up by eclipse and compilation errors are avoided.

In order to add the functionality to a maven project add the following lines to the pom:

In the example above the source produces by the Maven cxf-codegen-plugin are add to the sources of the project.

The build helper maven plugin has some other useful goals. For example the reserve network port goal can be used to reserve a network port and sets its value as a property. This is useful for finding ports not currently in use and assigning them to some components for usage (e.g. the jetty maven plugin)

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">