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
01a0a54f
Commit
01a0a54f
authored
Jan 23, 2020
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Include layertools in layered jars build with Gradle
Closes gh-19867
parent
288f5cea
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
0 deletions
+18
-0
BootJar.java
...g/springframework/boot/gradle/tasks/bundling/BootJar.java
+12
-0
BootJarTests.java
...ingframework/boot/gradle/tasks/bundling/BootJarTests.java
+6
-0
No files found.
spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/BootJar.java
View file @
01a0a54f
...
...
@@ -18,7 +18,9 @@ package org.springframework.boot.gradle.tasks.bundling;
import
java.io.BufferedWriter
;
import
java.io.File
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.StringWriter
;
import
java.util.ArrayList
;
import
java.util.Collections
;
...
...
@@ -43,6 +45,7 @@ import org.gradle.api.tasks.bundling.Jar;
import
org.springframework.boot.loader.tools.Layer
;
import
org.springframework.boot.loader.tools.Layers
;
import
org.springframework.boot.loader.tools.Library
;
import
org.springframework.util.FileCopyUtils
;
/**
* A custom {@link Jar} task that produces a Spring Boot executable jar.
...
...
@@ -177,6 +180,15 @@ public class BootJar extends Jar implements BootArchive {
*/
public
void
layered
()
{
this
.
layers
=
Layers
.
IMPLICIT
;
this
.
bootInf
.
into
(
"lib"
,
(
spec
)
->
spec
.
from
((
Callable
<
File
>)
()
->
{
String
jarName
=
"spring-boot-jarmode-layertools.jar"
;
InputStream
stream
=
getClass
().
getClassLoader
().
getResourceAsStream
(
"META-INF/jarmode/"
+
jarName
);
File
taskTmp
=
new
File
(
getProject
().
getBuildDir
(),
"tmp/"
+
getName
());
taskTmp
.
mkdirs
();
File
layerToolsJar
=
new
File
(
taskTmp
,
jarName
);
FileCopyUtils
.
copy
(
stream
,
new
FileOutputStream
(
layerToolsJar
));
return
layerToolsJar
;
}));
this
.
bootInf
.
eachFile
((
details
)
->
{
Layer
layer
=
layerForFileDetails
(
details
);
if
(
layer
!=
null
)
{
...
...
spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/BootJarTests.java
View file @
01a0a54f
...
...
@@ -123,6 +123,12 @@ class BootJarTests extends AbstractBootArchiveTests<BootJar> {
}
}
@Test
void
whenJarIsLayeredThenLayerToolsAreAddedToTheJar
()
throws
IOException
{
List
<
String
>
entryNames
=
getEntryNames
(
createLayeredJar
());
assertThat
(
entryNames
).
contains
(
"BOOT-INF/layers/dependencies/lib/spring-boot-jarmode-layertools.jar"
);
}
@Test
void
classpathIndexPointsToBootInfLibs
()
throws
IOException
{
try
(
JarFile
jarFile
=
new
JarFile
(
createPopulatedJar
()))
{
...
...
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