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
ff9788c6
Commit
ff9788c6
authored
Feb 16, 2017
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '1.5.x'
parents
4304cdb9
f67dd957
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
64 additions
and
35 deletions
+64
-35
RepackagingTests.java
...ava/org/springframework/boot/gradle/RepackagingTests.java
+53
-31
repackage.gradle
...ing-boot-gradle-tests/src/test/resources/repackage.gradle
+9
-2
RepackageTask.java
.../springframework/boot/gradle/repackage/RepackageTask.java
+2
-2
No files found.
spring-boot-integration-tests/spring-boot-gradle-tests/src/test/java/org/springframework/boot/gradle/RepackagingTests.java
View file @
ff9788c6
/*
* Copyright 2012-201
6
the original author or authors.
* Copyright 2012-201
7
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.
...
...
@@ -20,6 +20,7 @@ import java.io.File;
import
java.io.IOException
;
import
java.util.jar.JarFile
;
import
org.gradle.tooling.BuildLauncher
;
import
org.gradle.tooling.ProjectConnection
;
import
org.junit.BeforeClass
;
import
org.junit.Test
;
...
...
@@ -46,24 +47,20 @@ public class RepackagingTests {
@Test
public
void
repackagingEnabled
()
throws
IOException
{
project
.
newBuild
().
forTasks
(
"clean"
,
"build"
)
.
withArguments
(
"-PbootVersion="
+
BOOT_VERSION
,
"-Prepackage=true"
,
"-PexcludeDevtools=false"
)
.
run
();
createBuildForTasks
(
"clean"
,
"build"
)
.
withArguments
(
"-PbootVersion="
+
BOOT_VERSION
,
"-Prepackage=true"
).
run
();
File
buildLibs
=
new
File
(
"target/repackage/build/libs"
);
File
repackageFile
=
new
File
(
buildLibs
,
"repackage.jar"
);
assertThat
(
repackageFile
.
exists
()).
isTrue
();
assertThat
(
new
File
(
buildLibs
,
"repackage.jar.original"
).
exists
()).
isTrue
();
assertThat
(
new
File
(
buildLibs
,
"repackage-sources.jar.original"
).
exists
())
.
isFalse
();
assertThat
(
isDevToolsJarIncluded
(
repackageFile
)).
isTrue
();
}
@Test
public
void
repackagingDisabled
()
{
project
.
newBuild
().
forTasks
(
"clean"
,
"build"
)
.
withArguments
(
"-PbootVersion="
+
BOOT_VERSION
,
"-Prepackage=false"
,
"-PexcludeDevtools=false"
)
createBuildForTasks
(
"clean"
,
"build"
)
.
withArguments
(
"-PbootVersion="
+
BOOT_VERSION
,
"-Prepackage=false"
)
.
run
();
File
buildLibs
=
new
File
(
"target/repackage/build/libs"
);
assertThat
(
new
File
(
buildLibs
,
"repackage.jar"
).
exists
()).
isTrue
();
...
...
@@ -74,9 +71,8 @@ public class RepackagingTests {
@Test
public
void
repackagingDisabledWithCustomRepackagedJar
()
{
project
.
newBuild
().
forTasks
(
"clean"
,
"build"
,
"customRepackagedJar"
)
.
withArguments
(
"-PbootVersion="
+
BOOT_VERSION
,
"-Prepackage=false"
,
"-PexcludeDevtools=false"
)
createBuildForTasks
(
"clean"
,
"build"
,
"customRepackagedJar"
)
.
withArguments
(
"-PbootVersion="
+
BOOT_VERSION
,
"-Prepackage=false"
)
.
run
();
File
buildLibs
=
new
File
(
"target/repackage/build/libs"
);
assertThat
(
new
File
(
buildLibs
,
"repackage.jar"
).
exists
()).
isTrue
();
...
...
@@ -91,8 +87,7 @@ public class RepackagingTests {
public
void
repackagingDisabledWithCustomRepackagedJarUsingStringJarTaskReference
()
{
project
.
newBuild
()
.
forTasks
(
"clean"
,
"build"
,
"customRepackagedJarWithStringReference"
)
.
withArguments
(
"-PbootVersion="
+
BOOT_VERSION
,
"-Prepackage=false"
,
"-PexcludeDevtools=false"
)
.
withArguments
(
"-PbootVersion="
+
BOOT_VERSION
,
"-Prepackage=false"
)
.
run
();
File
buildLibs
=
new
File
(
"target/repackage/build/libs"
);
assertThat
(
new
File
(
buildLibs
,
"repackage.jar"
).
exists
()).
isTrue
();
...
...
@@ -105,10 +100,8 @@ public class RepackagingTests {
@Test
public
void
repackagingEnabledWithCustomRepackagedJar
()
{
project
.
newBuild
().
forTasks
(
"clean"
,
"build"
,
"customRepackagedJar"
)
.
withArguments
(
"-PbootVersion="
+
BOOT_VERSION
,
"-Prepackage=true"
,
"-PexcludeDevtools=false"
)
.
run
();
createBuildForTasks
(
"clean"
,
"build"
,
"customRepackagedJar"
)
.
withArguments
(
"-PbootVersion="
+
BOOT_VERSION
,
"-Prepackage=true"
).
run
();
File
buildLibs
=
new
File
(
"target/repackage/build/libs"
);
assertThat
(
new
File
(
buildLibs
,
"repackage.jar"
).
exists
()).
isTrue
();
assertThat
(
new
File
(
buildLibs
,
"repackage.jar.original"
).
exists
()).
isTrue
();
...
...
@@ -122,9 +115,7 @@ public class RepackagingTests {
public
void
repackagingEnableWithCustomRepackagedJarUsingStringJarTaskReference
()
{
project
.
newBuild
()
.
forTasks
(
"clean"
,
"build"
,
"customRepackagedJarWithStringReference"
)
.
withArguments
(
"-PbootVersion="
+
BOOT_VERSION
,
"-Prepackage=true"
,
"-PexcludeDevtools=false"
)
.
run
();
.
withArguments
(
"-PbootVersion="
+
BOOT_VERSION
,
"-Prepackage=true"
).
run
();
File
buildLibs
=
new
File
(
"target/repackage/build/libs"
);
assertThat
(
new
File
(
buildLibs
,
"repackage.jar"
).
exists
()).
isTrue
();
assertThat
(
new
File
(
buildLibs
,
"repackage.jar.original"
).
exists
()).
isTrue
();
...
...
@@ -138,10 +129,8 @@ public class RepackagingTests {
public
void
repackageWithFileDependency
()
throws
Exception
{
FileCopyUtils
.
copy
(
new
File
(
"src/test/resources/foo.jar"
),
new
File
(
"target/repackage/foo.jar"
));
project
.
newBuild
().
forTasks
(
"clean"
,
"build"
)
.
withArguments
(
"-PbootVersion="
+
BOOT_VERSION
,
"-Prepackage=true"
,
"-PexcludeDevtools=false"
)
.
run
();
createBuildForTasks
(
"clean"
,
"build"
)
.
withArguments
(
"-PbootVersion="
+
BOOT_VERSION
,
"-Prepackage=true"
).
run
();
File
buildLibs
=
new
File
(
"target/repackage/build/libs"
);
JarFile
jarFile
=
new
JarFile
(
new
File
(
buildLibs
,
"repackage.jar"
));
assertThat
(
jarFile
.
getEntry
(
"BOOT-INF/lib/foo.jar"
)).
isNotNull
();
...
...
@@ -149,10 +138,23 @@ public class RepackagingTests {
}
@Test
public
void
repackagingEnabledExcludeDevtools
()
throws
IOException
{
project
.
newBuild
().
forTasks
(
"clean"
,
"build"
)
public
void
devtoolsIsExcludedByDefault
()
throws
IOException
{
createBuildForTasks
(
"clean"
,
"bootRepackage"
)
.
withArguments
(
"-PbootVersion="
+
BOOT_VERSION
,
"-Prepackage=true"
).
run
();
File
buildLibs
=
new
File
(
"target/repackage/build/libs"
);
File
repackageFile
=
new
File
(
buildLibs
,
"repackage.jar"
);
assertThat
(
repackageFile
.
exists
()).
isTrue
();
assertThat
(
new
File
(
buildLibs
,
"repackage.jar.original"
).
exists
()).
isTrue
();
assertThat
(
new
File
(
buildLibs
,
"repackage-sources.jar.original"
).
exists
())
.
isFalse
();
assertThat
(
isDevToolsJarIncluded
(
repackageFile
)).
isFalse
();
}
@Test
public
void
devtoolsCanBeIncludedUsingTheExtension
()
throws
IOException
{
createBuildForTasks
(
"clean"
,
"bootRepackage"
)
.
withArguments
(
"-PbootVersion="
+
BOOT_VERSION
,
"-Prepackage=true"
,
"-PexcludeDevtools
=tru
e"
)
"-PexcludeDevtools
OnExtension=fals
e"
)
.
run
();
File
buildLibs
=
new
File
(
"target/repackage/build/libs"
);
File
repackageFile
=
new
File
(
buildLibs
,
"repackage.jar"
);
...
...
@@ -160,20 +162,40 @@ public class RepackagingTests {
assertThat
(
new
File
(
buildLibs
,
"repackage.jar.original"
).
exists
()).
isTrue
();
assertThat
(
new
File
(
buildLibs
,
"repackage-sources.jar.original"
).
exists
())
.
isFalse
();
assertThat
(
isDevToolsJarIncluded
(
repackageFile
)).
isFalse
();
assertThat
(
isDevToolsJarIncluded
(
repackageFile
)).
isTrue
();
}
@Test
public
void
devtoolsCanBeIncludedUsingBootRepackage
()
throws
IOException
{
createBuildForTasks
(
"clean"
,
"bootRepackage"
)
.
withArguments
(
"-PbootVersion="
+
BOOT_VERSION
,
"-Prepackage=true"
,
"-PexcludeDevtoolsOnBootRepackage=false"
)
.
run
();
File
buildLibs
=
new
File
(
"target/repackage/build/libs"
);
File
repackageFile
=
new
File
(
buildLibs
,
"repackage.jar"
);
assertThat
(
repackageFile
.
exists
()).
isTrue
();
assertThat
(
new
File
(
buildLibs
,
"repackage.jar.original"
).
exists
()).
isTrue
();
assertThat
(
new
File
(
buildLibs
,
"repackage-sources.jar.original"
).
exists
())
.
isFalse
();
assertThat
(
isDevToolsJarIncluded
(
repackageFile
)).
isTrue
();
}
@Test
public
void
customRepackagingTaskWithOwnMainClassNameAnNoGlobalMainClassName
()
{
project
.
newBuild
().
f
orTasks
(
"clean"
,
"customRepackagedJarWithOwnMainClass"
)
createBuildF
orTasks
(
"clean"
,
"customRepackagedJarWithOwnMainClass"
)
.
withArguments
(
"-PbootVersion="
+
BOOT_VERSION
,
"-Prepackage=true"
,
"-P
excludeDevtools=false"
,
"-P
noMainClass=true"
)
"-PnoMainClass=true"
)
.
run
();
File
buildLibs
=
new
File
(
"target/repackage/build/libs"
);
assertThat
(
new
File
(
buildLibs
,
"custom.jar"
).
exists
()).
isTrue
();
assertThat
(
new
File
(
buildLibs
,
"custom.jar.original"
).
exists
()).
isTrue
();
}
private
BuildLauncher
createBuildForTasks
(
String
...
taskNames
)
{
return
project
.
newBuild
().
setStandardError
(
System
.
err
)
.
setStandardOutput
(
System
.
out
).
forTasks
(
taskNames
);
}
private
boolean
isDevToolsJarIncluded
(
File
repackageFile
)
throws
IOException
{
JarFile
jarFile
=
new
JarFile
(
repackageFile
);
try
{
...
...
spring-boot-integration-tests/spring-boot-gradle-tests/src/test/resources/repackage.gradle
View file @
ff9788c6
...
...
@@ -26,10 +26,17 @@ springBoot {
if
(!
project
.
hasProperty
(
"noMainClass"
))
{
mainClass
=
'foo.bar.Baz'
}
excludeDevtools
=
Boolean
.
valueOf
(
project
.
excludeDevtools
)
if
(
project
.
hasProperty
(
"excludeDevtoolsOnExtension"
))
{
excludeDevtools
=
Boolean
.
valueOf
(
project
.
excludeDevtoolsOnExtension
)
}
}
bootRepackage
.
enabled
=
Boolean
.
valueOf
(
project
.
repackage
)
bootRepackage
{
enabled
=
Boolean
.
valueOf
(
project
.
repackage
)
if
(
project
.
hasProperty
(
"excludeDevtoolsOnBootRepackage"
))
{
excludeDevtools
=
Boolean
.
valueOf
(
project
.
excludeDevtoolsOnBootRepackage
)
}
}
task
customJar
(
type:
Jar
)
{
archiveName
=
'custom.jar'
...
...
spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/repackage/RepackageTask.java
View file @
ff9788c6
...
...
@@ -144,8 +144,8 @@ public class RepackageTask extends DefaultTask {
SpringBootPluginExtension
extension
=
project
.
getExtensions
()
.
getByType
(
SpringBootPluginExtension
.
class
);
ProjectLibraries
libraries
=
new
ProjectLibraries
(
project
,
extension
,
(
this
.
excludeDevtools
!=
null
&&
this
.
excludeDevtools
)
||
extension
.
isExcludeDevtools
()
);
this
.
excludeDevtools
==
null
?
extension
.
isExcludeDevtools
(
)
:
this
.
excludeDevtools
);
if
(
extension
.
getProvidedConfiguration
()
!=
null
)
{
libraries
.
setProvidedConfigurationName
(
extension
.
getProvidedConfiguration
());
}
...
...
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