Adding extra source path to your Maven build

Although it might be considered as bad practice I ran into a case in which I wanted to add an extra source path to my Maven build besides the default ‘/src/main/java’ path. In my situation I generate Java code with JAX-WS to create a web service based on an existing WSDL (I will show this in a separate post). Normally you generate this code in the ‘target’ folder so it is automatically build up in the compile step and cleaned up in the clean step. But like I said I wanted to be able to use the generated code in my Netbeans project as ‘source’ code but I did not want mix it with my own code.
So I added an extra source path as described in this post like this:

<!-- Plugin to add source path to build cycle -->

And to keep it clean I also added the generated source path to the ‘clean plugin’ like this:

<!-- Plugin to add delete path to build cycle -->

This configuration makes it possible to use the extra source path as a normal Maven path and it shows up nicely in my Netbeans project:

About Pascal Alma

Pascal is a senior software developer and architect. Pascal has been designing and building applications since 2001. He is particularly interested in Open Source toolstack (Mule, Spring Framework, JBoss) and technologies like Web Services, SOA and Cloud technologies. Lately he is having great fun by building iOS apps with Swift. Specialties: JEE AWS XML/XSD/XSLT Web Services/SOA Mule ESB/ WSO2 ESB Maven Cloud Technology Swift/ iOS
This entry was posted in Maven and tagged . Bookmark the permalink.