See gh-24597
This commit is contained in:
Stephane Nicoll 2021-01-04 16:39:27 +01:00
parent 4b5b97ba04
commit c19f7e696e
1 changed files with 10 additions and 6 deletions

View File

@ -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.
@ -20,7 +20,6 @@ import java.io.IOException;
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;
@ -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;
}
}