Skip to content

Commit 6cbe1c3

Browse files
committed
[MNG-8244] Fix mojos not bound to "started only" phases
1 parent 7be65f2 commit 6cbe1c3

File tree

3 files changed

+19
-25
lines changed

3 files changed

+19
-25
lines changed

impl/maven-core/src/main/java/org/apache/maven/internal/impl/DefaultLifecycleRegistry.java

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -411,21 +411,22 @@ public Collection<Phase> phases() {
411411
public Collection<Phase> v3phases() {
412412
return List.of(phase(
413413
ALL,
414-
phase(VALIDATE),
415-
phase(INITIALIZE),
416-
phase(SOURCES),
417-
phase(RESOURCES),
418-
phase(COMPILE),
419-
phase(READY),
420-
phase(TEST_SOURCES),
421-
phase(TEST_RESOURCES),
422-
phase(TEST_COMPILE),
423-
phase(TEST),
424-
phase(UNIT_TEST),
425-
phase(PACKAGE),
426-
phase(BUILD),
427-
phase(INTEGRATION_TEST),
428-
phase(VERIFY),
414+
phase(VALIDATE,
415+
phase(INITIALIZE)),
416+
phase(
417+
BUILD,
418+
phase(SOURCES),
419+
phase(RESOURCES),
420+
phase(COMPILE),
421+
phase(READY),
422+
phase(TEST_SOURCES),
423+
phase(TEST_RESOURCES),
424+
phase(TEST_COMPILE),
425+
phase(TEST),
426+
phase(UNIT_TEST),
427+
phase(PACKAGE)),
428+
phase(VERIFY,
429+
phase(INTEGRATION_TEST)),
429430
phase(INSTALL),
430431
phase(DEPLOY)));
431432
}

impl/maven-core/src/main/java/org/apache/maven/lifecycle/internal/DefaultLifecycleMappingDelegate.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ private Map<PhaseId, List<MojoExecution>> getPhaseBindings(
172172
Map<String, Map<PhaseId, List<MojoExecution>>> mappings, String phase) {
173173
if (phase != null) {
174174
PhaseId id = PhaseId.of(phase);
175-
return mappings.get(id.phase());
175+
return mappings.get(id.executionPoint().prefix() + id.phase());
176176
}
177177
return null;
178178
}

impl/maven-core/src/main/java/org/apache/maven/lifecycle/internal/PhaseComparator.java

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ public PhaseComparator(List<String> lifecyclePhases) {
4343
public int compare(String o1, String o2) {
4444
PhaseId p1 = PhaseId.of(o1);
4545
PhaseId p2 = PhaseId.of(o2);
46-
int i1 = lifecyclePhases.indexOf(p1.phase());
47-
int i2 = lifecyclePhases.indexOf(p2.phase());
46+
int i1 = lifecyclePhases.indexOf(p1.executionPoint().prefix() + p1.phase());
47+
int i2 = lifecyclePhases.indexOf(p2.executionPoint().prefix() + p2.phase());
4848
if (i1 == -1 && i2 == -1) {
4949
// unknown phases, leave in existing order
5050
return 0;
@@ -61,13 +61,6 @@ public int compare(String o1, String o2) {
6161
if (rv != 0) {
6262
return rv;
6363
}
64-
// same phase, now compare execution points
65-
i1 = p1.executionPoint().ordinal();
66-
i2 = p2.executionPoint().ordinal();
67-
rv = Integer.compare(i1, i2);
68-
if (rv != 0) {
69-
return rv;
70-
}
7164
// same execution point, now compare priorities
7265
return Integer.compare(p1.priority(), p2.priority());
7366
}

0 commit comments

Comments
 (0)