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
2d75cc79
Commit
2d75cc79
authored
Oct 05, 2016
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish contribution
Closes gh-6367
parent
d07f6894
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
31 additions
and
45 deletions
+31
-45
JarCommandIT.java
...rc/it/java/org/springframework/boot/cli/JarCommandIT.java
+10
-5
WarCommandIT.java
...rc/it/java/org/springframework/boot/cli/WarCommandIT.java
+4
-23
jar.groovy
spring-boot-cli/src/it/resources/jar-command/jar.groovy
+1
-0
root.properties
spring-boot-cli/src/it/resources/jar-command/root.properties
+0
-0
root.properties
spring-boot-cli/src/it/resources/war-command/root.properties
+0
-0
war.groovy
spring-boot-cli/src/it/resources/war-command/war.groovy
+1
-0
ArchiveCommand.java
...ingframework/boot/cli/command/archive/ArchiveCommand.java
+12
-4
JarCommand.java
.../springframework/boot/cli/command/archive/JarCommand.java
+0
-11
WarCommand.java
.../springframework/boot/cli/command/archive/WarCommand.java
+3
-2
No files found.
spring-boot-cli/src/it/java/org/springframework/boot/cli/JarCommandIT.java
View file @
2d75cc79
/*
* Copyright 2012-201
4
the original author or authors.
* Copyright 2012-201
6
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -36,6 +36,7 @@ import static org.junit.Assert.assertTrue;
* Integration test for {@link JarCommand}.
*
* @author Andy Wilkinson
* @author Stephane Nicoll
*/
public
class
JarCommandIT
{
...
...
@@ -98,12 +99,16 @@ public class JarCommandIT {
assertThat
(
invocation
.
getErrorOutput
(),
equalTo
(
""
));
assertThat
(
invocation
.
getStandardOutput
(),
containsString
(
"Hello World!"
));
assertThat
(
invocation
.
getStandardOutput
(),
containsString
(
"/public/public.txt"
));
assertThat
(
invocation
.
getStandardOutput
(),
containsString
(
"/resources/resource.txt"
));
assertThat
(
invocation
.
getStandardOutput
(),
containsString
(
"/static/static.txt"
));
containsString
(
"/BOOT-INF/classes!/public/public.txt"
));
assertThat
(
invocation
.
getStandardOutput
(),
containsString
(
"/templates/template.txt"
));
containsString
(
"/BOOT-INF/classes!/resources/resource.txt"
));
assertThat
(
invocation
.
getStandardOutput
(),
containsString
(
"/BOOT-INF/classes!/static/static.txt"
));
assertThat
(
invocation
.
getStandardOutput
(),
containsString
(
"/BOOT-INF/classes!/templates/template.txt"
));
assertThat
(
invocation
.
getStandardOutput
(),
containsString
(
"/BOOT-INF/classes!/root.properties"
));
assertThat
(
invocation
.
getStandardOutput
(),
containsString
(
"Goodbye Mama"
));
}
...
...
spring-boot-cli/src/it/java/org/springframework/boot/cli/WarCommandIT.java
View file @
2d75cc79
...
...
@@ -16,16 +16,16 @@
package
org
.
springframework
.
boot
.
cli
;
import
java.io.File
;
import
org.junit.Test
;
import
org.springframework.boot.cli.command.archive.WarCommand
;
import
org.springframework.boot.cli.infrastructure.CommandLineInvoker
;
import
org.springframework.boot.cli.infrastructure.CommandLineInvoker.Invocation
;
import
org.springframework.boot.loader.tools.JavaExecutable
;
import
org.springframework.util.SocketUtils
;
import
java.io.File
;
import
java.util.zip.ZipFile
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
/**
...
...
@@ -57,27 +57,8 @@ public class WarCommandIT {
assertThat
(
invocation
.
getOutput
())
.
contains
(
"/WEB-INF/lib-provided/tomcat-embed-core"
);
assertThat
(
invocation
.
getOutput
())
.
contains
(
"
/WEB-INF/lib-provided/tomcat-embed-core
"
);
.
contains
(
"
WEB-INF/classes!/root.properties
"
);
process
.
destroy
();
}
@Test
public
void
resourcesAreCopiedToWebInfClasses
()
throws
Exception
{
File
war
=
new
File
(
"target/test-app.war"
);
Invocation
invocation
=
this
.
cli
.
invoke
(
"war"
,
war
.
getAbsolutePath
(),
"war.groovy"
);
invocation
.
await
();
assertThat
(
war
.
exists
()).
isTrue
();
ZipFile
warFile
=
new
ZipFile
(
war
.
getAbsolutePath
());
try
{
assertThat
(
warFile
.
getEntry
(
"application.properties"
)).
isNull
();
assertThat
(
warFile
.
getEntry
(
"WEB-INF/classes/application.properties"
)).
isNotNull
();
}
finally
{
warFile
.
close
();
}
}
}
spring-boot-cli/src/it/resources/jar-command/jar.groovy
View file @
2d75cc79
...
...
@@ -13,6 +13,7 @@ class Example implements CommandLineRunner {
println
getClass
().
getResource
(
'/resources/resource.txt'
)
println
getClass
().
getResource
(
'/static/static.txt'
)
println
getClass
().
getResource
(
'/templates/template.txt'
)
println
getClass
().
getResource
(
'/root.properties'
)
println
template
(
'template.txt'
,
[
world:
'Mama'
])
}
}
...
...
spring-boot-cli/src/it/resources/
war-command/application
.properties
→
spring-boot-cli/src/it/resources/
jar-command/root
.properties
View file @
2d75cc79
File moved
spring-boot-cli/src/it/resources/war-command/root.properties
0 → 100644
View file @
2d75cc79
spring-boot-cli/src/it/resources/war-command/war.groovy
View file @
2d75cc79
...
...
@@ -10,6 +10,7 @@ class WarExample implements CommandLineRunner {
void
run
(
String
...
args
)
{
println
getClass
().
getResource
(
'/org/apache/tomcat/InstanceManager.class'
)
println
getClass
().
getResource
(
'/root.properties'
)
throw
new
RuntimeException
(
"onStart error"
)
}
...
...
spring-boot-cli/src/main/java/org/springframework/boot/cli/command/archive/ArchiveCommand.java
View file @
2d75cc79
/*
* Copyright 2012-201
5
the original author or authors.
* Copyright 2012-201
6
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -17,6 +17,7 @@
package
org
.
springframework
.
boot
.
cli
.
command
.
archive
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.FileNotFoundException
;
import
java.io.IOException
;
import
java.io.InputStream
;
...
...
@@ -93,7 +94,7 @@ abstract class ArchiveCommand extends OptionParsingCommand {
private
final
String
type
;
pr
otected
final
Layout
layout
;
pr
ivate
final
Layout
layout
;
private
OptionSpec
<
String
>
includeOption
;
...
...
@@ -104,6 +105,10 @@ abstract class ArchiveCommand extends OptionParsingCommand {
this
.
layout
=
layout
;
}
protected
Layout
getLayout
()
{
return
this
.
layout
;
}
@Override
protected
void
doOptions
()
{
this
.
includeOption
=
option
(
"include"
,
...
...
@@ -284,8 +289,11 @@ abstract class ArchiveCommand extends OptionParsingCommand {
return
libraries
;
}
protected
abstract
void
writeClasspathEntry
(
JarWriter
writer
,
MatchedResource
entry
)
throws
IOException
;
protected
void
writeClasspathEntry
(
JarWriter
writer
,
MatchedResource
entry
)
throws
IOException
{
writer
.
writeEntry
(
entry
.
getName
(),
new
FileInputStream
(
entry
.
getFile
()));
}
protected
abstract
LibraryScope
getLibraryScope
(
File
file
);
...
...
spring-boot-cli/src/main/java/org/springframework/boot/cli/command/archive/JarCommand.java
View file @
2d75cc79
...
...
@@ -17,11 +17,8 @@
package
org
.
springframework
.
boot
.
cli
.
command
.
archive
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.IOException
;
import
org.springframework.boot.cli.command.Command
;
import
org.springframework.boot.loader.tools.JarWriter
;
import
org.springframework.boot.loader.tools.Layouts
;
import
org.springframework.boot.loader.tools.LibraryScope
;
...
...
@@ -30,7 +27,6 @@ import org.springframework.boot.loader.tools.LibraryScope;
*
* @author Andy Wilkinson
* @author Phillip Webb
* @author Henri Kerola
*/
public
class
JarCommand
extends
ArchiveCommand
{
...
...
@@ -50,13 +46,6 @@ public class JarCommand extends ArchiveCommand {
return
LibraryScope
.
COMPILE
;
}
@Override
protected
void
writeClasspathEntry
(
JarWriter
writer
,
ResourceMatcher
.
MatchedResource
entry
)
throws
IOException
{
writer
.
writeEntry
(
entry
.
getName
(),
new
FileInputStream
(
entry
.
getFile
()));
}
}
}
spring-boot-cli/src/main/java/org/springframework/boot/cli/command/archive/WarCommand.java
View file @
2d75cc79
/*
* Copyright 2012-201
5
the original author or authors.
* Copyright 2012-201
6
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -66,9 +66,10 @@ public class WarCommand extends ArchiveCommand {
@Override
protected
void
writeClasspathEntry
(
JarWriter
writer
,
ResourceMatcher
.
MatchedResource
entry
)
throws
IOException
{
writer
.
writeEntry
(
this
.
layout
.
getClassesLocation
()
+
entry
.
getName
(),
writer
.
writeEntry
(
getLayout
()
.
getClassesLocation
()
+
entry
.
getName
(),
new
FileInputStream
(
entry
.
getFile
()));
}
}
}
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