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
54b3f480
Commit
54b3f480
authored
Jan 30, 2020
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use posix long names when creating tar archive for image building
Fixes gh-19964
parent
02d095d7
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
50 additions
and
1 deletion
+50
-1
TarLayoutWriter.java
...framework/boot/buildpack/platform/io/TarLayoutWriter.java
+1
-0
ZipFileTarArchive.java
...amework/boot/buildpack/platform/io/ZipFileTarArchive.java
+1
-0
BootBuildImageIntegrationTests.java
...gradle/tasks/bundling/BootBuildImageIntegrationTests.java
+19
-0
BuildImageTests.java
.../java/org/springframework/boot/maven/BuildImageTests.java
+18
-1
MavenBuild.java
...tTest/java/org/springframework/boot/maven/MavenBuild.java
+10
-0
BuildImageMojo.java
...n/java/org/springframework/boot/maven/BuildImageMojo.java
+1
-0
No files found.
spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/io/TarLayoutWriter.java
View file @
54b3f480
...
...
@@ -39,6 +39,7 @@ class TarLayoutWriter implements Layout, Closeable {
TarLayoutWriter
(
OutputStream
outputStream
)
{
this
.
outputStream
=
new
TarArchiveOutputStream
(
outputStream
);
this
.
outputStream
.
setLongFileMode
(
TarArchiveOutputStream
.
LONGFILE_POSIX
);
}
@Override
...
...
spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/io/ZipFileTarArchive.java
View file @
54b3f480
...
...
@@ -61,6 +61,7 @@ public class ZipFileTarArchive implements TarArchive {
@Override
public
void
writeTo
(
OutputStream
outputStream
)
throws
IOException
{
TarArchiveOutputStream
tar
=
new
TarArchiveOutputStream
(
outputStream
);
tar
.
setLongFileMode
(
TarArchiveOutputStream
.
LONGFILE_POSIX
);
try
(
ZipFile
zipFile
=
new
ZipFile
(
this
.
zip
))
{
Enumeration
<
ZipArchiveEntry
>
entries
=
zipFile
.
getEntries
();
while
(
entries
.
hasMoreElements
())
{
...
...
spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/BootBuildImageIntegrationTests.java
View file @
54b3f480
...
...
@@ -20,6 +20,10 @@ import java.io.File;
import
java.io.FileWriter
;
import
java.io.IOException
;
import
java.io.PrintWriter
;
import
java.nio.file.Files
;
import
java.nio.file.Path
;
import
java.nio.file.Paths
;
import
java.util.Random
;
import
org.gradle.testkit.runner.BuildResult
;
import
org.gradle.testkit.runner.TaskOutcome
;
...
...
@@ -51,6 +55,7 @@ class BootBuildImageIntegrationTests {
@TestTemplate
void
bootBuildImageBuildsImage
()
throws
IOException
{
writeMainClass
();
writeLongNameResource
();
BuildResult
result
=
this
.
gradleBuild
.
build
(
"bootBuildImage"
);
assertThat
(
result
.
task
(
":bootBuildImage"
).
getOutcome
()).
isEqualTo
(
TaskOutcome
.
SUCCESS
);
ImageReference
imageReference
=
ImageReference
.
of
(
ImageName
.
of
(
this
.
gradleBuild
.
getProjectDir
().
getName
()));
...
...
@@ -87,4 +92,18 @@ class BootBuildImageIntegrationTests {
}
}
private
void
writeLongNameResource
()
{
StringBuilder
name
=
new
StringBuilder
();
new
Random
().
ints
(
'a'
,
'z'
+
1
).
limit
(
128
).
forEach
((
i
)
->
name
.
append
((
char
)
i
));
try
{
Path
path
=
this
.
gradleBuild
.
getProjectDir
().
toPath
()
.
resolve
(
Paths
.
get
(
"src"
,
"main"
,
"resources"
,
name
.
toString
()));
Files
.
createDirectories
(
path
.
getParent
());
Files
.
createFile
(
path
);
}
catch
(
IOException
ex
)
{
throw
new
RuntimeException
(
ex
);
}
}
}
spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/java/org/springframework/boot/maven/BuildImageTests.java
View file @
54b3f480
...
...
@@ -18,6 +18,10 @@ package org.springframework.boot.maven;
import
java.io.File
;
import
java.io.IOException
;
import
java.nio.file.Files
;
import
java.nio.file.Path
;
import
java.nio.file.Paths
;
import
java.util.Random
;
import
org.junit.jupiter.api.TestTemplate
;
import
org.junit.jupiter.api.extension.ExtendWith
;
...
...
@@ -42,7 +46,7 @@ public class BuildImageTests extends AbstractArchiveIntegrationTests {
@TestTemplate
void
whenBuildImageIsInvokedWithoutRepackageTheArchiveIsRepackagedOnTheFly
(
MavenBuild
mavenBuild
)
{
mavenBuild
.
project
(
"build-image"
).
goals
(
"package"
).
execute
((
project
)
->
{
mavenBuild
.
project
(
"build-image"
).
goals
(
"package"
).
prepare
(
this
::
writeLongNameResource
).
execute
((
project
)
->
{
File
jar
=
new
File
(
project
,
"target/build-image-0.0.1.BUILD-SNAPSHOT.jar"
);
assertThat
(
jar
).
isFile
();
File
original
=
new
File
(
project
,
"target/build-image-0.0.1.BUILD-SNAPSHOT.jar.original"
);
...
...
@@ -79,6 +83,19 @@ public class BuildImageTests extends AbstractArchiveIntegrationTests {
});
}
private
void
writeLongNameResource
(
File
project
)
{
StringBuilder
name
=
new
StringBuilder
();
new
Random
().
ints
(
'a'
,
'z'
+
1
).
limit
(
128
).
forEach
((
i
)
->
name
.
append
((
char
)
i
));
try
{
Path
path
=
project
.
toPath
().
resolve
(
Paths
.
get
(
"src"
,
"main"
,
"resources"
,
name
.
toString
()));
Files
.
createDirectories
(
path
.
getParent
());
Files
.
createFile
(
path
);
}
catch
(
IOException
ex
)
{
throw
new
RuntimeException
(
ex
);
}
}
private
void
removeImage
(
ImageReference
imageReference
)
{
try
{
new
DockerApi
().
image
().
remove
(
imageReference
,
false
);
...
...
spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/intTest/java/org/springframework/boot/maven/MavenBuild.java
View file @
54b3f480
...
...
@@ -70,6 +70,8 @@ class MavenBuild {
private
final
Properties
properties
=
new
Properties
();
private
Consumer
<
File
>
preparation
;
private
File
projectDir
;
MavenBuild
(
File
home
)
{
...
...
@@ -109,6 +111,11 @@ class MavenBuild {
return
this
;
}
MavenBuild
prepare
(
Consumer
<
File
>
callback
)
{
this
.
preparation
=
callback
;
return
this
;
}
void
execute
(
Consumer
<
File
>
callback
)
{
Invoker
invoker
=
new
DefaultInvoker
();
invoker
.
setMavenHome
(
this
.
home
);
...
...
@@ -158,6 +165,9 @@ class MavenBuild {
request
.
setBatchMode
(
true
);
File
target
=
new
File
(
this
.
temp
,
"target"
);
target
.
mkdirs
();
if
(
this
.
preparation
!=
null
)
{
this
.
preparation
.
accept
(
this
.
temp
);
}
File
buildLogFile
=
new
File
(
target
,
"build.log"
);
try
(
PrintWriter
buildLog
=
new
PrintWriter
(
new
FileWriter
(
buildLogFile
)))
{
request
.
setOutputHandler
(
new
InvocationOutputHandler
()
{
...
...
spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/BuildImageMojo.java
View file @
54b3f480
...
...
@@ -215,6 +215,7 @@ public class BuildImageMojo extends AbstractPackagerMojo {
@Override
public
void
writeTo
(
OutputStream
outputStream
)
throws
IOException
{
TarArchiveOutputStream
tar
=
new
TarArchiveOutputStream
(
outputStream
);
tar
.
setLongFileMode
(
TarArchiveOutputStream
.
LONGFILE_POSIX
);
this
.
packager
.
packageImage
(
this
.
libraries
,
(
entry
,
entryWriter
)
->
write
(
entry
,
entryWriter
,
tar
));
}
...
...
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