如何将Maven嵌入到我的应用程序中? [英] How can I embed Maven into my application?

查看:128
本文介绍了如何将Maven嵌入到我的应用程序中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的Java应用程序中嵌入Maven或实现所有功能的库.

I'd like to embed Maven or the library that does all the magic into my Java application.

关键点:

  • 这是我要执行的两个任务:

  • They are two tasks I want to perform :

1/在本地存储库中发布jar
2/将jar发布到私有企业存储库(Nexus)

1/ Publishing a jar in local repository
2/ Publishing a jar in a private enterprise repository (Nexus)

所有必需的jar都必须位于公共Maven存储库中

All required jars MUST be located in a public Maven repository

jar应当与Maven版本无关(即不特定于Maven 2或3)

The jars SHOULD be Maven version agnostic (ie not specific to Maven 2 or 3)

如果可以的话,请提供您的回复片段.

If you can , please provide a snippet with your response.

推荐答案

以下是嵌入Maven 2库的示例:

Here is an example embedding Maven 2 libraries:

  • CentralRepositoryService.java
  • pom.xml

您可以查找ArtifactInstallerArtifactDeployer而不是查找项目构建器-您将在maven-install-pluginmaven-deploy-plugin中找到所需的代码.

Instead of looking up the project builder, you can look up the ArtifactInstaller and ArtifactDeployer - you'll find the code you want in the maven-install-plugin and the maven-deploy-plugin.

在此示例中,POST的唯一区别是它将生成适当的元数据,校验和和快照转换.

The difference just POSTing in this example is that it will generate the appropriate metadata, checksums and snapshot transformations.

Maven 3库可能更易于嵌入并与Maven 2兼容,但是我没有任何可用的示例.

The Maven 3 libraries may be easier to embed and remain compatible with Maven 2, however I don't have any examples readily available.

这篇关于如何将Maven嵌入到我的应用程序中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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