Commit c19f7e69 authored by Stephane Nicoll's avatar Stephane Nicoll

Polish

See gh-24597
parent 4b5b97ba
/* /*
* 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"); * 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.
...@@ -20,7 +20,6 @@ import java.io.IOException; ...@@ -20,7 +20,6 @@ import java.io.IOException;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
import java.util.Optional;
import java.util.Set; import java.util.Set;
import java.util.jar.JarFile; import java.util.jar.JarFile;
import java.util.jar.Manifest; import java.util.jar.Manifest;
...@@ -45,13 +44,18 @@ class JarTypeFilter extends DependencyFilter { ...@@ -45,13 +44,18 @@ class JarTypeFilter extends DependencyFilter {
@Override @Override
protected boolean filter(Artifact artifact) { protected boolean filter(Artifact artifact) {
try (JarFile jarFile = new JarFile(artifact.getFile())) { try (JarFile jarFile = new JarFile(artifact.getFile())) {
return Optional.ofNullable(jarFile.getManifest()).map(Manifest::getMainAttributes) Manifest manifest = jarFile.getManifest();
.map((attributes) -> attributes.getValue("Spring-Boot-Jar-Type")).map(EXCLUDED_JAR_TYPES::contains) if (manifest != null) {
.orElse(Boolean.FALSE); String jarType = manifest.getMainAttributes().getValue("Spring-Boot-Jar-Type");
if (jarType != null && EXCLUDED_JAR_TYPES.contains(jarType)) {
return true;
}
}
} }
catch (IOException ex) { catch (IOException ex) {
return false; // Continue
} }
return false;
} }
} }
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