Java 您知道的所有 Maven Archetype 目录的 URL 是什么?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/635543/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What are the URLs of all the Maven Archetype catalogs that you know about?
提问by Matthew McCullough
Maven Archetypesare 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 Maven archetype catalogs currently active on the net.
Maven 原型是“模板”,您可以通过它快速生成给定框架或项目类型的运行示例。我正在尝试编译当前在网络上活动的所有 Maven 原型目录的列表。
From the Maven documentation about catalog files:
Knowledge about archetypes are stored in catalogs.
The catalogs are xml files.
The Archetype Plugin comes bundled with an internal catalog. This one is used by default.
The Archetype Plugin can use catalogs from local filesystem and from HTTP connections.
有关原型的知识存储在目录中。
目录是 xml 文件。
Archetype 插件与内部目录捆绑在一起。这是默认使用的。
原型插件可以使用来自本地文件系统和 HTTP 连接的目录。
So far, I've gathered this list of repositories that do publish catalogs, but would love to see if anyone knows of more:
到目前为止,我已经收集了这个发布目录的存储库列表,但很想看看是否有人知道更多:
mvn archetype:generate
-DarchetypeCatalog=local
-DarchetypeCatalog=remote
-DarchetypeCatalog=http://repo.fusesource.com/maven2
-DarchetypeCatalog=http://cocoon.apache.org
-DarchetypeCatalog=http://download.java.net/maven/2
-DarchetypeCatalog=http://myfaces.apache.org
-DarchetypeCatalog=http://tapestry.formos.com/maven-repository
-DarchetypeCatalog=http://scala-tools.org
-DarchetypeCatalog=http://www.terracotta.org/download/reflector/maven2/
Links to same: 1) FuseSource2) Cocoon3) Java.net4) MyFaces5) Tapestry6) Scala Catalog7) Terracotta Catalog
相同的链接:1) FuseSource2) Cocoon3) Java.net4) MyFaces5) Tapestry6) Scala Catalog7) Terracotta Catalog
You'll notice that if the repository actually publishes an archetype catalog (all of the above do), you'll get a UI prompt of all the choices found in that archetype-catalog.xml
. For example:
您会注意到,如果存储库实际发布了原型目录(上述所有内容),您将收到一个 UI 提示,其中包含在该目录中找到的所有选项archetype-catalog.xml
。例如:
mvn archetype:generate -DarchetypeCatalog=http://scala-tools.org
[INFO] No archetype defined. Using maven-archetype-quickstart (org.apache.maven.archetypes:maven-archetype-quickstart:1.0)
Choose archetype:
1: http://scala-tools.org -> scala-archetype-simple (A simple scala project)
2: http://scala-tools.org -> lift-archetype-blank (A blank/empty liftweb project)
3: http://scala-tools.org -> lift-archetype-basic (A basic liftweb project (with DB, css, ...))
Choose a number: (1/2/3):
If you want to view the Scala catalog file directly for example, you can browse to http://scala-tools.org/archetype-catalog.xml
例如,如果你想直接查看 Scala 目录文件,你可以浏览到 http://scala-tools.org/archetype-catalog.xml
But if the repository doesn't provide an archetype-catalog.xml, then just as PascalT says, you'll need to know the name in advance (much less convenient) and pass it in command line arguments.
但是,如果存储库不提供 archetype-catalog.xml,那么正如 PascalT 所说,您需要提前知道名称(不太方便)并在命令行参数中传递它。
采纳答案by Pascal Thivent
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.
老实说,我真的不明白构建所有目录列表的意义。首先选择一个项目,然后根据需要添加目录对我来说看起来更“自然”。这就是为什么 IMO 在原型列表中具有更多价值的原因。无论如何,您都需要他们的名字,即使列表中包含所有目录。
Anyway, here are some candidates;
无论如何,这里有一些候选人;
- Grails has archetypes in http://snapshots.repository.codehaus.org/.
Atlassian has archetypes in https://maven.atlassian.com/repository/public/
- Grails 在http://snapshots.repository.codehaus.org/ 中有原型。
Atlassian 在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
.
目录的要点正是不必事先知道原型的名称。它们用于发布原型并允许mvn archetype:generate
列出原型。因此,在使用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.ServiceMixhas catalogs here http://servicemix.apache.org/tooling/(based on a
http://servicemix.apache.org/tooling/<version>/archetype-catalog.xml
pattern). Valid proposition.
Atlassian 的原型在内部目录中。不是一个好提议。
Grails 原型不在内部目录或已发布的
archetype-catalog.xml
. 不是一个好提议。ServiceMix在http://servicemix.apache.org/tooling/有目录(基于一种
http://servicemix.apache.org/tooling/<version>/archetype-catalog.xml
模式)。有效的提议。
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:
我在挖掘这个时学到了一件有趣的事情。maven 人员提供了一个很好的工具,可以帮助开发原型的人创建目录 XML:archetype:crawl
目标基本上是抓取本地 Maven 存储库搜索原型并archetype-catalog.xml
在~/.m2/repository
默认情况下生成/更新文件。项目,人们只需要定期运行,例如:
mvn archetype:crawl -Dcatalog=/var/www/html/archetype-catalog.xml
Grails doesn't provide a catalog. To create a project, we have to run:
Grails 不提供目录。要创建一个项目,我们必须运行:
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/<me>/.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):
原型被列出,~/.m2/archetype-catalog.xml
我们现在也可以使用mvn archetype:generate
for Grails(参见选项 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.
这当然是一个(巨大的)解决方法,它可能有副作用(您不会看到新版本的原型)。实际上,我不认为 archetype:crawl 目标旨在用于此用途。我希望他们所有的项目都发布他们的原型。
回答by Alex Miller
Terracotta has one but I don't know the url off-hand...will post back. Also, I have used archetypes in the past from AppFuse(http://static.appfuse.org/releases/) and Webtidealthough I don't know where to find their archetype catalogs.
兵马俑有一个,但我不知道现成的网址……会回帖。此外,我过去使用过AppFuse( http://static.appfuse.org/releases/) 和Webtide 的原型,尽管我不知道在哪里可以找到它们的原型目录。
The Terracotta repository and catalog are here: http://www.terracotta.org/download/reflector/maven2/
Terracotta 存储库和目录在这里:http: //www.terracotta.org/download/reflector/maven2/
Perhaps this is useful: http://docs.codehaus.org/display/MAVENUSER/Archetypes+List
也许这很有用:http: //docs.codehaus.org/display/MAVENUSER/Archetypes+List
回答by Brian Fox
The nexus index that is produced by Nexus and consumed by M2eclipse knows about all the archetypes and lets you choose them when you create a new maven project from the ide.
由 Nexus 生成并由 M2eclipse 使用的 nexus 索引了解所有原型,并让您在从 ide 创建新的 maven 项目时选择它们。
回答by Matthew McCullough
There's yet another resource at Codehaus for a very robust list of archetypes out there on the 'net. http://docs.codehaus.org/display/MAVENUSER/Archetypes+List
Codehaus 上还有另一个资源,可以在网上找到一个非常强大的原型列表。 http://docs.codehaus.org/display/MAVENUSER/Archetypes+List
回答by jeevatkm
For Maven Archetype list refer this link http://www.myjeeva.com/2012/06/exclusive-maven-archetype-list/(you will find around 607 Archetypes).
对于 Maven 原型列表,请参阅此链接http://www.myjeeva.com/2012/06/exclusive-maven-archetype-list/(您将找到大约 607 个原型)。
While using mvn archetype:generate
command at question of Choose a number or apply filter (format: [groupId:]artifactId, case sensitive contains): 197:
在使用mvn archetype:generate
命令时Choose a number or apply filter (format: [groupId:]artifactId, case sensitive contains): 197:
provide archetype numberfrom above link.
从上面的链接提供原型编号。
Note: default value is 197
注意:默认值为 197
- 197 -> org.apache.maven.archetypes:maven-archetype-quickstart (An archetype which contains a sample Maven project.)
- 197 -> org.apache.maven.archetypes:maven-archetype-quickstart(包含示例 Maven 项目的原型。)