Open puce77 opened 6 years ago
Something like modelBuilder.build(request).getEffectiveModel()
might help.
Or to keep it simple you could use something like:
if (model.getVersion() == null){
if (model.getParent() != null && StringUtils.isNotBlank(model.getParent().getRelativePath())){
version = model.getParent().getVersion();
}
}
We're just starting with this plugin and are now facing this issue with out multi-module projects. We use two parent poms, one above each project that manages dependencies and one above that one for organization-wide information.
So our structure is like this: project > parent (dependency management) > organization (metadata and plugins)
I've created a PR for this issue: #130
Thanks very much for the property versionsForceUpdate, this allows our Multi-Module POM's to have versions:set for non-parent aggregations.
However, it does not work for me, due to the single quotes around the artifact and group name (being here). if (versionsForceUpdate) { g = "-DgroupId=''"; a = "-DartifactId='*'"; } Is this only in my environment a problem, or are these quotes necessary?
For the record: In the terminal, I see the exact same behaviour, running:
mvn org.codehaus.mojo:versions-maven-plugin:set -DgroupId='' -DartifactId='' -DnewVersion=1.4.35-L-SNAPSHOT -DgenerateBackupPoms=false
does not work, but this here does work:
mvn org.codehaus.mojo:versions-maven-plugin:set -DgroupId= -DartifactId= -DnewVersion=1.4.35-L-SNAPSHOT -DgenerateBackupPoms=false
Could we get a fix on this issue?
@rhirtstzh First of all, please create a separate issue for that, current issue has nothing to do with versionsForceUpdate
.
Which OS are you using?
From the versions-maven-plugin documentation:
On Windows you can omit the single quotes on Linux they are necessary to prevent expansion through the shell.
And in your first example it should be -DgroupId='*' -DartifactId='*'
. Have you tried that?
Sorry about that, I opened a new one #134 .
Aforementioned PR doesn't fix this issue.
We are facing this issue, too; or at least similar behavior. In our project, one module represents a BOM but has no parent relationship to the aggregator POM, which loads the BOM in its <dependencyManagement>
block. When executing e.g. gitflow:release-finish
, this yields the following error:
[ERROR] Non-resolvable import POM: Failure to find ...
In a (currently private) fork of the Git Flow Maven Plugin, we were able to sidestep this issue by modifying AbstractGitFlowMojo#reloadProject(MavenProject)
as follows:
private MavenProject reloadProject(final MavenProject project) throws MojoFailureException {
try {
List<ProjectBuildingResult> results = projectBuilder.build(Collections.singletonList(project.getFile()),
true, mavenSession.getProjectBuildingRequest());
for (ProjectBuildingResult result : results) {
MavenProject reloadedProject = result.getProject();
if (project.getArtifactId().equals(reloadedProject.getArtifactId())) {
return reloadedProject;
}
}
throw new NoSuchElementException("No reloaded project matches the artifact ID " + project.getArtifactId());
} catch (Exception e) {
throw new MojoFailureException("Error re-loading project info", e);
}
}
Via ProjectBuilder#build(List<File>, boolean, ProjectBuildingRequest)
, this recursively builds all sub modules to make sure the corresponding artifacts are available – which, I believe, should also help to address this issue. (Note that we are additionally adding -DargLine='-DprocessAllModules'
as suggested here.)
This is the first time I'm touching the Maven Core API, therefore, does this make sense to anybody?
Hello @beatngu13, I wrapped up your suggested code Changes in Pull Request #324
@dirk-kaspar @beatngu13 Can you add integration test to that PR? Or at least create small project that demonstrates this error.
@aleksandr-m @beatngu13 I added an Integration Test on that PR. Could you please review the changes?
I do have the following Project Structure: https://github.com/apfelbasti/GitflowMaven Unfortunately I am not able to build a release version (from 0.0.1-SNAPSHOT to 0.0.1 to 0.0.2-SNAPSHOT. Is is possible with this structure or is my command wrong?
@apfelbasti what command are you using and what error do you get?
@beatngu13 I use gitflow:release -DprocessAllModules from the aggregator-Project. The versions for -bom and other projects are "old".
@apfelbasti you have to pass the property as follows:
$ mvn gitflow:release -DargLine='-DprocessAllModules'
Does this help?
@beatngu13 Unfortunately not... This does only update the version of the aggregator-Project.
@apfelbasti I just had a look at your repository:
-DprocessAllModules
(which stems from the Maven Versions Plugin plugin) has no effect.When you invoke the Maven Versions Plugin directly, indeed only the aggregator version changes:
$ mvn versions:set -DnewVersion=0.0.4 -DprocessAllModules
...
$ git diff
diff --git a/gitflow-maven-aggregator/pom.xml b/gitflow-maven-aggregator/pom.xml
index 4adadab..db31787 100644
--- a/gitflow-maven-aggregator/pom.xml
+++ b/gitflow-maven-aggregator/pom.xml
@@ -4,7 +4,7 @@
<groupId>de.apfelbasti</groupId>
<artifactId>gitflow-maven-aggregator</artifactId>
- <version>0.0.4-SNAPSHOT</version>
+ <version>0.0.4</version>
<packaging>pom</packaging>
<properties>
However, when you sync the versions, i.e., manually bump the other modules to 0.0.4-SNAPSHOT, then it works:
$ mvn versions:set -DnewVersion=0.0.4 -DprocessAllModules
...
$ git diff
diff --git a/gitflow-maven-aggregator/pom.xml b/gitflow-maven-aggregator/pom.xml
index 4adadab..db31787 100644
--- a/gitflow-maven-aggregator/pom.xml
+++ b/gitflow-maven-aggregator/pom.xml
@@ -4,7 +4,7 @@
<groupId>de.apfelbasti</groupId>
<artifactId>gitflow-maven-aggregator</artifactId>
- <version>0.0.4-SNAPSHOT</version>
+ <version>0.0.4</version>
<packaging>pom</packaging>
<properties>
diff --git a/gitflow-maven-bom/pom.xml b/gitflow-maven-bom/pom.xml
index bfea80a..69ee155 100644
--- a/gitflow-maven-bom/pom.xml
+++ b/gitflow-maven-bom/pom.xml
@@ -4,7 +4,7 @@
<groupId>de.apfelbasti</groupId>
<artifactId>gitflow-maven-bom</artifactId>
- <version>0.0.4-SNAPSHOT</version>
+ <version>0.0.4</version>
<packaging>pom</packaging>
<properties>
diff --git a/gitflow-maven-x/pom.xml b/gitflow-maven-x/pom.xml
index b23eb58..9799789 100644
--- a/gitflow-maven-x/pom.xml
+++ b/gitflow-maven-x/pom.xml
@@ -7,7 +7,7 @@
<parent>
<groupId>de.apfelbasti</groupId>
<artifactId>gitflow-maven-bom</artifactId>
- <version>0.0.4-SNAPSHOT</version>
+ <version>0.0.4</version>
<relativePath>../gitflow-maven-bom</relativePath>
</parent>
diff --git a/gitflow-maven-y/pom.xml b/gitflow-maven-y/pom.xml
index 587e759..bdbd56f 100644
--- a/gitflow-maven-y/pom.xml
+++ b/gitflow-maven-y/pom.xml
@@ -7,7 +7,7 @@
<parent>
<groupId>de.apfelbasti</groupId>
<artifactId>gitflow-maven-bom</artifactId>
- <version>0.0.4-SNAPSHOT</version>
+ <version>0.0.4</version>
<relativePath>../gitflow-maven-bom</relativePath>
</parent>
diff --git a/gitflow-maven-z/pom.xml b/gitflow-maven-z/pom.xml
index f4f2ff0..e82cd09 100644
--- a/gitflow-maven-z/pom.xml
+++ b/gitflow-maven-z/pom.xml
@@ -7,7 +7,7 @@
<parent>
<groupId>de.apfelbasti</groupId>
<artifactId>gitflow-maven-bom</artifactId>
- <version>0.0.4-SNAPSHOT</version>
+ <version>0.0.4</version>
<relativePath>../gitflow-maven-bom</relativePath>
</parent>
When you commit setting all versions to 0.0.4-SNAPSHOT and abandon
<configuration>
<tychoBuild>true</tychoBuild>
</configuration>
from the aggregator and the BOM, everything works fine:
$ mvn gitflow:release -DargLine='-DprocessAllModules'
...
$ git diff HEAD^
diff --git a/gitflow-maven-aggregator/pom.xml b/gitflow-maven-aggregator/pom.xml
index 482e008..d36ced3 100644
--- a/gitflow-maven-aggregator/pom.xml
+++ b/gitflow-maven-aggregator/pom.xml
@@ -4,7 +4,7 @@
<groupId>de.apfelbasti</groupId>
<artifactId>gitflow-maven-aggregator</artifactId>
- <version>0.0.4</version>
+ <version>0.0.5-SNAPSHOT</version>
<packaging>pom</packaging>
<properties>
diff --git a/gitflow-maven-bom/pom.xml b/gitflow-maven-bom/pom.xml
index 1157be9..04c7201 100644
--- a/gitflow-maven-bom/pom.xml
+++ b/gitflow-maven-bom/pom.xml
@@ -4,7 +4,7 @@
<groupId>de.apfelbasti</groupId>
<artifactId>gitflow-maven-bom</artifactId>
- <version>0.0.4</version>
+ <version>0.0.5-SNAPSHOT</version>
<packaging>pom</packaging>
<properties>
diff --git a/gitflow-maven-x/pom.xml b/gitflow-maven-x/pom.xml
index 9799789..f47679a 100644
--- a/gitflow-maven-x/pom.xml
+++ b/gitflow-maven-x/pom.xml
@@ -7,7 +7,7 @@
<parent>
<groupId>de.apfelbasti</groupId>
<artifactId>gitflow-maven-bom</artifactId>
- <version>0.0.4</version>
+ <version>0.0.5-SNAPSHOT</version>
<relativePath>../gitflow-maven-bom</relativePath>
</parent>
diff --git a/gitflow-maven-y/pom.xml b/gitflow-maven-y/pom.xml
index bdbd56f..57deebc 100644
--- a/gitflow-maven-y/pom.xml
+++ b/gitflow-maven-y/pom.xml
@@ -7,7 +7,7 @@
<parent>
<groupId>de.apfelbasti</groupId>
<artifactId>gitflow-maven-bom</artifactId>
- <version>0.0.4</version>
+ <version>0.0.5-SNAPSHOT</version>
<relativePath>../gitflow-maven-bom</relativePath>
</parent>
diff --git a/gitflow-maven-z/pom.xml b/gitflow-maven-z/pom.xml
index e82cd09..9bc37dc 100644
--- a/gitflow-maven-z/pom.xml
+++ b/gitflow-maven-z/pom.xml
@@ -7,7 +7,7 @@
<parent>
<groupId>de.apfelbasti</groupId>
<artifactId>gitflow-maven-bom</artifactId>
- <version>0.0.4</version>
+ <version>0.0.5-SNAPSHOT</version>
<relativePath>../gitflow-maven-bom</relativePath>
</parent>
If you want/have to stick to Tycho, maybe there is a property similar to processAllModules
from the Maven Versions Plugin. The following goal is invoked by the Gitflow Maven Plugin:
https://eclipse.org/tycho/sitedocs/tycho-release/tycho-versions-plugin/set-version-mojo.html
Looks like this issue has been addressed, at least when using the Maven Versions Plugin? Updating the docs with a hint regarding processAllModules
and how to pass it to the Gitflow Maven Plugin (i.e. -DargLine='-DprocessAllModules'
) surely would be helpful.
@beatngu13 Thank you! It just works without <tychoBuild>true</tychoBuild>
. I didn't realized, that this was the problem.
If the multi module POM (root) and the parent POM are different POMs, the the plugin throws the following error:
Sample POM (https://github.com/Drombler/drombler-commons/blob/develop/pom.xml ):