我尝试使用Maven Central Repo中不存在的原型创建Maven项目,但存在于另一个远程存储库中。在> maven-archetype-plugin版本2.4 我可以使用-darchetyperepository param以指定另一个仓库,其中Maven应该在其中寻找我的原型。在新版本(3.0)中,此参数不起作用。(证明:http://maven.apache.org/archetype/maven-archetype-plugin/generate-mojo.html#archetypecatalog)
所以我需要使用旧版本的插件并编写长命令,例如
$ mvn org.apache.maven.plugins:maven-archetype-plugin:2.4:generate -DarchetypeGroupId=some.id -DarchetypeArtifactId=some.another.id -DarchetypeVersion=some.version -DarchetypeRepository=repo.url
如何使用maven-arketype-plugin:3.0?
执行相同的命令我尝试使用archetypeCatalog=repo.url
,但是它不起作用,我只能使用它设置本地或远程存储库。
谢谢。
插件开发人员的答案:
Allowing to set a URL via commandline is considered to be a security leak, so specifying the repository (id: archetype) in the settings.xml is the right way.
来自Maven原型插件参考:
从MAVEN原型插件开始,原型分辨率已更改:不再有可能通过命令行(使用-darchetyperepository = repo.url)指定存储库,而是已经定义为Maven已定义的存储库是
这意味着您必须在设置中添加一个存储库条目,请参见上面的链接。
您可以在设置中指定存储库为[ArchetypeArtifactId] -repo。这被定义为常见问题解答之一。
如果您没有身份验证,请不要在stayings.xml中指定它。
或
我刚刚运行以下命令
mvn org.apache.maven.plugins:maven-archetype-plugin:3.0.0:generate
-DarchetypeGroupId=org.grails
-DarchetypeArtifactId=grails-maven-archetype
-DarchetypeVersion=1.0
-DarchetypeCatalog=http://snapshots.repository.codehaus.org
这给了我警告,
[警告]在任何目录中都找不到原型。回到中央存储库(http://repo.maven.apache.org/maven2)。
[警告]使用-darchetyperepository =如果原型的存储库在其他地方。