GH-660 - Dependency checks now explicitly skip module-internal dependencies.

As we process a type's entire type hierarchy for dependencies we might discover a foreign module's internal dependencies for modules that declare allowed dependencies explicitly. Explicitly declared dependencies so far solely verified the target being explicitly listed, which, for internal dependencies does not make sense. We now immediately start checking the source and target modules to be equivalent, in which case we can skip any further processing.
This commit is contained in:
Oliver Drotbohm
2024-06-18 12:29:04 +02:00
parent 3d32b2013c
commit 60149ea323
8 changed files with 107 additions and 2 deletions

View File

@@ -35,7 +35,7 @@ import com.tngtech.archunit.core.importer.ImportOption;
*
* @author Oliver Drotbohm
*/
class TestUtils {
public class TestUtils {
private static Supplier<JavaClasses> imported = SingletonSupplier.of(() -> new ClassFileImporter() //
.importPackagesOf(ApplicationModules.class, Repository.class, AggregateRoot.class));

View File

@@ -0,0 +1,30 @@
/*
* Copyright 2024 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 reproducers.gh660.first;
import org.junit.jupiter.api.Test;
import org.springframework.modulith.core.TestUtils;
/**
* @author Oliver Drotbohm
*/
class Gh660Tests {
@Test // GH-660
void doesNotRejectInternalDependencies() {
TestUtils.of("reproducers.gh660").verify();
}
}

View File

@@ -0,0 +1,2 @@
@org.springframework.modulith.ApplicationModule(allowedDependencies = {})
package reproducers.gh660.first;

View File

@@ -0,0 +1,21 @@
/*
* Copyright 2024 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 reproducers.gh660.first.repository;
/**
* @author Oliver Drotbohm
*/
public class Product {}

View File

@@ -0,0 +1,23 @@
/*
* Copyright 2024 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 reproducers.gh660.first.repository;
/**
* @author Oliver Drotbohm
*/
public interface ProductRepository {
Product save(Product product);
}

View File

@@ -0,0 +1,2 @@
@org.springframework.modulith.NamedInterface
package reproducers.gh660.first.repository;

View File

@@ -0,0 +1,23 @@
/*
* Copyright 2024 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 reproducers.gh660.second;
import reproducers.gh660.first.repository.ProductRepository;
/**
* @author Oliver Drotbohm
*/
public interface ExtendingRepository extends ProductRepository {}