Add Spring-Boot-* manifest attributes to jars and wars built with Gradle
Closes gh-16068
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2018 the original author or authors.
|
||||
* Copyright 2012-2019 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.
|
||||
@@ -73,10 +73,20 @@ class BootArchiveSupport {
|
||||
configureExclusions();
|
||||
}
|
||||
|
||||
void configureManifest(Jar jar, String mainClassName) {
|
||||
void configureManifest(Jar jar, String mainClassName, String springBootClasses,
|
||||
String springBootLib) {
|
||||
Attributes attributes = jar.getManifest().getAttributes();
|
||||
attributes.putIfAbsent("Main-Class", this.loaderMainClass);
|
||||
attributes.putIfAbsent("Start-Class", mainClassName);
|
||||
attributes.computeIfAbsent("Spring-Boot-Version",
|
||||
(key) -> determineSpringBootVersion());
|
||||
attributes.putIfAbsent("Spring-Boot-Classes", springBootClasses);
|
||||
attributes.putIfAbsent("Spring-Boot-Lib", springBootLib);
|
||||
}
|
||||
|
||||
private String determineSpringBootVersion() {
|
||||
String implementationVersion = getClass().getPackage().getImplementationVersion();
|
||||
return (implementationVersion != null) ? implementationVersion : "unknown";
|
||||
}
|
||||
|
||||
CopyAction createCopyAction(Jar jar) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2018 the original author or authors.
|
||||
* Copyright 2012-2019 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.
|
||||
@@ -65,7 +65,8 @@ public class BootJar extends Jar implements BootArchive {
|
||||
|
||||
@Override
|
||||
public void copy() {
|
||||
this.support.configureManifest(this, getMainClassName());
|
||||
this.support.configureManifest(this, getMainClassName(), "BOOT-INF/classes/",
|
||||
"BOOT-INF/lib/");
|
||||
super.copy();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2018 the original author or authors.
|
||||
* Copyright 2012-2019 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.
|
||||
@@ -57,7 +57,8 @@ public class BootWar extends War implements BootArchive {
|
||||
|
||||
@Override
|
||||
public void copy() {
|
||||
this.support.configureManifest(this, getMainClassName());
|
||||
this.support.configureManifest(this, getMainClassName(), "WEB-INF/classes/",
|
||||
"WEB-INF/lib/");
|
||||
super.copy();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user