I have a multi-module Maven project wherein I just want to release an update module rather than the entire project. This is due to some specific requirements, wherein a release of entire project is uncalled for - only a subset of the library needs the fixes and thus the release.
我有一个多模块Maven项目,我只想发布一个更新模块,而不是整个项目。这是由于某些特定的需求,其中一个发布的整个项目是不需要的——只有一个子集的库需要修复,从而释放。
However, when I run a mvn release:prepare
I get the following error Non-resolvable parent POM
- I have setup the parent POM relationship in the module project with relativePath
tag but that does not seem to work.
然而,当我运行一个mvn发行版:prepare时,我将得到以下错误:不可解析的父POM—我已经在使用相对论路径标记的模块项目中设置了父POM关系,但这似乎并不奏效。
Is it possible to release only a module rather than releasing the entire project.
是否可能只发布一个模块而不发布整个项目。
Thanks in advance.
提前谢谢。
EDIT
编辑
Parent pom
父母pom
<groupId>com.domain</groupId>
<artifactId>project-parent</artifactId>
<version>0.5.1-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>library1</module>
<module>library2</module>
<module>library3</module>
</modules>
The module POMs are as under:
模块POMs如下:
<parent>
<groupId>com.domain></groupId>
<artifactId>project-parent</artifactId>
<version>0.5.1-SNAPSHOT</version>
</parent>
<artifactId>library1</artifactId>
Now I just want to release the new version of library1 and not others
现在我只想发布library1的新版本,而不是其他人
3 个解决方案
#1
8
Try running the maven commands from the parent project/directory with the -pl <project name>
switch.
尝试使用-pl <项目名称> 开关从父项目/目录运行maven命令。
#2
7
mvn -pl .,library1 clean install
The "." will build your parent pom.xml and "library1" is the module name you gave it.
“。”将建立你的父母pom。xml和“library1”是您给它的模块名。
If you don't want to build the parent pom.xml, you can also do:
如果您不想构建父pom。xml,你也可以这样做:
mvn -pl library1 clean install
or in your case, maybe:
或者在你的案例中,也许:
mvn -pl library1 deploy
I used "deploy" because "release" is not a Maven build lifecycle phase.
我使用“deploy”是因为“release”不是Maven构建生命周期阶段。
#3
0
I think maven is trying to tell you that the parent you defined is not released/stable. In your pom the parent version is "0.5.1-SNAPSHOT" which can not/should not work if you want to release a single library module as it would be pointing to something that is not uniquely defined. Is there a stable version you can point to instead? Otherwise maybe the -am switch works in combination with -pl?
我认为maven试图告诉您,您定义的父类没有发布/稳定。在您的pom中,父版本是“0.5.1-SNAPSHOT”,如果您想要释放单个库模块,它就不能/不应该工作,因为它将指向一个没有唯一定义的东西。是否有一个稳定的版本可以指向?否则-am开关可能与-pl结合使用?
Edit
I tried this just now with maven 3.2 and it does ask me for what version the parent should be set/resolved to. It is as I stated previously you need stable version numbers for the release to work
我刚刚在maven 3.2中尝试过这个方法,它确实问我应该设置/解析父版本的版本。正如我前面所说的,您需要稳定的版本号才能使发行版正常工作
mvn release:prepare -pl library1
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building library1 1.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-release-plugin:2.3.2:prepare (default-cli) @ library1 ---
[INFO] Verifying that there are no local modifications...
[INFO] ignoring changes on: **\release.properties, **\pom.xml.next, **\pom.xml.releaseBackup, **\pom.xml.backup, **\pom.xml.branch, **\pom.xml.tag [INFO] Executing: cmd.exe /X /C "git status"
[INFO] Working directory: C:\temp\mavenTest\library1
[INFO] Checking dependencies and plugins for snapshots ...
There are still some remaining snapshot dependencies.
: Do you want to resolve them now? (yes/no) no: : yes
Dependency type to resolve,: specify the selection number ( 0:All 1:Project Dependencies 2:Plugins 3:Reports 4:Extensions ): (0/1/2/3) 1: : 1
Dependency 'testme:parent' is a snapshot (1.1-SNAPSHOT)
: Which release version should it be set to? 1.1: :
#1
8
Try running the maven commands from the parent project/directory with the -pl <project name>
switch.
尝试使用-pl <项目名称> 开关从父项目/目录运行maven命令。
#2
7
mvn -pl .,library1 clean install
The "." will build your parent pom.xml and "library1" is the module name you gave it.
“。”将建立你的父母pom。xml和“library1”是您给它的模块名。
If you don't want to build the parent pom.xml, you can also do:
如果您不想构建父pom。xml,你也可以这样做:
mvn -pl library1 clean install
or in your case, maybe:
或者在你的案例中,也许:
mvn -pl library1 deploy
I used "deploy" because "release" is not a Maven build lifecycle phase.
我使用“deploy”是因为“release”不是Maven构建生命周期阶段。
#3
0
I think maven is trying to tell you that the parent you defined is not released/stable. In your pom the parent version is "0.5.1-SNAPSHOT" which can not/should not work if you want to release a single library module as it would be pointing to something that is not uniquely defined. Is there a stable version you can point to instead? Otherwise maybe the -am switch works in combination with -pl?
我认为maven试图告诉您,您定义的父类没有发布/稳定。在您的pom中,父版本是“0.5.1-SNAPSHOT”,如果您想要释放单个库模块,它就不能/不应该工作,因为它将指向一个没有唯一定义的东西。是否有一个稳定的版本可以指向?否则-am开关可能与-pl结合使用?
Edit
I tried this just now with maven 3.2 and it does ask me for what version the parent should be set/resolved to. It is as I stated previously you need stable version numbers for the release to work
我刚刚在maven 3.2中尝试过这个方法,它确实问我应该设置/解析父版本的版本。正如我前面所说的,您需要稳定的版本号才能使发行版正常工作
mvn release:prepare -pl library1
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building library1 1.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-release-plugin:2.3.2:prepare (default-cli) @ library1 ---
[INFO] Verifying that there are no local modifications...
[INFO] ignoring changes on: **\release.properties, **\pom.xml.next, **\pom.xml.releaseBackup, **\pom.xml.backup, **\pom.xml.branch, **\pom.xml.tag [INFO] Executing: cmd.exe /X /C "git status"
[INFO] Working directory: C:\temp\mavenTest\library1
[INFO] Checking dependencies and plugins for snapshots ...
There are still some remaining snapshot dependencies.
: Do you want to resolve them now? (yes/no) no: : yes
Dependency type to resolve,: specify the selection number ( 0:All 1:Project Dependencies 2:Plugins 3:Reports 4:Extensions ): (0/1/2/3) 1: : 1
Dependency 'testme:parent' is a snapshot (1.1-SNAPSHOT)
: Which release version should it be set to? 1.1: :