From 0b67d70f82117ab804c3680b3b4ca8978d665a20 Mon Sep 17 00:00:00 2001 From: Sam Barker Date: Mon, 13 Nov 2023 13:17:09 +0100 Subject: [PATCH] use built in enforcer rule rather than a custom one to ban the use of system tests in other modules Signed-off-by: Sam Barker rh-pre-commit.version: 2.0.1 rh-pre-commit.check-secrets: ENABLED --- kroxylicious-enforcer-rules/pom.xml | 39 ----------- .../rules/SystemTestIsolationRule.java | 65 ------------------- kroxylicious-systemtests/pom.xml | 26 +------- pom.xml | 24 ++++++- 4 files changed, 23 insertions(+), 131 deletions(-) delete mode 100644 kroxylicious-enforcer-rules/pom.xml delete mode 100644 kroxylicious-enforcer-rules/src/main/java/io/kroxylicious/enforcer/rules/SystemTestIsolationRule.java diff --git a/kroxylicious-enforcer-rules/pom.xml b/kroxylicious-enforcer-rules/pom.xml deleted file mode 100644 index 7d26a3df48..0000000000 --- a/kroxylicious-enforcer-rules/pom.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - - 4.0.0 - - io.kroxylicious - kroxylicious-parent - 0.4.0-SNAPSHOT - - - kroxylicious-enforcer-rules - - - 17 - 17 - UTF-8 - - - - - org.apache.maven.enforcer - enforcer-api - - - org.apache.maven - maven-core - - - - diff --git a/kroxylicious-enforcer-rules/src/main/java/io/kroxylicious/enforcer/rules/SystemTestIsolationRule.java b/kroxylicious-enforcer-rules/src/main/java/io/kroxylicious/enforcer/rules/SystemTestIsolationRule.java deleted file mode 100644 index e1958a944d..0000000000 --- a/kroxylicious-enforcer-rules/src/main/java/io/kroxylicious/enforcer/rules/SystemTestIsolationRule.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright Kroxylicious Authors. - * - * Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0 - */ - -package io.kroxylicious.enforcer.rules; - -import java.util.Arrays; -import java.util.List; - -import javax.inject.Named; - -import org.apache.maven.enforcer.rule.api.EnforcerRule; -import org.apache.maven.enforcer.rule.api.EnforcerRuleException; -import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper; -import org.apache.maven.execution.MavenSession; -import org.apache.maven.execution.ProjectDependencyGraph; -import org.apache.maven.plugin.logging.Log; -import org.apache.maven.project.MavenProject; -import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException; - -/** - * System test isolation rule - * Checks that no other modules depends on System test module - */ -@Named("systemTestIsolationRule") // rule name - must start from lowercase character -public class SystemTestIsolationRule implements EnforcerRule { - - public void execute(EnforcerRuleHelper helper) throws EnforcerRuleException { - final Log log = helper.getLog(); - final MavenProject currentProject; - final MavenSession session; - try { - currentProject = ((MavenProject) helper.evaluate("${project}")); - session = (MavenSession) helper.evaluate("${session}"); - } - catch (ExpressionEvaluationException e) { - throw new RuntimeException(e); - } - - ProjectDependencyGraph graph = session.getProjectDependencyGraph(); - List downProjects = graph.getDownstreamProjects(currentProject, true); - log.info("Maven downstream projects: " + Arrays.toString(downProjects.toArray())); - - if (!downProjects.isEmpty()) { - throw new EnforcerRuleException("Failing because system test module is used as a dependency in another project"); - } - } - - @Override - public boolean isCacheable() { - return false; - } - - @Override - public boolean isResultValid(EnforcerRule enforcerRule) { - return false; - } - - @Override - public String getCacheId() { - return null; - } -} diff --git a/kroxylicious-systemtests/pom.xml b/kroxylicious-systemtests/pom.xml index ec74a5fb8d..84acc61dbe 100644 --- a/kroxylicious-systemtests/pom.xml +++ b/kroxylicious-systemtests/pom.xml @@ -132,30 +132,6 @@ - - org.apache.maven.plugins - maven-enforcer-plugin - - - io.kroxylicious - kroxylicious-enforcer-rules - 0.4.0-SNAPSHOT - - - - - enforce-systemtest-isolation - - - - - - - enforce - - - - @@ -163,4 +139,4 @@ - + \ No newline at end of file diff --git a/pom.xml b/pom.xml index 97d9782a17..9394977471 100644 --- a/pom.xml +++ b/pom.xml @@ -343,7 +343,6 @@ - kroxylicious-enforcer-rules kroxylicious-kms kroxylicious-kms-provider-kroxylicious-inmemory kroxylicious-bom @@ -655,6 +654,27 @@ + + org.apache.maven.plugins + maven-enforcer-plugin + + + enforce-systemtest-isolation + + enforce + + + + + + io.kroxylicious:kroxylicious-systemtests + + + + + + + @@ -949,4 +969,4 @@ - + \ No newline at end of file