File tree Expand file tree Collapse file tree 2 files changed +28
-5
lines changed
src/main/java/pl/project13/maven/git Expand file tree Collapse file tree 2 files changed +28
-5
lines changed Original file line number Diff line number Diff line change @@ -254,16 +254,23 @@ It's really simple to setup this plugin; below is a sample pom that you may base
254
254
Explanation:
255
255
Use with caution!
256
256
257
- In a multi-module build, only run once. This means that the plugins effects will only execute once, for the parent project.
257
+ In a multi-module build, only run once. This means that the plugins effects will only execute
258
+ once for the first project in the execution graph. If `skipPoms` is set to true (default)
259
+ the plugin will run for the first non pom project in the execution graph (as listed in the reactor build order).
258
260
This probably won't "do the right thing" if your project has more than one git repository.
259
261
260
262
Important: If you're using `generateGitPropertiesFile`, setting `runOnlyOnce` will make the plugin
261
- only generate the file in the directory where you started your build (!).
263
+ only generate the file in the project build directory which is the first one based on the execution graph (!).
262
264
263
265
Important: Please note that the git-commit-id-plugin also has an option to skip pom project (`<packaging>pom</packaging>`).
264
266
If you plan to use the `runOnlyOnce` option alongside with an aggregator pom you may want to set `<skipPoms>false</skipPoms>`.
265
267
266
- The `git.*` maven properties are available in all modules.
268
+ For multi-module build you might also want to set `injectAllReactorProjects` to make
269
+ the `git.*` maven properties available in all modules.
270
+
271
+ Note:
272
+ prior to version 4.0.0 the plugin was simply using the execute once applied for the parent project
273
+ (which might have skipped execution if the parent project was a pom project).
267
274
-->
268
275
<runOnlyOnce >false</runOnlyOnce >
269
276
Original file line number Diff line number Diff line change @@ -419,8 +419,24 @@ public void execute() throws MojoExecutionException {
419
419
}
420
420
421
421
if (runOnlyOnce ) {
422
- if (!session .getExecutionRootDirectory ().equals (session .getCurrentProject ().getBasedir ().getAbsolutePath ())) {
423
- log .info ("runOnlyOnce is enabled and this project is not the top level project, skipping execution!" );
422
+ List <MavenProject > sortedProjects = session .getProjectDependencyGraph ().getSortedProjects ();
423
+ MavenProject firstProject = sortedProjects .stream ()
424
+ // skipPoms == true => find first project that is not pom project
425
+ .filter (p -> {
426
+ if (skipPoms ) {
427
+ return !isPomProject (p );
428
+ } else {
429
+ return true ;
430
+ }
431
+ })
432
+ .findFirst ()
433
+ .orElse (session .getCurrentProject ());
434
+
435
+ log .info ("Current project: '" + session .getCurrentProject ().getName () +
436
+ "', first project to execute based on dependency graph: '" + firstProject .getName () + "'" );
437
+
438
+ if (!session .getCurrentProject ().equals (firstProject )) {
439
+ log .info ("runOnlyOnce is enabled and this project is not the first project (perhaps skipPoms is configured?), skipping execution!" );
424
440
return ;
425
441
}
426
442
}
You can’t perform that action at this time.
0 commit comments