Maven 2 Archetypes get a much needed improvement
Yesterday, a new version of the Maven Archetype Plugin was released. This release incorporates many of the improvements that were developed in a different project - code named "Archetype NG". The two major improvements are 1) you only have to use "mvn archetype:create" now and 2) you can create archetypes from existing projects.
I haven't tried #2, but #1 seems to work pretty well (especially since AppFuse archetypes are the first 9 ).
powers:~ mraible$ mvn archetype:create [INFO] Scanning for projects... [INFO] Searching repository for plugin with prefix: 'archetype'. [INFO] ------------------------------------------------------------------------ [INFO] Building Maven Default Project [INFO] task-segment: [archetype:create] (aggregator-style) [INFO] ------------------------------------------------------------------------ [INFO] Preparing archetype:create [INFO] No goals needed for project - skipping [INFO] Setting property: classpath.resource.loader.class => 'org.codehaus.plexus.velocity.ContextClassLoaderResourceLoader'. [INFO] Setting property: velocimacro.messages.on => 'false'. [INFO] Setting property: resource.loader => 'classpath'. [INFO] Setting property: resource.manager.logwhenfound => 'false'. [INFO] [archetype:create] Choose archetype: 1: internal -> appfuse-basic-jsf (AppFuse archetype for creating a web application with Hibernate, Spring and JSF) 2: internal -> appfuse-basic-spring (AppFuse archetype for creating a web application with Hibernate, Spring and Spring MVC) 3: internal -> appfuse-basic-struts (AppFuse archetype for creating a web application with Hibernate, Spring and Struts 2) 4: internal -> appfuse-basic-tapestry (AppFuse archetype for creating a web application with Hibernate, Spring and Tapestry 4) 5: internal -> appfuse-core (AppFuse archetype for creating a jar application with Hibernate and Spring and XFire) 6: internal -> appfuse-modular-jsf (AppFuse archetype for creating a modular application with Hibernate, Spring and JSF) 7: internal -> appfuse-modular-spring (AppFuse archetype for creating a modular application with Hibernate, Spring and Spring MVC) 8: internal -> appfuse-modular-struts (AppFuse archetype for creating a modular application with Hibernate, Spring and Struts 2) 9: internal -> appfuse-modular-tapestry (AppFuse archetype for creating a modular application with Hibernate, Spring and Tapestry 4) 10: internal -> maven-archetype-j2ee-simple (A simple J2EE Java application) 11: internal -> maven-archetype-marmalade-mojo (A Maven plugin development project using marmalade) 12: internal -> maven-archetype-mojo (A Maven Java plugin development project) 13: internal -> maven-archetype-portlet (A simple portlet application) 14: internal -> maven-archetype-profiles () 15: internal -> maven-archetype-quickstart () 16: internal -> maven-archetype-site-simple (A simple site generation project) 17: internal -> maven-archetype-site (A more complex site project) 18: internal -> maven-archetype-webapp (A simple Java web application) 19: internal -> struts2-archetype-starter (A starter Struts 2 application with Sitemesh, DWR, and Spring) 20: internal -> struts2-archetype-blank (A minimal Struts 2 application) 21: internal -> struts2-archetype-portlet (A minimal Struts 2 application that can be deployed as a portlet) 22: internal -> struts2-archetype-dbportlet (A starter Struts 2 portlet that demonstrates a simple CRUD interface with db backing) 23: internal -> struts2-archetype-plugin (A Struts 2 plugin) 24: internal -> shale-archetype-blank (A blank Shale web application with JSF) 25: internal -> maven-adf-archetype (Archetype to ease the burden of creating a new application based with ADF) 26: internal -> data-app (A new Databinder application with sources and resources.) 27: internal -> jini-service-archetype (Archetype for Jini service project creation) 28: internal -> softeu-archetype-seam (JSF+Facelets+Seam Archetype) 29: internal -> softeu-archetype-seam-simple (JSF+Facelets+Seam (no persistence) Archetype) 30: internal -> softeu-archetype-jsf (JSF+Facelets Archetype) 31: internal -> jpa-maven-archetype (JPA application) 32: internal -> spring-osgi-bundle-archetype (Spring-OSGi archetype) 33: internal -> confluence-plugin-archetype (Atlassian Confluence plugin archetype) 34: internal -> maven-archetype-har (Hibernate Archive) 35: internal -> maven-archetype-sar (JBoss Service Archive) 36: internal -> wicket-archetype-quickstart (A simple Apache Wicket project) Choose a number: (1/2/3/4/5/6/7/8/9/10/11/12/13/14/15/16/17/18/19/20/21/22/23/24/25/26/27/28/29/30/31/32/33/34/35/36): 3 Downloading: http://static.appfuse.org/releases/org/appfuse/archetypes/appfuse-basic-struts/2.0/appfuse-basic-struts-2.0.jar 71K downloaded Define value for groupId: : com.company Define value for artifactId: : myapp Define value for version: : 1.0-SNAPSHOT Define value for package: : war Confirm properties configuration: groupId: com.company artifactId: myapp version: 1.0-SNAPSHOT package: war Y: : Y [INFO] ---------------------------------------------------------------------------- [INFO] Using following parameters for creating OldArchetype: appfuse-basic-struts:2.0 [INFO] ---------------------------------------------------------------------------- [INFO] Parameter: groupId, Value: com.company [INFO] Parameter: packageName, Value: war [INFO] Parameter: basedir, Value: /Users/mraible [INFO] Parameter: package, Value: war [INFO] Parameter: version, Value: 1.0-SNAPSHOT [INFO] Parameter: artifactId, Value: myapp ...{suppressed hundreds of Velocity warnings}... [INFO] OldArchetype created in dir: /Users/mraible/myapp [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESSFUL [INFO] ------------------------------------------------------------------------ [INFO] Total time: 43 seconds [INFO] Finished at: Sat Feb 09 14:39:11 MST 2008 [INFO] Final Memory: 7M/511M [INFO] ------------------------------------------------------------------------ powers:~ mraible$
There's some typos (duplicate colons) in the prompts, but this is an alpha release, so I don't see any problem with that. I wonder where this list of archetypes is stored? We need to change the default version of AppFuse from 2.0 to 2.0.1.
I asked to Raphaƫl on the vote thread and he replied:
The main list is the internal catalog.
It is also possible to define a specific catalog by -DarchetypeCatalog=http://repo.company.com/maven2 the catalog is an xml file located at the root and called archetype-catalog.xml.
The process that populates a catalog during deploy. is not currently working.
Cheers,
Arnaud
Posted by Arnaud HERITIER on February 09, 2008 at 10:50 PM MST #
Posted by Jason van Zyl on February 10, 2008 at 03:28 AM MST #
Posted by David Bernard on February 10, 2008 at 09:09 PM MST #
This is a great improvement for the command-line users.
Friends of IDE integration have had the ability to choose from the same list for some time now. Q for eclipse has a pluggable architecture for declaring archetype sources (quite similar to the archetype catalogs in this new version of the plug-in).
I think its great to see this usability improvements going down into the maven "core" components.
Posted by Abel Muiño on February 11, 2008 at 01:51 PM MST #
Posted by Brent Atkinson on February 12, 2008 at 03:06 AM MST #
I've entered an issue in JIRA for this: ARCHEENGINE-127
Posted by Matt Raible on February 12, 2008 at 04:11 AM MST #
- using the old plugin
- create a local archetype-catalog.xml (under ~/.m2/archetype-catalog.xml) (file://... and http://... don't work)
seePosted by David Bernard on February 12, 2008 at 07:53 AM MST #
Posted by Brent Atkinson on February 12, 2008 at 02:34 PM MST #
Hi there
having trouble with the new archetype mechanism, like not being able to use the archetype-archetype plugin (its not in the list).
Is it possible to make it backwardly compatable with the old way?
Also i have been trying to find out about how to use it in the new way, but it seems that none of the documentation has been updated, and all the links on http://maven.apache.org/plugins/maven-archetype-plugin/ are dead.
Is this known about?
Cheers
Mark
Posted by Mark Miller on February 18, 2008 at 01:44 PM MST #
Mark,
I am not 100% certain what exactly you are trying to accomplish from your post, but after the archetype plugin was updated with this new functionality it essentially broke the old archetype usage. For example, you can no longer invoke the plugin as you used to be able to. Also, the new version of the plugin, which uses an xml catalog file to generate the new menu functionality doesn't support custom catalogs fully. I haven't verified it yet, but it was previously stated that you can create an archetype-catalog.xml file listing your desired archetypes and install it in the root of your ~/.m2 directory. This should enable you to run the new plugin and have your archetypes available in the menu.
It seems that the new archetype plugin was published as a release a little prematurely as it doesn't fully support the old way of doing things, and also doesn't fully support an alternative way of doing things. Also, as you mentioned the archetype plugin documentation doesn't reflect the new plugin's usage. To revert to the old way, you can run the older version of the plugin. You need to specify the full coordinates when running the plugin. So rather than 'mvn archetype:create', you would replace that with 'mvn org.apache.maven.plugins:maven-archetype-plugin:1.0-alpha-7:create'. I hope this helps.
Posted by Brent Atkinson on February 18, 2008 at 06:25 PM MST #
Mark,
I just tried using a local catalog with the new plugin using my original archetypes and wasn't able to get it working. One thing I noticed was that the new plugin's internal catalog (located in org.apache.maven.archetype:archetype-common:2.0-alpha-1), comments out an archetype definition. Apparently, the archetype is commented out because it doesn't have an archetype.xml file. Comparing my archetypes with the ones pointed to by the internal catalog, there is a difference in how the archetypes are packaged. The ones in the internal catalog are packaged with the archetype.xml file in META-INF/, not META-INF/maven/. I wonder if this has any significance. Also, I don't quite understand why the repository elements in the catalog files are not specified as repository id's and instead use the URLs directly. Will this mean that the new plugin doesn't work with repositories that require authentication (like my own)? Anyway, it wasn't immediately obvious how to use the local catalog and it didn't use it by default. Once you have an archetype-catalog.xml file in your ~/.m2/ directory, use 'mvn archetype:create -DarchetypeCatalog=local' to have it use your local catalog.
Posted by Brent Atkinson on February 18, 2008 at 08:28 PM MST #
This is a totally stupid way to release something like this into the main stream. Just when some of us have built our own processes for using Maven 2 archetype functionality, along comes something like this...
How about reverting the maven-archetype-plugin to it's original form and releasing a new, supposedly-improved archetype plugin with a separate name like "maven-appfuse-archetype-plugin"?
When are people that do this kind of thing in the maven2 world going to grow up?
Posted by Bradley Smith on March 17, 2008 at 08:05 PM MDT #
Posted by Zdeno Tubel on March 20, 2008 at 11:47 AM MDT #
Posted by Sébastien PRAT on April 10, 2008 at 01:22 PM MDT #
The problem seems to be solved in the 2.0-alpha-3 release (not yet available).
Posted by Sébastien PRAT on April 10, 2008 at 01:56 PM MDT #