What are the URLs of all the Maven Archetype catalogs that you know about?

后端 未结 5 1428
你的背包
你的背包 2020-12-22 16:25

Maven Archetypes are the \"templates\" by which you can quickly generate a running example of a given framework or project type. I am trying to compile a list of all the Ma

5条回答
  •  情话喂你
    2020-12-22 17:04

    To be honest, I don't really see the point of building a list of all catalogs. It looks more "natural" to me to pick a project first and then add the catalog if required. This is why there is IMO more value in a list of archetypes. You'll need their name anyway, even if you have all catalogs in a list.

    Anyway, here are some candidates;

    • Grails has archetypes in http://snapshots.repository.codehaus.org/.
    • Atlassian has archetypes in https://maven.atlassian.com/repository/public/

    Edit: after Matthew clarification on archetype's catalogs.

    I misunderstood some concepts and my answer isn't clear and correct.

    The point of catalogs is exactly to not have to know the names of archetypes in advance. They are made to publish archetypes and allow mvn archetype:generate to list archetypes. So it makes sense to add "external" catalogs (understand not in the internal) to get a wider list of known archetypes when using mvn archetype:generate.

    For archetypes without a catalog, users have to type an horrible command that must be documented somewhere (because it requires knowledge of the artifact).

    Regarding my propositions:

    • Atlassian's archetypes are in the internal catalog. Not a good proposition.

    • Grails archetypes aren't in the internal catalog or in a published archetype-catalog.xml. Not a good proposition.

    • ServiceMix has catalogs here http://servicemix.apache.org/tooling/ (based on a http://servicemix.apache.org/tooling//archetype-catalog.xml pattern). Valid proposition.


    One fun thing I learned while digging this. The maven guys provides a nice tool that helps people developing archetypes to create a catalog XML: the archetype:crawl goal basically crawls a local Maven repository searching for Archetypes and generates/updates a archetype-catalog.xml file in ~/.m2/repository by default. Projects, people just have to run periodically something like:

    mvn archetype:crawl -Dcatalog=/var/www/html/archetype-catalog.xml

    Grails doesn't provide a catalog. To create a project, we have to run:

    mvn org.apache.maven.plugins:maven-archetype-plugin:2.0-alpha-4:generate -DarchetypeGroupId=org.grails \
    -DarchetypeArtifactId=grails-maven-archetype \
    -DarchetypeVersion=1.0 \
    -DarchetypeRepository=http://snapshots.repository.codehaus.org \
    -DgroupId=example -DartifactId=my-app
    

    But once we did this, we have the archetype in our local repository. So if we type:

    mvn archetype:crawl -Dcatalog=/home//.m2/archetype-catalog.xml
    

    The archetype get listed in ~/.m2/archetype-catalog.xml and we can now use the mvn archetype:generate for Grails too (see option 5):

    mvn archetype:generate
    ...
    [INFO] No archetype defined. Using maven-archetype-quickstart (org.apache.maven.archetypes:maven-archetype-quickstart:1.0)
    Choose archetype:
    1: local -> maven-archetype-archetype (archetype)
    2: local -> maven-archetype-j2ee-simple (j2ee)
    3: local -> maven-archetype-quickstart (quickstart)
    4: local -> maven-archetype-webapp (webapp)
    5: local -> grails-maven-archetype (maven-project)
    6: internal -> appfuse-basic-jsf (AppFuse archetype for creating a web application with Hibernate, Spring and JSF)
    ...
    

    This is of course a (hugly) workaround and it might have side effects (you won't see new versions of archetypes). Actually, I don't think the archetype:crawl goal is intended for this use. I would like all projects them to publish their archetypes.

提交回复
热议问题