安装Maven原型 [英] Install Maven Archetype

查看:105
本文介绍了安装Maven原型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经从一个现有项目中创建了一个Maven原型.我什至将原型安装在本地存储库中,并用它来创建一个新项目.一切都变得完美(令人难以置信).

I have created a Maven archetype from an existing project. I have even installed the archetype in my local repository and used it to create a new project. Everything went perfect (incredible).

问题是我想分发此原型,以便任何人都可以将其安装在本地计算机上,甚至可以部署到Maven存储库以使用它.我当时正在考虑分发生成的工件JAR,而不是我项目的源代码,并让人们安装它,但是似乎它不能作为原型安装,或者至少在我尝试使用它时无法识别.

The thing is that I want to distribute this archetype so anybody can install it in his local machine or even deploy to a maven repo in order to use it. I was thinking about distributing the generated the artifact JAR, not the source of my project, and let people install it but it seems like it doesn't install as an archetype or at least it isn't recognized when I try to use it.

我使用mvn install:install-file目标来做到这一点.

I used mvn install:install-file goal to do this.

这是最好的方法吗?可以分发此JAR文件以将其作为原型安装吗? JAR文件缺少某些内容吗?

Is this the best way to do this? Is it posible to distribute this JAR file in order to install it as an archetype? Is the JAR file missing something?

谢谢.

推荐答案

此处的一些说明:

// installs the project to your local repository (jar, archetype, etc.)
mvn install
// AND updates archetype catalog
mvn install archetype:update-local-catalog
// calls plugin archetype goal crawl
mvn archetype:crawl

Crawl遍历Maven仓库和CREATES目录.

Crawl goes through Maven repo and CREATES catalog.

如果希望交互使用原型,则需要调用完整坐标或将其列在目录中.

If you wish to use archetype interactively, you either need to call if with full coordinates or have it listed in the catalog.

// use local catalog
mvn archetype:generate -DarchetypeCatalog=local
// full coordinate set, my example
mvn archetype:generate -DarchetypeGroupId=pl.lafk -DarchetypeArtifactId=simple-testng-quickstart -DarchetypeVersion=1.0 -DgroupId=pl.lafk -DartifactId=sample-app

调用mvn deploy时,您将执行所有安装操作,并将软件包推送到远程存储库(如果已配置).

When you call mvn deploy you do all that install does plus push the package to remote repository - if you have it configured.

我使用的链接是Maven插件站点: https://maven.apache .org/archetype/archetype-packaging/index.html

Link I used was Maven site for plugin: https://maven.apache.org/archetype/archetype-packaging/index.html

另外:mvn archetype:help

这篇关于安装Maven原型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆