|
|
|
@ -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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|