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
ce740478
Commit
ce740478
authored
May 03, 2017
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '1.4.x' into 1.5.x
parents
51970f81
2f260888
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
11 deletions
+33
-11
CommandLineInvoker.java
...framework/boot/cli/infrastructure/CommandLineInvoker.java
+33
-11
No files found.
spring-boot-cli/src/it/java/org/springframework/boot/cli/infrastructure/CommandLineInvoker.java
View file @
ce740478
...
...
@@ -19,6 +19,8 @@ package org.springframework.boot.cli.infrastructure;
import
java.io.BufferedReader
;
import
java.io.File
;
import
java.io.FileFilter
;
import
java.io.FileInputStream
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.PrintWriter
;
...
...
@@ -27,8 +29,11 @@ import java.io.StringWriter;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.zip.ZipEntry
;
import
java.util.zip.ZipInputStream
;
import
org.springframework.util.Assert
;
import
org.springframework.util.StreamUtils
;
/**
* Utility to invoke the command line in the same way as a user would, i.e. via the shell
...
...
@@ -63,18 +68,35 @@ public final class CommandLineInvoker {
return
processBuilder
.
start
();
}
private
File
findLaunchScript
()
{
File
dir
=
new
File
(
"target"
);
dir
=
dir
.
listFiles
(
new
FileFilter
()
{
@Override
public
boolean
accept
(
File
pathname
)
{
return
pathname
.
isDirectory
()
&&
pathname
.
getName
().
contains
(
"-bin"
);
private
File
findLaunchScript
()
throws
IOException
{
File
unpacked
=
new
File
(
"target/unpacked-cli"
);
if
(!
unpacked
.
isDirectory
())
{
File
zip
=
new
File
(
"target"
).
listFiles
(
new
FileFilter
()
{
@Override
public
boolean
accept
(
File
pathname
)
{
return
pathname
.
getName
().
endsWith
(
"-bin.zip"
);
}
})[
0
];
ZipInputStream
input
=
new
ZipInputStream
(
new
FileInputStream
(
zip
));
ZipEntry
entry
;
while
((
entry
=
input
.
getNextEntry
())
!=
null
)
{
File
file
=
new
File
(
unpacked
,
entry
.
getName
());
if
(
entry
.
isDirectory
())
{
file
.
mkdirs
();
}
else
{
file
.
getParentFile
().
mkdirs
();
StreamUtils
.
copy
(
input
,
new
FileOutputStream
(
file
));
if
(
entry
.
getName
().
endsWith
(
"/bin/spring"
))
{
file
.
setExecutable
(
true
);
}
}
}
})[
0
];
dir
=
new
File
(
dir
,
dir
.
getName
().
replace
(
"-bin"
,
""
).
replace
(
"spring-boot-cli"
,
"spring"
));
dir
=
new
File
(
dir
,
"bin"
);
File
launchScript
=
new
File
(
dir
,
isWindows
()
?
"spring.bat"
:
"spring"
);
}
File
bin
=
new
File
(
unpacked
.
listFiles
()[
0
],
"bin"
);
File
launchScript
=
new
File
(
bin
,
isWindows
()
?
"spring.bat"
:
"spring"
);
Assert
.
state
(
launchScript
.
exists
()
&&
launchScript
.
isFile
(),
"Could not find CLI launch script "
+
launchScript
.
getAbsolutePath
());
return
launchScript
;
...
...
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