Skip to content

Commit 98dcd78

Browse files
authored
Fix requested manually managed dependencies (#432)
1 parent 8e3ff08 commit 98dcd78

File tree

2 files changed

+60
-34
lines changed

2 files changed

+60
-34
lines changed

components/sbm-support-boot/src/main/java/org/springframework/sbm/boot/common/conditions/HasSpringBootDependencyManuallyManaged.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public boolean evaluate(ProjectContext context) {
4343
.stream()
4444
.map(Module::getBuildFile)
4545
.anyMatch(b -> {
46-
boolean matchedInDependencies = b.getDeclaredDependencies()
46+
boolean matchedInDependencies = b.getRequestedDependencies()
4747
.stream()
4848
.anyMatch(matchesSpringBootPattern());
4949

components/sbm-support-boot/src/test/java/org/springframework/sbm/boot/common/conditions/HasSpringBootDependencyManuallyManagedTest.java

Lines changed: 59 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -191,41 +191,67 @@ public void conditionToBeTrueIfManagedDependencies() {
191191
}
192192

193193
@Test
194-
public void conditionToBeTrueIfVersionIsDefinedInProperty() {
194+
public void conditionToBeTrueIfVersionIsDefinedInParentPom() {
195195
ProjectContext projectContext = TestProjectContext.buildProjectContext()
196196
.withMavenRootBuildFileSource("""
197-
<?xml version="1.0" encoding="UTF-8"?>
198-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
199-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
200-
<modelVersion>4.0.0</modelVersion>
201-
<groupId>com.example</groupId>
202-
<artifactId>explicit-deps-app</artifactId>
203-
<version>0.0.1-SNAPSHOT</version>
204-
<name>explicit-deps-app</name>
205-
<description>explicit-deps-app</description>
206-
<properties>
207-
<spring-boot.version>2.7.1</spring-boot.version>
208-
</properties>
209-
210-
<dependencies>
211-
<dependency>
212-
<groupId>org.springframework.boot</groupId>
213-
<artifactId>spring-boot-starter-web</artifactId>
214-
<version>${spring-boot.version}</version>
215-
</dependency>
216-
<dependency>
217-
<groupId>io.dropwizard.metrics</groupId>
218-
<artifactId>metrics-annotation</artifactId>
219-
<version>4.2.8</version>
220-
</dependency>
221-
<dependency>
222-
<groupId>org.springframework.boot</groupId>
223-
<artifactId>spring-boot-starter-test</artifactId>
224-
<version>2.7.3</version>
225-
<scope>test</scope>
226-
</dependency>
227-
</dependencies>
228-
</project>
197+
<?xml version="1.0" encoding="UTF-8"?>
198+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
199+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
200+
<modelVersion>4.0.0</modelVersion>
201+
<packaging>pom</packaging>
202+
<groupId>com.example</groupId>
203+
<artifactId>parent-boot-upgrade-27_30</artifactId>
204+
<version>0.0.1-SNAPSHOT</version>
205+
<name>parent-boot-upgrade-27_30</name>
206+
<description>parent-boot-upgrade-27_30</description>
207+
<properties>
208+
<java.version>17</java.version>
209+
<spring-boot.version>2.7.3</spring-boot.version>
210+
</properties>
211+
<modules>
212+
<module>component1</module>
213+
</modules>
214+
<repositories>
215+
<repository>
216+
<id>spring-milestone</id>
217+
<url>https://repo.spring.io/milestone</url>
218+
<snapshots>
219+
<enabled>false</enabled>
220+
</snapshots>
221+
</repository>
222+
</repositories>
223+
</project>
224+
""")
225+
.withMavenBuildFileSource("component1/pom.xml", """
226+
<?xml version="1.0" encoding="UTF-8"?>
227+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
228+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
229+
<modelVersion>4.0.0</modelVersion>
230+
<parent>
231+
<groupId>com.example</groupId>
232+
<artifactId>parent-boot-upgrade-27_30</artifactId>
233+
<version>0.0.1-SNAPSHOT</version>
234+
</parent>
235+
<groupId>com.example</groupId>
236+
<artifactId>explicit-deps-app</artifactId>
237+
<version>0.0.1-SNAPSHOT</version>
238+
<name>explicit-deps-app</name>
239+
<description>explicit-deps-app</description>
240+
241+
<dependencies>
242+
<dependency>
243+
<groupId>org.springframework.boot</groupId>
244+
<artifactId>spring-boot-starter-web</artifactId>
245+
<version>${spring-boot.version}</version>
246+
</dependency>
247+
<dependency>
248+
<groupId>org.springframework.boot</groupId>
249+
<artifactId>spring-boot-starter-test</artifactId>
250+
<version>${spring-boot.version}</version>
251+
<scope>test</scope>
252+
</dependency>
253+
</dependencies>
254+
</project>
229255
""")
230256
.build();
231257

0 commit comments

Comments
 (0)