Commit e937b2e0 authored by Andy Wilkinson's avatar Andy Wilkinson

Merge branch '2.1.x' into 2.2.x

Closes gh-20501
parents e1ce21c3 f251772e
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2020 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -143,7 +143,6 @@ public class DependencyCustomizer { ...@@ -143,7 +143,6 @@ public class DependencyCustomizer {
if (DependencyCustomizer.this.loader.getResource(path) == null) { if (DependencyCustomizer.this.loader.getResource(path) == null) {
return false; return false;
} }
return true;
} }
catch (Exception ex) { catch (Exception ex) {
// swallow exception and continue // swallow exception and continue
......
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2020 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -138,6 +138,48 @@ class DependencyCustomizerTests { ...@@ -138,6 +138,48 @@ class DependencyCustomizerTests {
assertThat(this.classNode.getAnnotations(new ClassNode(Grab.class))).hasSize(1); assertThat(this.classNode.getAnnotations(new ClassNode(Grab.class))).hasSize(1);
} }
@Test
void allResourcesPresentWithAllResourcesPresentPerformsAdd() {
this.dependencyCustomizer.ifAllResourcesPresent("dependency-customizer-tests/resource1.txt",
"dependency-customizer-tests/resource2.txt").add("spring-boot-starter-logging");
assertThat(this.classNode.getAnnotations(new ClassNode(Grab.class))).hasSize(1);
}
@Test
void allResourcesPresentWithSomeResourcesPresentDoesNotPerformAdd() {
this.dependencyCustomizer.ifAllResourcesPresent("dependency-customizer-tests/resource1.txt",
"dependency-customizer-tests/does-not-exist.txt").add("spring-boot-starter-logging");
assertThat(this.classNode.getAnnotations(new ClassNode(Grab.class))).isEmpty();
}
@Test
void allResourcesPresentWithNoResourcesPresentDoesNotPerformAdd() {
this.dependencyCustomizer.ifAllResourcesPresent("dependency-customizer-tests/does-not-exist",
"dependency-customizer-tests/does-not-exist-either.txt").add("spring-boot-starter-logging");
assertThat(this.classNode.getAnnotations(new ClassNode(Grab.class))).isEmpty();
}
@Test
void anyResourcesPresentWithAllResourcesPresentPerformsAdd() {
this.dependencyCustomizer.ifAnyResourcesPresent("dependency-customizer-tests/resource1.txt",
"dependency-customizer-tests/resource2.txt").add("spring-boot-starter-logging");
assertThat(this.classNode.getAnnotations(new ClassNode(Grab.class))).hasSize(1);
}
@Test
void anyResourcesPresentWithSomeResourcesPresentPerforms() {
this.dependencyCustomizer.ifAnyResourcesPresent("dependency-customizer-tests/resource1.txt",
"dependency-customizer-tests/does-not-exist.txt").add("spring-boot-starter-logging");
assertThat(this.classNode.getAnnotations(new ClassNode(Grab.class))).hasSize(1);
}
@Test
void anyResourcesPresentWithNoResourcesPresentDoesNotPerformAdd() {
this.dependencyCustomizer.ifAnyResourcesPresent("dependency-customizer-tests/does-not-exist",
"dependency-customizer-tests/does-not-exist-either.txt").add("spring-boot-starter-logging");
assertThat(this.classNode.getAnnotations(new ClassNode(Grab.class))).isEmpty();
}
private void assertGrabAnnotation(AnnotationNode annotationNode, String group, String module, String version, private void assertGrabAnnotation(AnnotationNode annotationNode, String group, String module, String version,
String classifier, String type, boolean transitive) { String classifier, String type, boolean transitive) {
assertThat(getMemberValue(annotationNode, "group")).isEqualTo(group); assertThat(getMemberValue(annotationNode, "group")).isEqualTo(group);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment