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
d07f6894
Commit
d07f6894
authored
Jul 10, 2016
by
Henri Kerola
Committed by
Stephane Nicoll
Oct 05, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
"spring war" should copy resources to WEB-INF/classes
Closes gh-6351
parent
07690bab
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
56 additions
and
17 deletions
+56
-17
WarCommandIT.java
...rc/it/java/org/springframework/boot/cli/WarCommandIT.java
+31
-13
application.properties
...t-cli/src/it/resources/war-command/application.properties
+0
-0
ArchiveCommand.java
...ingframework/boot/cli/command/archive/ArchiveCommand.java
+6
-4
JarCommand.java
.../springframework/boot/cli/command/archive/JarCommand.java
+11
-0
WarCommand.java
.../springframework/boot/cli/command/archive/WarCommand.java
+8
-0
No files found.
spring-boot-cli/src/it/java/org/springframework/boot/cli/WarCommandIT.java
View file @
d07f6894
...
@@ -16,24 +16,23 @@
...
@@ -16,24 +16,23 @@
package
org
.
springframework
.
boot
.
cli
;
package
org
.
springframework
.
boot
.
cli
;
import
java.io.File
;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.springframework.boot.cli.command.archive.WarCommand
;
import
org.springframework.boot.cli.command.archive.WarCommand
;
import
org.springframework.boot.cli.infrastructure.CommandLineInvoker
;
import
org.springframework.boot.cli.infrastructure.CommandLineInvoker
;
import
org.springframework.boot.cli.infrastructure.CommandLineInvoker.Invocation
;
import
org.springframework.boot.cli.infrastructure.CommandLineInvoker.Invocation
;
import
org.springframework.boot.loader.tools.JavaExecutable
;
import
org.springframework.boot.loader.tools.JavaExecutable
;
import
org.springframework.util.SocketUtils
;
import
org.springframework.util.SocketUtils
;
import
static
org
.
hamcrest
.
Matchers
.
containsString
;
import
java.io.File
;
import
static
org
.
junit
.
Assert
.
assertThat
;
import
java.util.zip.ZipFile
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
/**
/**
* Integration test for {@link WarCommand}.
* Integration test for {@link WarCommand}.
*
*
* @author Andrey Stolyarov
* @author Andrey Stolyarov
* @author Henri Kerola
*/
*/
public
class
WarCommandIT
{
public
class
WarCommandIT
{
...
@@ -47,19 +46,38 @@ public class WarCommandIT {
...
@@ -47,19 +46,38 @@ public class WarCommandIT {
Invocation
invocation
=
this
.
cli
.
invoke
(
"war"
,
war
.
getAbsolutePath
(),
Invocation
invocation
=
this
.
cli
.
invoke
(
"war"
,
war
.
getAbsolutePath
(),
"war.groovy"
);
"war.groovy"
);
invocation
.
await
();
invocation
.
await
();
assertT
rue
(
war
.
exists
()
);
assertT
hat
(
war
.
exists
()).
isTrue
(
);
Process
process
=
new
JavaExecutable
()
Process
process
=
new
JavaExecutable
()
.
processBuilder
(
"-jar"
,
war
.
getAbsolutePath
(),
"--server.port="
+
port
)
.
processBuilder
(
"-jar"
,
war
.
getAbsolutePath
(),
"--server.port="
+
port
)
.
start
();
.
start
();
invocation
=
new
Invocation
(
process
);
invocation
=
new
Invocation
(
process
);
invocation
.
await
();
invocation
.
await
();
assertThat
(
invocation
.
getOutput
()
,
containsString
(
"onStart error"
)
);
assertThat
(
invocation
.
getOutput
()
).
contains
(
"onStart error"
);
assertThat
(
invocation
.
getOutput
()
,
containsString
(
"Tomcat started"
)
);
assertThat
(
invocation
.
getOutput
()
).
contains
(
"Tomcat started"
);
assertThat
(
invocation
.
getOutput
()
,
assertThat
(
invocation
.
getOutput
()
)
containsString
(
"/WEB-INF/lib-provided/tomcat-embed-core"
)
);
.
contains
(
"/WEB-INF/lib-provided/tomcat-embed-core"
);
assertThat
(
invocation
.
getOutput
()
,
assertThat
(
invocation
.
getOutput
()
)
containsString
(
"/WEB-INF/lib-provided/tomcat-embed-core"
)
);
.
contains
(
"/WEB-INF/lib-provided/tomcat-embed-core"
);
process
.
destroy
();
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/war-command/application.properties
0 → 100644
View file @
d07f6894
spring-boot-cli/src/main/java/org/springframework/boot/cli/command/archive/ArchiveCommand.java
View file @
d07f6894
...
@@ -17,7 +17,6 @@
...
@@ -17,7 +17,6 @@
package
org
.
springframework
.
boot
.
cli
.
command
.
archive
;
package
org
.
springframework
.
boot
.
cli
.
command
.
archive
;
import
java.io.File
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.FileNotFoundException
;
import
java.io.FileNotFoundException
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.InputStream
;
...
@@ -73,6 +72,7 @@ import org.springframework.util.Assert;
...
@@ -73,6 +72,7 @@ import org.springframework.util.Assert;
* @author Andy Wilkinson
* @author Andy Wilkinson
* @author Phillip Webb
* @author Phillip Webb
* @author Andrey Stolyarov
* @author Andrey Stolyarov
* @author Henri Kerola
*/
*/
abstract
class
ArchiveCommand
extends
OptionParsingCommand
{
abstract
class
ArchiveCommand
extends
OptionParsingCommand
{
...
@@ -93,7 +93,7 @@ abstract class ArchiveCommand extends OptionParsingCommand {
...
@@ -93,7 +93,7 @@ abstract class ArchiveCommand extends OptionParsingCommand {
private
final
String
type
;
private
final
String
type
;
pr
ivate
final
Layout
layout
;
pr
otected
final
Layout
layout
;
private
OptionSpec
<
String
>
includeOption
;
private
OptionSpec
<
String
>
includeOption
;
...
@@ -278,13 +278,15 @@ abstract class ArchiveCommand extends OptionParsingCommand {
...
@@ -278,13 +278,15 @@ abstract class ArchiveCommand extends OptionParsingCommand {
libraries
.
add
(
new
Library
(
entry
.
getFile
(),
LibraryScope
.
COMPILE
));
libraries
.
add
(
new
Library
(
entry
.
getFile
(),
LibraryScope
.
COMPILE
));
}
}
else
{
else
{
writer
.
writeEntry
(
entry
.
getName
(),
writeClasspathEntry
(
writer
,
entry
);
new
FileInputStream
(
entry
.
getFile
()));
}
}
}
}
return
libraries
;
return
libraries
;
}
}
protected
abstract
void
writeClasspathEntry
(
JarWriter
writer
,
MatchedResource
entry
)
throws
IOException
;
protected
abstract
LibraryScope
getLibraryScope
(
File
file
);
protected
abstract
LibraryScope
getLibraryScope
(
File
file
);
}
}
...
...
spring-boot-cli/src/main/java/org/springframework/boot/cli/command/archive/JarCommand.java
View file @
d07f6894
...
@@ -17,8 +17,11 @@
...
@@ -17,8 +17,11 @@
package
org
.
springframework
.
boot
.
cli
.
command
.
archive
;
package
org
.
springframework
.
boot
.
cli
.
command
.
archive
;
import
java.io.File
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.IOException
;
import
org.springframework.boot.cli.command.Command
;
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.Layouts
;
import
org.springframework.boot.loader.tools.LibraryScope
;
import
org.springframework.boot.loader.tools.LibraryScope
;
...
@@ -27,6 +30,7 @@ import org.springframework.boot.loader.tools.LibraryScope;
...
@@ -27,6 +30,7 @@ import org.springframework.boot.loader.tools.LibraryScope;
*
*
* @author Andy Wilkinson
* @author Andy Wilkinson
* @author Phillip Webb
* @author Phillip Webb
* @author Henri Kerola
*/
*/
public
class
JarCommand
extends
ArchiveCommand
{
public
class
JarCommand
extends
ArchiveCommand
{
...
@@ -46,6 +50,13 @@ public class JarCommand extends ArchiveCommand {
...
@@ -46,6 +50,13 @@ public class JarCommand extends ArchiveCommand {
return
LibraryScope
.
COMPILE
;
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 @
d07f6894
...
@@ -17,6 +17,7 @@
...
@@ -17,6 +17,7 @@
package
org
.
springframework
.
boot
.
cli
.
command
.
archive
;
package
org
.
springframework
.
boot
.
cli
.
command
.
archive
;
import
java.io.File
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.IOException
;
import
java.io.IOException
;
import
org.springframework.boot.cli.command.Command
;
import
org.springframework.boot.cli.command.Command
;
...
@@ -29,6 +30,7 @@ import org.springframework.boot.loader.tools.LibraryScope;
...
@@ -29,6 +30,7 @@ import org.springframework.boot.loader.tools.LibraryScope;
*
*
* @author Andrey Stolyarov
* @author Andrey Stolyarov
* @author Phillip Webb
* @author Phillip Webb
* @author Henri Kerola
* @since 1.3.0
* @since 1.3.0
*/
*/
public
class
WarCommand
extends
ArchiveCommand
{
public
class
WarCommand
extends
ArchiveCommand
{
...
@@ -61,6 +63,12 @@ public class WarCommand extends ArchiveCommand {
...
@@ -61,6 +63,12 @@ public class WarCommand extends ArchiveCommand {
super
.
addCliClasses
(
writer
);
super
.
addCliClasses
(
writer
);
}
}
@Override
protected
void
writeClasspathEntry
(
JarWriter
writer
,
ResourceMatcher
.
MatchedResource
entry
)
throws
IOException
{
writer
.
writeEntry
(
this
.
layout
.
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