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
9eb5c9bd
Commit
9eb5c9bd
authored
Jul 09, 2018
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '1.5.x' into 2.0.x
parents
44ebeb8a
a50646b7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
3 deletions
+31
-3
JarWriter.java
...java/org/springframework/boot/loader/tools/JarWriter.java
+5
-3
RepackagerTests.java
...rg/springframework/boot/loader/tools/RepackagerTests.java
+26
-0
No files found.
spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/JarWriter.java
View file @
9eb5c9bd
...
...
@@ -134,7 +134,7 @@ public class JarWriter implements LoaderClassesWriter, AutoCloseable {
Enumeration
<
JarEntry
>
entries
=
jarFile
.
entries
();
while
(
entries
.
hasMoreElements
())
{
JarArchiveEntry
entry
=
new
JarArchiveEntry
(
entries
.
nextElement
());
setUp
StoredEntryIfNecessa
ry
(
jarFile
,
entry
);
setUp
Ent
ry
(
jarFile
,
entry
);
try
(
ZipHeaderPeekInputStream
inputStream
=
new
ZipHeaderPeekInputStream
(
jarFile
.
getInputStream
(
entry
)))
{
EntryWriter
entryWriter
=
new
InputStreamEntryWriter
(
inputStream
,
true
);
...
...
@@ -146,13 +146,15 @@ public class JarWriter implements LoaderClassesWriter, AutoCloseable {
}
}
private
void
setUpStoredEntryIfNecessary
(
JarFile
jarFile
,
JarArchiveEntry
entry
)
throws
IOException
{
private
void
setUpEntry
(
JarFile
jarFile
,
JarArchiveEntry
entry
)
throws
IOException
{
try
(
ZipHeaderPeekInputStream
inputStream
=
new
ZipHeaderPeekInputStream
(
jarFile
.
getInputStream
(
entry
)))
{
if
(
inputStream
.
hasZipHeader
()
&&
entry
.
getMethod
()
!=
ZipEntry
.
STORED
)
{
new
CrcAndSize
(
inputStream
).
setupStoredEntry
(
entry
);
}
else
{
entry
.
setCompressedSize
(-
1
);
}
}
}
...
...
spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/test/java/org/springframework/boot/loader/tools/RepackagerTests.java
View file @
9eb5c9bd
...
...
@@ -18,6 +18,7 @@ package org.springframework.boot.loader.tools;
import
java.io.ByteArrayInputStream
;
import
java.io.File
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.nio.file.Files
;
import
java.nio.file.attribute.PosixFilePermission
;
...
...
@@ -25,11 +26,14 @@ import java.util.ArrayList;
import
java.util.Calendar
;
import
java.util.Enumeration
;
import
java.util.List
;
import
java.util.Random
;
import
java.util.jar.Attributes
;
import
java.util.jar.JarEntry
;
import
java.util.jar.JarFile
;
import
java.util.jar.Manifest
;
import
java.util.zip.Deflater
;
import
java.util.zip.ZipEntry
;
import
java.util.zip.ZipOutputStream
;
import
org.apache.commons.compress.archivers.zip.ZipArchiveEntry
;
import
org.apache.commons.compress.archivers.zip.ZipFile
;
...
...
@@ -638,6 +642,28 @@ public class RepackagerTests {
"META-INF/MANIFEST.MF"
,
"a/"
,
"a/b/"
,
"a/b/C.class"
);
}
@Test
public
void
jarThatUsesCustomCompressionConfigurationCanBeRepackaged
()
throws
IOException
{
File
source
=
this
.
temporaryFolder
.
newFile
(
"source.jar"
);
ZipOutputStream
output
=
new
ZipOutputStream
(
new
FileOutputStream
(
source
))
{
{
this
.
def
=
new
Deflater
(
Deflater
.
NO_COMPRESSION
,
true
);
}
};
byte
[]
data
=
new
byte
[
1024
*
1024
];
new
Random
().
nextBytes
(
data
);
ZipEntry
entry
=
new
ZipEntry
(
"entry.dat"
);
output
.
putNextEntry
(
entry
);
output
.
write
(
data
);
output
.
closeEntry
();
output
.
close
();
File
dest
=
this
.
temporaryFolder
.
newFile
(
"dest.jar"
);
Repackager
repackager
=
new
Repackager
(
source
);
repackager
.
setMainClass
(
"com.example.Main"
);
repackager
.
repackage
(
dest
,
NO_LIBRARIES
);
}
private
File
createLibrary
()
throws
IOException
{
TestJarFile
library
=
new
TestJarFile
(
this
.
temporaryFolder
);
library
.
addClass
(
"com/example/library/Library.class"
,
...
...
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