From c72b77c08e635cde7876e8557e641d786e4f5f61 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Wed, 26 Apr 2023 20:36:45 +0100 Subject: [PATCH] Polish --- .../boot/build/architecture/Rules.java | 62 ------------------- 1 file changed, 62 deletions(-) delete mode 100644 buildSrc/src/main/java/org/springframework/boot/build/architecture/Rules.java diff --git a/buildSrc/src/main/java/org/springframework/boot/build/architecture/Rules.java b/buildSrc/src/main/java/org/springframework/boot/build/architecture/Rules.java deleted file mode 100644 index d12c0a813b..0000000000 --- a/buildSrc/src/main/java/org/springframework/boot/build/architecture/Rules.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright 2023 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.build.architecture; - -import java.util.stream.Stream; - -import com.tngtech.archunit.base.DescribedPredicate; -import com.tngtech.archunit.core.domain.JavaClass.Predicates; -import com.tngtech.archunit.lang.ArchRule; -import com.tngtech.archunit.lang.syntax.ArchRuleDefinition; -import com.tngtech.archunit.library.dependencies.SlicesRuleDefinition; - -/** - * Architecture rules evaluated by {@link ArchitectureCheck}. - * - * @author Andy Wilkinson - */ -final class Rules { - - private Rules() { - - } - - static Stream stream() { - return Stream.of(allPackagesShouldBeFreeOfTangles(), - allBeanPostProcessorBeanMethodsShouldBeStaticAndHaveParametersThatWillNotCausePrematureInitialization()); - } - - static ArchRule allPackagesShouldBeFreeOfTangles() { - return SlicesRuleDefinition.slices().matching("(**)").should().beFreeOfCycles(); - } - - static ArchRule allBeanPostProcessorBeanMethodsShouldBeStaticAndHaveParametersThatWillNotCausePrematureInitialization() { - return ArchRuleDefinition.methods() - .that() - .areAnnotatedWith("org.springframework.context.annotation.Bean") - .and() - .haveRawReturnType(Predicates.assignableTo("org.springframework.beans.factory.config.BeanPostProcessor")) - .should() - .beStatic() - .andShould() - .haveRawParameterTypes(DescribedPredicate - .allElements(Predicates.assignableTo("org.springframework.beans.factory.ObjectProvider") - .or(Predicates.assignableTo("org.springframework.context.ApplicationContext")))) - .allowEmptyShould(true); - } - -}