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
de1e3c60
Commit
de1e3c60
authored
May 04, 2020
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Include empty layers when listing and extracting
Fixes gh-21301
parent
5d7df790
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
12 additions
and
9 deletions
+12
-9
IndexedLayers.java
...pringframework/boot/jarmode/layertools/IndexedLayers.java
+7
-6
ExtractCommandTests.java
...ramework/boot/jarmode/layertools/ExtractCommandTests.java
+3
-2
IndexedLayersTests.java
...framework/boot/jarmode/layertools/IndexedLayersTests.java
+1
-1
test-layers.idx
...g/springframework/boot/jarmode/layertools/test-layers.idx
+1
-0
No files found.
spring-boot-project/spring-boot-tools/spring-boot-jarmode-layertools/src/main/java/org/springframework/boot/jarmode/layertools/IndexedLayers.java
View file @
de1e3c60
...
...
@@ -20,16 +20,16 @@ import java.io.FileNotFoundException;
import
java.io.IOException
;
import
java.nio.charset.StandardCharsets
;
import
java.nio.file.NoSuchFileException
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Iterator
;
import
java.util.LinkedHashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.jar.JarFile
;
import
java.util.zip.ZipEntry
;
import
org.springframework.util.Assert
;
import
org.springframework.util.LinkedMultiValueMap
;
import
org.springframework.util.MultiValueMap
;
import
org.springframework.util.StreamUtils
;
import
org.springframework.util.StringUtils
;
...
...
@@ -41,18 +41,19 @@ import org.springframework.util.StringUtils;
*/
class
IndexedLayers
implements
Layers
{
private
MultiValueMap
<
String
,
String
>
layers
=
new
LinkedMultiValue
Map
<>();
private
final
Map
<
String
,
List
<
String
>>
layers
=
new
LinkedHash
Map
<>();
IndexedLayers
(
String
indexFile
)
{
String
[]
lines
=
Arrays
.
stream
(
indexFile
.
split
(
"\n"
)).
map
((
line
)
->
line
.
replace
(
"\r"
,
""
))
.
filter
(
StringUtils:
:
hasText
).
toArray
(
String
[]::
new
);
String
layer
=
null
;
List
<
String
>
contents
=
null
;
for
(
String
line
:
lines
)
{
if
(
line
.
startsWith
(
"- "
))
{
layer
=
line
.
substring
(
3
,
line
.
length
()
-
2
);
contents
=
new
ArrayList
<>();
this
.
layers
.
put
(
line
.
substring
(
3
,
line
.
length
()
-
2
),
contents
);
}
else
if
(
line
.
startsWith
(
" - "
))
{
this
.
layers
.
add
(
layer
,
line
.
substring
(
5
,
line
.
length
()
-
1
));
contents
.
add
(
line
.
substring
(
5
,
line
.
length
()
-
1
));
}
else
{
throw
new
IllegalStateException
(
"Layer index file is malformed"
);
...
...
spring-boot-project/spring-boot-tools/spring-boot-jarmode-layertools/src/test/java/org/springframework/boot/jarmode/layertools/ExtractCommandTests.java
View file @
de1e3c60
...
...
@@ -69,10 +69,11 @@ class ExtractCommandTests {
@Test
void
runExtractsLayers
()
throws
Exception
{
this
.
command
.
run
(
Collections
.
emptyMap
(),
Collections
.
emptyList
());
assertThat
(
this
.
extract
.
list
()).
containsOnly
(
"a"
,
"b"
,
"c"
);
assertThat
(
this
.
extract
.
list
()).
containsOnly
(
"a"
,
"b"
,
"c"
,
"d"
);
assertThat
(
new
File
(
this
.
extract
,
"a/a/a.jar"
)).
exists
();
assertThat
(
new
File
(
this
.
extract
,
"b/b/b.jar"
)).
exists
();
assertThat
(
new
File
(
this
.
extract
,
"c/c/c.jar"
)).
exists
();
assertThat
(
new
File
(
this
.
extract
,
"d"
)).
isDirectory
();
}
@Test
...
...
@@ -119,7 +120,7 @@ class ExtractCommandTests {
@Override
public
Iterator
<
String
>
iterator
()
{
return
Arrays
.
asList
(
"a"
,
"b"
,
"c"
).
iterator
();
return
Arrays
.
asList
(
"a"
,
"b"
,
"c"
,
"d"
).
iterator
();
}
@Override
...
...
spring-boot-project/spring-boot-tools/spring-boot-jarmode-layertools/src/test/java/org/springframework/boot/jarmode/layertools/IndexedLayersTests.java
View file @
de1e3c60
...
...
@@ -52,7 +52,7 @@ class IndexedLayersTests {
@Test
void
iteratorReturnsLayers
()
throws
Exception
{
IndexedLayers
layers
=
new
IndexedLayers
(
getIndex
());
assertThat
(
layers
).
containsExactly
(
"test"
,
"application"
);
assertThat
(
layers
).
containsExactly
(
"test"
,
"
empty"
,
"
application"
);
}
@Test
...
...
spring-boot-project/spring-boot-tools/spring-boot-jarmode-layertools/src/test/resources/org/springframework/boot/jarmode/layertools/test-layers.idx
View file @
de1e3c60
- "test":
- "BOOT-INF/lib/a.jar"
- "BOOT-INF/lib/b.jar"
- "empty":
- "application":
- "BOOT-INF/classes/Demo.class"
- "META-INF/"
...
...
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