Skip to content

Commit e937b2e

Browse files
committed
Merge branch '2.1.x' into 2.2.x
Closes gh-20501
2 parents e1ce21c + f251772 commit e937b2e

File tree

4 files changed

+44
-3
lines changed

4 files changed

+44
-3
lines changed

spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/DependencyCustomizer.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2019 the original author or authors.
2+
* Copyright 2012-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -143,7 +143,6 @@ protected boolean canAdd() {
143143
if (DependencyCustomizer.this.loader.getResource(path) == null) {
144144
return false;
145145
}
146-
return true;
147146
}
148147
catch (Exception ex) {
149148
// swallow exception and continue

spring-boot-project/spring-boot-cli/src/test/java/org/springframework/boot/cli/compiler/DependencyCustomizerTests.java

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2019 the original author or authors.
2+
* Copyright 2012-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -138,6 +138,48 @@ void allMissingClassesWithAllClassesMissingPerformsAdd() {
138138
assertThat(this.classNode.getAnnotations(new ClassNode(Grab.class))).hasSize(1);
139139
}
140140

141+
@Test
142+
void allResourcesPresentWithAllResourcesPresentPerformsAdd() {
143+
this.dependencyCustomizer.ifAllResourcesPresent("dependency-customizer-tests/resource1.txt",
144+
"dependency-customizer-tests/resource2.txt").add("spring-boot-starter-logging");
145+
assertThat(this.classNode.getAnnotations(new ClassNode(Grab.class))).hasSize(1);
146+
}
147+
148+
@Test
149+
void allResourcesPresentWithSomeResourcesPresentDoesNotPerformAdd() {
150+
this.dependencyCustomizer.ifAllResourcesPresent("dependency-customizer-tests/resource1.txt",
151+
"dependency-customizer-tests/does-not-exist.txt").add("spring-boot-starter-logging");
152+
assertThat(this.classNode.getAnnotations(new ClassNode(Grab.class))).isEmpty();
153+
}
154+
155+
@Test
156+
void allResourcesPresentWithNoResourcesPresentDoesNotPerformAdd() {
157+
this.dependencyCustomizer.ifAllResourcesPresent("dependency-customizer-tests/does-not-exist",
158+
"dependency-customizer-tests/does-not-exist-either.txt").add("spring-boot-starter-logging");
159+
assertThat(this.classNode.getAnnotations(new ClassNode(Grab.class))).isEmpty();
160+
}
161+
162+
@Test
163+
void anyResourcesPresentWithAllResourcesPresentPerformsAdd() {
164+
this.dependencyCustomizer.ifAnyResourcesPresent("dependency-customizer-tests/resource1.txt",
165+
"dependency-customizer-tests/resource2.txt").add("spring-boot-starter-logging");
166+
assertThat(this.classNode.getAnnotations(new ClassNode(Grab.class))).hasSize(1);
167+
}
168+
169+
@Test
170+
void anyResourcesPresentWithSomeResourcesPresentPerforms() {
171+
this.dependencyCustomizer.ifAnyResourcesPresent("dependency-customizer-tests/resource1.txt",
172+
"dependency-customizer-tests/does-not-exist.txt").add("spring-boot-starter-logging");
173+
assertThat(this.classNode.getAnnotations(new ClassNode(Grab.class))).hasSize(1);
174+
}
175+
176+
@Test
177+
void anyResourcesPresentWithNoResourcesPresentDoesNotPerformAdd() {
178+
this.dependencyCustomizer.ifAnyResourcesPresent("dependency-customizer-tests/does-not-exist",
179+
"dependency-customizer-tests/does-not-exist-either.txt").add("spring-boot-starter-logging");
180+
assertThat(this.classNode.getAnnotations(new ClassNode(Grab.class))).isEmpty();
181+
}
182+
141183
private void assertGrabAnnotation(AnnotationNode annotationNode, String group, String module, String version,
142184
String classifier, String type, boolean transitive) {
143185
assertThat(getMemberValue(annotationNode, "group")).isEqualTo(group);

spring-boot-project/spring-boot-cli/src/test/resources/dependency-customizer-tests/resource1.txt

Whitespace-only changes.

spring-boot-project/spring-boot-cli/src/test/resources/dependency-customizer-tests/resource2.txt

Whitespace-only changes.

0 commit comments

Comments
 (0)