25 junho 2012

Maven Archetype: dynamic name for folders

Maven Archetypes are great! But some things lack documentation. If you are considering building your own archetypes, you may need this sooner or later.

I have a Maven Archetype to create modules for Apache Camel, and all of them will come up at the same ClassPath, but how to avoid conflicts when loading the Spring XML ApplicationContext? Put your XML files in different folders, or give them a different name.

I chose the first solution. If you want to give a folder a dynamic name, just call it __someProperty__ (yes, with double underscores). Think as you wanted to name the folder like ${artifactId}, but your operational system may not like this, so that's why Maven works with __artifactId__.

This is an example of my archetype.xml:

<?xml version="1.0" encoding="UTF-8"?>

And this is the project structure:

This is an archetype to load a Camel Context - with Spring - into JBoss 7.1.1 (as you may noticed from my previous posts) 


If you want to see more about this architecture, please let me know by +1 this post.
Postar um comentário


LinkedIn: www.linkedin.com/in/brunocborges
Twitter: www.twitter.com/brunoborges
Comprei e Não Vou
Rio de Janeiro, RJ Brasil
São Paulo, SP Brasil