Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
7b5f46d6
Commit
7b5f46d6
authored
Apr 02, 2019
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Spring-Boot-* manifest attributes to jars and wars built with Gradle
Closes gh-16068
parent
336af93c
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
47 additions
and
28 deletions
+47
-28
BootArchiveSupport.java
...mework/boot/gradle/tasks/bundling/BootArchiveSupport.java
+12
-2
BootJar.java
...g/springframework/boot/gradle/tasks/bundling/BootJar.java
+3
-2
BootWar.java
...g/springframework/boot/gradle/tasks/bundling/BootWar.java
+3
-2
AbstractBootArchiveTests.java
.../boot/gradle/tasks/bundling/AbstractBootArchiveTests.java
+24
-17
BootJarTests.java
...ingframework/boot/gradle/tasks/bundling/BootJarTests.java
+2
-2
BootWarTests.java
...ingframework/boot/gradle/tasks/bundling/BootWarTests.java
+3
-3
No files found.
spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/BootArchiveSupport.java
View file @
7b5f46d6
/*
/*
* Copyright 2012-201
8
the original author or authors.
* Copyright 2012-201
9
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.
...
@@ -73,10 +73,20 @@ class BootArchiveSupport {
...
@@ -73,10 +73,20 @@ class BootArchiveSupport {
configureExclusions
();
configureExclusions
();
}
}
void
configureManifest
(
Jar
jar
,
String
mainClassName
)
{
void
configureManifest
(
Jar
jar
,
String
mainClassName
,
String
springBootClasses
,
String
springBootLib
)
{
Attributes
attributes
=
jar
.
getManifest
().
getAttributes
();
Attributes
attributes
=
jar
.
getManifest
().
getAttributes
();
attributes
.
putIfAbsent
(
"Main-Class"
,
this
.
loaderMainClass
);
attributes
.
putIfAbsent
(
"Main-Class"
,
this
.
loaderMainClass
);
attributes
.
putIfAbsent
(
"Start-Class"
,
mainClassName
);
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
)
{
CopyAction
createCopyAction
(
Jar
jar
)
{
...
...
spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/BootJar.java
View file @
7b5f46d6
/*
/*
* Copyright 2012-201
8
the original author or authors.
* Copyright 2012-201
9
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.
...
@@ -65,7 +65,8 @@ public class BootJar extends Jar implements BootArchive {
...
@@ -65,7 +65,8 @@ public class BootJar extends Jar implements BootArchive {
@Override
@Override
public
void
copy
()
{
public
void
copy
()
{
this
.
support
.
configureManifest
(
this
,
getMainClassName
());
this
.
support
.
configureManifest
(
this
,
getMainClassName
(),
"BOOT-INF/classes/"
,
"BOOT-INF/lib/"
);
super
.
copy
();
super
.
copy
();
}
}
...
...
spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/BootWar.java
View file @
7b5f46d6
/*
/*
* Copyright 2012-201
8
the original author or authors.
* Copyright 2012-201
9
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.
...
@@ -57,7 +57,8 @@ public class BootWar extends War implements BootArchive {
...
@@ -57,7 +57,8 @@ public class BootWar extends War implements BootArchive {
@Override
@Override
public
void
copy
()
{
public
void
copy
()
{
this
.
support
.
configureManifest
(
this
,
getMainClassName
());
this
.
support
.
configureManifest
(
this
,
getMainClassName
(),
"WEB-INF/classes/"
,
"WEB-INF/lib/"
);
super
.
copy
();
super
.
copy
();
}
}
...
...
spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/AbstractBootArchiveTests.java
View file @
7b5f46d6
/*
/*
* Copyright 2012-201
8
the original author or authors.
* Copyright 2012-201
9
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.
...
@@ -97,6 +97,13 @@ public abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
...
@@ -97,6 +97,13 @@ public abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
.
isEqualTo
(
this
.
launcherClass
);
.
isEqualTo
(
this
.
launcherClass
);
assertThat
(
jarFile
.
getManifest
().
getMainAttributes
().
getValue
(
"Start-Class"
))
assertThat
(
jarFile
.
getManifest
().
getMainAttributes
().
getValue
(
"Start-Class"
))
.
isEqualTo
(
"com.example.Main"
);
.
isEqualTo
(
"com.example.Main"
);
assertThat
(
jarFile
.
getManifest
().
getMainAttributes
()
.
getValue
(
"Spring-Boot-Classes"
)).
isEqualTo
(
this
.
classesPath
);
assertThat
(
jarFile
.
getManifest
().
getMainAttributes
().
getValue
(
"Spring-Boot-Lib"
))
.
isEqualTo
(
this
.
libPath
);
assertThat
(
jarFile
.
getManifest
().
getMainAttributes
()
.
getValue
(
"Spring-Boot-Version"
)).
isNotNull
();
}
}
}
}
...
@@ -106,8 +113,8 @@ public abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
...
@@ -106,8 +113,8 @@ public abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
this
.
task
.
classpath
(
this
.
temp
.
newFile
(
"one.jar"
),
this
.
temp
.
newFile
(
"two.jar"
));
this
.
task
.
classpath
(
this
.
temp
.
newFile
(
"one.jar"
),
this
.
temp
.
newFile
(
"two.jar"
));
this
.
task
.
execute
();
this
.
task
.
execute
();
try
(
JarFile
jarFile
=
new
JarFile
(
this
.
task
.
getArchivePath
()))
{
try
(
JarFile
jarFile
=
new
JarFile
(
this
.
task
.
getArchivePath
()))
{
assertThat
(
jarFile
.
getEntry
(
this
.
libPath
+
"
/
one.jar"
)).
isNotNull
();
assertThat
(
jarFile
.
getEntry
(
this
.
libPath
+
"one.jar"
)).
isNotNull
();
assertThat
(
jarFile
.
getEntry
(
this
.
libPath
+
"
/
two.jar"
)).
isNotNull
();
assertThat
(
jarFile
.
getEntry
(
this
.
libPath
+
"two.jar"
)).
isNotNull
();
}
}
}
}
...
@@ -123,7 +130,7 @@ public abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
...
@@ -123,7 +130,7 @@ public abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
this
.
task
.
execute
();
this
.
task
.
execute
();
try
(
JarFile
jarFile
=
new
JarFile
(
this
.
task
.
getArchivePath
()))
{
try
(
JarFile
jarFile
=
new
JarFile
(
this
.
task
.
getArchivePath
()))
{
assertThat
(
assertThat
(
jarFile
.
getEntry
(
this
.
classesPath
+
"
/
com/example/Application.class"
))
jarFile
.
getEntry
(
this
.
classesPath
+
"com/example/Application.class"
))
.
isNotNull
();
.
isNotNull
();
}
}
}
}
...
@@ -136,8 +143,8 @@ public abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
...
@@ -136,8 +143,8 @@ public abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
.
setClasspath
(
this
.
task
.
getProject
().
files
(
this
.
temp
.
newFile
(
"two.jar"
)));
.
setClasspath
(
this
.
task
.
getProject
().
files
(
this
.
temp
.
newFile
(
"two.jar"
)));
this
.
task
.
execute
();
this
.
task
.
execute
();
try
(
JarFile
jarFile
=
new
JarFile
(
this
.
task
.
getArchivePath
()))
{
try
(
JarFile
jarFile
=
new
JarFile
(
this
.
task
.
getArchivePath
()))
{
assertThat
(
jarFile
.
getEntry
(
this
.
libPath
+
"
/
one.jar"
)).
isNull
();
assertThat
(
jarFile
.
getEntry
(
this
.
libPath
+
"one.jar"
)).
isNull
();
assertThat
(
jarFile
.
getEntry
(
this
.
libPath
+
"
/
two.jar"
)).
isNotNull
();
assertThat
(
jarFile
.
getEntry
(
this
.
libPath
+
"two.jar"
)).
isNotNull
();
}
}
}
}
...
@@ -148,8 +155,8 @@ public abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
...
@@ -148,8 +155,8 @@ public abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
this
.
task
.
setClasspath
(
this
.
temp
.
newFile
(
"two.jar"
));
this
.
task
.
setClasspath
(
this
.
temp
.
newFile
(
"two.jar"
));
this
.
task
.
execute
();
this
.
task
.
execute
();
try
(
JarFile
jarFile
=
new
JarFile
(
this
.
task
.
getArchivePath
()))
{
try
(
JarFile
jarFile
=
new
JarFile
(
this
.
task
.
getArchivePath
()))
{
assertThat
(
jarFile
.
getEntry
(
this
.
libPath
+
"
/
one.jar"
)).
isNull
();
assertThat
(
jarFile
.
getEntry
(
this
.
libPath
+
"one.jar"
)).
isNull
();
assertThat
(
jarFile
.
getEntry
(
this
.
libPath
+
"
/
two.jar"
)).
isNotNull
();
assertThat
(
jarFile
.
getEntry
(
this
.
libPath
+
"two.jar"
)).
isNotNull
();
}
}
}
}
...
@@ -187,9 +194,9 @@ public abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
...
@@ -187,9 +194,9 @@ public abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
this
.
task
.
requiresUnpack
(
"**/one.jar"
);
this
.
task
.
requiresUnpack
(
"**/one.jar"
);
this
.
task
.
execute
();
this
.
task
.
execute
();
try
(
JarFile
jarFile
=
new
JarFile
(
this
.
task
.
getArchivePath
()))
{
try
(
JarFile
jarFile
=
new
JarFile
(
this
.
task
.
getArchivePath
()))
{
assertThat
(
jarFile
.
getEntry
(
this
.
libPath
+
"
/
one.jar"
).
getComment
())
assertThat
(
jarFile
.
getEntry
(
this
.
libPath
+
"one.jar"
).
getComment
())
.
startsWith
(
"UNPACK:"
);
.
startsWith
(
"UNPACK:"
);
assertThat
(
jarFile
.
getEntry
(
this
.
libPath
+
"
/
two.jar"
).
getComment
()).
isNull
();
assertThat
(
jarFile
.
getEntry
(
this
.
libPath
+
"two.jar"
).
getComment
()).
isNull
();
}
}
}
}
...
@@ -200,9 +207,9 @@ public abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
...
@@ -200,9 +207,9 @@ public abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
this
.
task
.
requiresUnpack
((
element
)
->
element
.
getName
().
endsWith
(
"two.jar"
));
this
.
task
.
requiresUnpack
((
element
)
->
element
.
getName
().
endsWith
(
"two.jar"
));
this
.
task
.
execute
();
this
.
task
.
execute
();
try
(
JarFile
jarFile
=
new
JarFile
(
this
.
task
.
getArchivePath
()))
{
try
(
JarFile
jarFile
=
new
JarFile
(
this
.
task
.
getArchivePath
()))
{
assertThat
(
jarFile
.
getEntry
(
this
.
libPath
+
"
/
two.jar"
).
getComment
())
assertThat
(
jarFile
.
getEntry
(
this
.
libPath
+
"two.jar"
).
getComment
())
.
startsWith
(
"UNPACK:"
);
.
startsWith
(
"UNPACK:"
);
assertThat
(
jarFile
.
getEntry
(
this
.
libPath
+
"
/
one.jar"
).
getComment
()).
isNull
();
assertThat
(
jarFile
.
getEntry
(
this
.
libPath
+
"one.jar"
).
getComment
()).
isNull
();
}
}
}
}
...
@@ -322,7 +329,7 @@ public abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
...
@@ -322,7 +329,7 @@ public abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
this
.
task
.
execute
();
this
.
task
.
execute
();
assertThat
(
this
.
task
.
getArchivePath
()).
exists
();
assertThat
(
this
.
task
.
getArchivePath
()).
exists
();
try
(
JarFile
jarFile
=
new
JarFile
(
this
.
task
.
getArchivePath
()))
{
try
(
JarFile
jarFile
=
new
JarFile
(
this
.
task
.
getArchivePath
()))
{
assertThat
(
jarFile
.
getEntry
(
this
.
libPath
+
"
/
spring-boot-devtools-0.1.2.jar"
))
assertThat
(
jarFile
.
getEntry
(
this
.
libPath
+
"spring-boot-devtools-0.1.2.jar"
))
.
isNull
();
.
isNull
();
}
}
}
}
...
@@ -335,7 +342,7 @@ public abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
...
@@ -335,7 +342,7 @@ public abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
this
.
task
.
execute
();
this
.
task
.
execute
();
assertThat
(
this
.
task
.
getArchivePath
()).
exists
();
assertThat
(
this
.
task
.
getArchivePath
()).
exists
();
try
(
JarFile
jarFile
=
new
JarFile
(
this
.
task
.
getArchivePath
()))
{
try
(
JarFile
jarFile
=
new
JarFile
(
this
.
task
.
getArchivePath
()))
{
assertThat
(
jarFile
.
getEntry
(
this
.
libPath
+
"
/
spring-boot-devtools-0.1.2.jar"
))
assertThat
(
jarFile
.
getEntry
(
this
.
libPath
+
"spring-boot-devtools-0.1.2.jar"
))
.
isNotNull
();
.
isNotNull
();
}
}
}
}
...
@@ -377,9 +384,9 @@ public abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
...
@@ -377,9 +384,9 @@ public abstract class AbstractBootArchiveTests<T extends Jar & BootArchive> {
this
.
task
.
execute
();
this
.
task
.
execute
();
assertThat
(
getEntryNames
(
this
.
task
.
getArchivePath
())).
containsSubsequence
(
assertThat
(
getEntryNames
(
this
.
task
.
getArchivePath
())).
containsSubsequence
(
"org/springframework/boot/loader/"
,
"org/springframework/boot/loader/"
,
this
.
classesPath
+
"
/
com/example/Application.class"
,
this
.
classesPath
+
"com/example/Application.class"
,
this
.
libPath
+
"
/first-library.jar"
,
this
.
libPath
+
"/
second-library.jar"
,
this
.
libPath
+
"
first-library.jar"
,
this
.
libPath
+
"
second-library.jar"
,
this
.
libPath
+
"
/
third-library.jar"
);
this
.
libPath
+
"third-library.jar"
);
}
}
private
T
configure
(
T
task
)
throws
IOException
{
private
T
configure
(
T
task
)
throws
IOException
{
...
...
spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/BootJarTests.java
View file @
7b5f46d6
/*
/*
* Copyright 2012-201
8
the original author or authors.
* Copyright 2012-201
9
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.
...
@@ -33,7 +33,7 @@ public class BootJarTests extends AbstractBootArchiveTests<BootJar> {
...
@@ -33,7 +33,7 @@ public class BootJarTests extends AbstractBootArchiveTests<BootJar> {
public
BootJarTests
()
{
public
BootJarTests
()
{
super
(
BootJar
.
class
,
"org.springframework.boot.loader.JarLauncher"
,
super
(
BootJar
.
class
,
"org.springframework.boot.loader.JarLauncher"
,
"BOOT-INF/lib
"
,
"BOOT-INF/classes
"
);
"BOOT-INF/lib
/"
,
"BOOT-INF/classes/
"
);
}
}
@Test
@Test
...
...
spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/BootWarTests.java
View file @
7b5f46d6
/*
/*
* Copyright 2012-201
8
the original author or authors.
* Copyright 2012-201
9
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.
...
@@ -32,8 +32,8 @@ import static org.assertj.core.api.Assertions.assertThat;
...
@@ -32,8 +32,8 @@ import static org.assertj.core.api.Assertions.assertThat;
public
class
BootWarTests
extends
AbstractBootArchiveTests
<
BootWar
>
{
public
class
BootWarTests
extends
AbstractBootArchiveTests
<
BootWar
>
{
public
BootWarTests
()
{
public
BootWarTests
()
{
super
(
BootWar
.
class
,
"org.springframework.boot.loader.WarLauncher"
,
"WEB-INF/lib"
,
super
(
BootWar
.
class
,
"org.springframework.boot.loader.WarLauncher"
,
"WEB-INF/
classes
"
);
"WEB-INF/
lib/"
,
"WEB-INF/classes/
"
);
}
}
@Test
@Test
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment