Skip to content

Commit

Permalink
Polish
Browse files Browse the repository at this point in the history
  • Loading branch information
snicoll committed Jan 4, 2021
1 parent 4b5b97b commit c19f7e6
Showing 1 changed file with 10 additions and 6 deletions.
@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2021 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.
Expand All @@ -20,7 +20,6 @@
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.Optional;
import java.util.Set;
import java.util.jar.JarFile;
import java.util.jar.Manifest;
Expand All @@ -45,13 +44,18 @@ class JarTypeFilter extends DependencyFilter {
@Override
protected boolean filter(Artifact artifact) {
try (JarFile jarFile = new JarFile(artifact.getFile())) {
return Optional.ofNullable(jarFile.getManifest()).map(Manifest::getMainAttributes)
.map((attributes) -> attributes.getValue("Spring-Boot-Jar-Type")).map(EXCLUDED_JAR_TYPES::contains)
.orElse(Boolean.FALSE);
Manifest manifest = jarFile.getManifest();
if (manifest != null) {
String jarType = manifest.getMainAttributes().getValue("Spring-Boot-Jar-Type");
if (jarType != null && EXCLUDED_JAR_TYPES.contains(jarType)) {
return true;
}
}
}
catch (IOException ex) {
return false;
// Continue
}
return false;
}

}

0 comments on commit c19f7e6

Please sign in to comment.