一个 pom 中的多工件 ID [英] multi artifact id in one pom

查看:65
本文介绍了一个 pom 中的多工件 ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一个maven项目(jar),但是现在需要把它分成两个神器

There is a maven project(jar), but now it needs to be spilt into two artifacts

我想要两个像下面这样的 Maven 神器

I want to have two maven artifact like following

<groupId>xxx</groupId>
<artifactId>xxx-client</groupId>

<groupId>xxx</groupId>
<artifactId>xxx-impl</groupId>

但所有代码都在一个项目中.

But all the code is in one single project.

我的问题是,如何在不过多更改项目的情况下打包所需的两个工件.

My question would be, How can I package the tow required artifacts without changing the project too much.

然后,

mvn 包部署

将自动将这两个工件部署到存储库中其实我不想把这些项目拆分成两个maven项目.

will auto deploy these two artifacts into repository Actually I don't want to split these project into two maven project.

推荐答案

我不确定在一个 POM 中是否有可能有两个 标签,因为它是唯一的.您可以做的是,您可以有两个 pom 文件,例如 pom.xmlpom_impl.xml,现在是

I am not sure if there is a possibility of having two <artifactId> tags in one POM, since it is unique. What you may do is, you can have two pom files, say, pom.xml, and pom_impl.xml, now

  • 部署客户端做,mvn package deploy
  • 部署impl做,mvn -f pom_impl.xml package deploy

从来没有尝试过.

澄清:这个问题似乎模棱两可,好像您有一个项目,但您想生成相同代码库的两个工件(客户端和实现).再次阅读时,我觉得您有两个项目(两个不同的代码库),但您只是想统一它,使其表现为同一项目的两个模块.我的回答假设第一种情况.

Clarification: The question seem ambiguous, seems like you have one project but you wanted to generated two artifacts (client, and impl) of the same code-base. On reading it again, I feel like you have two projects (two different code base) but you just wanted to unify it so that it behaves as two modules of the same project. My answer assumes the first case.

这篇关于一个 pom 中的多工件 ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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