From 769da0af3757c0756165150f7136f063e1f01723 Mon Sep 17 00:00:00 2001 From: Slawomir Jaranowski Date: Sat, 28 Jan 2023 13:26:46 +0100 Subject: [PATCH] [MENFORCER-462] Execute ReactorModuleConvergence only once Rule checks whole reactor of current build so can be executed once in session --- .../maven/enforcer/rules/ReactorModuleConvergence.java | 5 +++++ .../maven/enforcer/rules/ReactorModuleConvergenceTest.java | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/enforcer-rules/src/main/java/org/apache/maven/enforcer/rules/ReactorModuleConvergence.java b/enforcer-rules/src/main/java/org/apache/maven/enforcer/rules/ReactorModuleConvergence.java index 651f12f5..090b056e 100644 --- a/enforcer-rules/src/main/java/org/apache/maven/enforcer/rules/ReactorModuleConvergence.java +++ b/enforcer-rules/src/main/java/org/apache/maven/enforcer/rules/ReactorModuleConvergence.java @@ -392,6 +392,11 @@ private void addMessageIfExist(StringBuilder sb) { } } + @Override + public String getCacheId() { + return String.valueOf(toString().hashCode()); + } + @Override public String toString() { return String.format( diff --git a/enforcer-rules/src/test/java/org/apache/maven/enforcer/rules/ReactorModuleConvergenceTest.java b/enforcer-rules/src/test/java/org/apache/maven/enforcer/rules/ReactorModuleConvergenceTest.java index e3b6bc53..f7b25568 100644 --- a/enforcer-rules/src/test/java/org/apache/maven/enforcer/rules/ReactorModuleConvergenceTest.java +++ b/enforcer-rules/src/test/java/org/apache/maven/enforcer/rules/ReactorModuleConvergenceTest.java @@ -32,6 +32,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -221,6 +222,11 @@ void shouldFailWithWrongDependencyInReactor() { // intentionally no assertTrue() cause we expect getting an exception. } + @Test + void cacheIdShouldBeSet() { + assertThat(rule.getCacheId()).isNotEmpty(); + } + /** * This small setup is equivalent to the following situation: *