{"id":31497,"date":"2022-10-10T15:24:31","date_gmt":"2022-10-10T15:24:31","guid":{"rendered":"https:\/\/www.devopsschool.com\/blog\/?p=31497"},"modified":"2023-04-22T10:47:52","modified_gmt":"2023-04-22T10:47:52","slug":"maven-tutorials-archetypes-archetypeartifactid","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/maven-tutorials-archetypes-archetypeartifactid\/","title":{"rendered":"Maven Tutorials: Archetypes &#038; archetypeArtifactId"},"content":{"rendered":"\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">What is Archetype?<\/h2>\n\n\n\n<p>In short, Archetype is a Maven project templating toolkit. An archetype is defined as&nbsp;<em>an original pattern or model from which all other things of the same kind are made<\/em>. The name fits as we are trying to provide a system that provides a consistent means of generating Maven projects. Archetype will help authors create Maven project templates for users, and provides users with the means to generate parameterized versions of those project templates.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"388\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/10\/image-1024x388.png\" alt=\"\" class=\"wp-image-31498\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/10\/image-1024x388.png 1024w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/10\/image-300x114.png 300w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/10\/image-768x291.png 768w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/10\/image.png 1033w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Using archetypes provides a great way to enable developers quickly in a way consistent with best practices employed by your project or organization. Within the Maven project, we use archetypes to try and get our users up and running as quickly as possible by providing a sample project that demonstrates many of the features of Maven, while introducing new users to the best practices employed by Maven. In a matter of seconds, a new user can have a working Maven project to use as a jumping board for investigating more of the features in Maven. We have also tried to make the Archetype mechanism additive, and by that we mean allowing portions of a project to be captured in an archetype so that pieces or aspects of a project can be added to existing projects. A good example of this is the Maven site archetype. If, for example, you have used the quick start archetype to generate a working project, you can then quickly create a site for that project by using the site archetype within that existing project. You can do anything like this with archetypes.<\/p>\n\n\n\n<p>You may want to standardize J2EE development within your organization, so you may want to provide archetypes for EJBs, or WARs, or for your web services. Once these archetypes are created and deployed in your organization&#8217;s repository, they are available for use by all developers within your organization.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"547\" height=\"333\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/10\/image-1.png\" alt=\"\" class=\"wp-image-31499\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/10\/image-1.png 547w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2022\/10\/image-1-300x183.png 300w\" sizes=\"auto, (max-width: 547px) 100vw, 547px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Using an Archetype<\/h2>\n\n\n\n<p>To create a new project based on an Archetype, you need to call&nbsp;<code>mvn archetype:generate<\/code>&nbsp;goal, like the following:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ mvn archetype:generate\nOR\nExample\n$ mvn archetype:generate -DgroupId=com.companyname.softwar -DartifactId=financialService -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Provided Archetypes<\/h2>\n\n\n\n<p>Maven provides several Archetype artifacts:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><th>Archetype ArtifactIds<\/th><th>Description<\/th><\/tr><tr><td>maven-archetype-archetype<\/td><td>An archetype to generate a sample archetype project.<\/td><\/tr><tr><td>maven-archetype-j2ee-simple<\/td><td>An archetype to generate a simplifed sample J2EE application.<\/td><\/tr><tr><td>maven-archetype-mojo<\/td><td>An archetype to generate a sample a sample Maven plugin.<\/td><\/tr><tr><td>maven-archetype-plugin<\/td><td>An archetype to generate a sample Maven plugin.<\/td><\/tr><tr><td>maven-archetype-plugin-site<\/td><td>An archetype to generate a sample Maven plugin site.<\/td><\/tr><tr><td>maven-archetype-portlet<\/td><td>An archetype to generate a sample JSR-268 Portlet.<\/td><\/tr><tr><td>maven-archetype-quickstart<\/td><td>An archetype to generate a sample Maven project.<\/td><\/tr><tr><td>maven-archetype-simple<\/td><td>An archetype to generate a simple Maven project.<\/td><\/tr><tr><td>maven-archetype-site<\/td><td>An archetype to generate a sample Maven site which demonstrates some of the supported document types like APT, XDoc, and FML and demonstrates how to i18n your site.<\/td><\/tr><tr><td>maven-archetype-site-simple<\/td><td>An archetype to generate a sample Maven site.<\/td><\/tr><tr><td>maven-archetype-webapp<\/td><td>An archetype to generate a sample Maven Webapp project.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>What is Archetype? In short, Archetype is a Maven project templating toolkit. An archetype is defined as&nbsp;an original pattern or model from which all other things of the same kind&#8230; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[2],"tags":[],"class_list":["post-31497","post","type-post","status-publish","format-standard","hentry","category-uncategorised"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/31497","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=31497"}],"version-history":[{"count":2,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/31497\/revisions"}],"predecessor-version":[{"id":33523,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/31497\/revisions\/33523"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=31497"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=31497"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=31497"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}