Search code examples
mavenarchitecturemaven-archetypearchetypes

Maven Archetype creation via Eclipse


I am willing to create an archetype which will be useful to create a lot of projects sharing the same architecture. I followed the maven guide and read some bloggers guides but even with these informations I am struggling.

I have some constraints for my projects :

  • All the project code is in a package which must be something like com.ei.app.project (app and project are vars I would like to set during the project generation)
  • I have dependencies I would like to be present in my POM when the project is generated
  • I have some scripts file with data (paths, app name...) and I would like to set them according to the project parameters, and if it is possible add additional parameters.
  • We don't use the official maven repo but set up another online repo. We have a strict security policy an whenever we have to add a lib into the repo it takes a lot of time for verifications.

How can I achieve this ? I tried several solutions but encountered a lot of errors. If you have a complete step-by-step guide in english or french that would be fantastic, but I would also like to understand how it works.

Many thanks for your help


Solution

  • Let me answer parts of your question.

    From an example project, you can create an archetype by using archetype:create-from-project (https://maven.apache.org/archetype/maven-archetype-plugin/create-from-project-mojo.html).

    You can supply a property file that will be used to replace actual values (like 1.0.0-SNAPSHOT) with references (like $version). All filtered files will be treated as velocity templates so that you can use $-type replacement.

    Your repository restriction may be problem because you probably need dozens of artifacts to make the archetype plugin run.