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
ecbc8ea2
Commit
ecbc8ea2
authored
Jul 02, 2020
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '2.3.x'
Closes gh-22202
parents
ecc50d17
79770b96
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
80 additions
and
11 deletions
+80
-11
BootJar.java
...g/springframework/boot/gradle/tasks/bundling/BootJar.java
+8
-1
LayerResolver.java
...ngframework/boot/gradle/tasks/bundling/LayerResolver.java
+31
-10
BootJarIntegrationTests.java
...k/boot/gradle/tasks/bundling/BootJarIntegrationTests.java
+5
-0
BootJarIntegrationTests-layersWithCustomSourceSet.gradle
.../BootJarIntegrationTests-layersWithCustomSourceSet.gradle
+36
-0
No files found.
spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/BootJar.java
View file @
ecbc8ea2
...
...
@@ -27,10 +27,12 @@ import org.gradle.api.file.FileCollection;
import
org.gradle.api.file.FileCopyDetails
;
import
org.gradle.api.file.FileTreeElement
;
import
org.gradle.api.internal.file.copy.CopyAction
;
import
org.gradle.api.plugins.JavaPluginConvention
;
import
org.gradle.api.specs.Spec
;
import
org.gradle.api.tasks.Internal
;
import
org.gradle.api.tasks.Nested
;
import
org.gradle.api.tasks.Optional
;
import
org.gradle.api.tasks.SourceSet
;
import
org.gradle.api.tasks.bundling.Jar
;
/**
...
...
@@ -103,7 +105,12 @@ public class BootJar extends Jar implements BootArchive {
@Override
protected
CopyAction
createCopyAction
()
{
if
(
this
.
layered
!=
null
)
{
LayerResolver
layerResolver
=
new
LayerResolver
(
getConfigurations
(),
this
.
layered
,
this
::
isLibrary
);
JavaPluginConvention
javaPluginConvention
=
getProject
().
getConvention
()
.
findPlugin
(
JavaPluginConvention
.
class
);
Iterable
<
SourceSet
>
sourceSets
=
(
javaPluginConvention
!=
null
)
?
javaPluginConvention
.
getSourceSets
()
:
Collections
.
emptySet
();
LayerResolver
layerResolver
=
new
LayerResolver
(
sourceSets
,
getConfigurations
(),
this
.
layered
,
this
::
isLibrary
);
String
layerToolsLocation
=
this
.
layered
.
isIncludeLayerTools
()
?
LIB_DIRECTORY
:
null
;
return
this
.
support
.
createCopyAction
(
this
,
layerResolver
,
layerToolsLocation
);
}
...
...
spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/LayerResolver.java
View file @
ecbc8ea2
...
...
@@ -17,8 +17,6 @@
package
org
.
springframework
.
boot
.
gradle
.
tasks
.
bundling
;
import
java.io.File
;
import
java.util.Arrays
;
import
java.util.Collections
;
import
java.util.HashSet
;
import
java.util.LinkedHashMap
;
import
java.util.Map
;
...
...
@@ -30,6 +28,7 @@ import org.gradle.api.artifacts.ResolvedArtifact;
import
org.gradle.api.artifacts.ResolvedConfiguration
;
import
org.gradle.api.file.FileCopyDetails
;
import
org.gradle.api.specs.Spec
;
import
org.gradle.api.tasks.SourceSet
;
import
org.springframework.boot.loader.tools.Layer
;
import
org.springframework.boot.loader.tools.Library
;
...
...
@@ -53,9 +52,9 @@ class LayerResolver {
private
final
Spec
<
FileCopyDetails
>
librarySpec
;
LayerResolver
(
Iterable
<
Configuration
>
configurations
,
LayeredSpec
layeredConfiguration
,
Spec
<
FileCopyDetails
>
librarySpec
)
{
this
.
resolvedDependencies
=
new
ResolvedDependencies
(
configurations
);
LayerResolver
(
Iterable
<
SourceSet
>
sourceSets
,
Iterable
<
Configuration
>
configurations
,
LayeredSpec
layeredConfiguration
,
Spec
<
FileCopyDetails
>
librarySpec
)
{
this
.
resolvedDependencies
=
new
ResolvedDependencies
(
sourceSets
,
configurations
);
this
.
layeredConfiguration
=
layeredConfiguration
;
this
.
librarySpec
=
librarySpec
;
}
...
...
@@ -96,19 +95,41 @@ class LayerResolver {
*/
private
static
class
ResolvedDependencies
{
private
static
final
Set
<
String
>
DEPRECATED_FOR_RESOLUTION_CONFIGURATIONS
=
Collections
.
unmodifiableSet
(
new
HashSet
<>(
Arrays
.
asList
(
"archives"
,
"compile"
,
"compileOnly"
,
"default"
,
"runtime"
,
"testCompile"
,
"testCompileOnly"
,
"testRuntime"
)));
private
final
Set
<
String
>
deprecatedForResolutionConfigurationNames
;
private
final
Map
<
Configuration
,
ResolvedConfigurationDependencies
>
configurationDependencies
=
new
LinkedHashMap
<>();
ResolvedDependencies
(
Iterable
<
Configuration
>
configurations
)
{
ResolvedDependencies
(
Iterable
<
SourceSet
>
sourceSets
,
Iterable
<
Configuration
>
configurations
)
{
this
.
deprecatedForResolutionConfigurationNames
=
deprecatedForResolutionConfigurationNames
(
sourceSets
);
configurations
.
forEach
(
this
::
processConfiguration
);
}
@SuppressWarnings
(
"deprecation"
)
private
Set
<
String
>
deprecatedForResolutionConfigurationNames
(
Iterable
<
SourceSet
>
sourceSets
)
{
Set
<
String
>
configurationNames
=
new
HashSet
<>();
configurationNames
.
add
(
"archives"
);
configurationNames
.
add
(
"default"
);
for
(
SourceSet
sourceSet
:
sourceSets
)
{
try
{
configurationNames
.
add
(
sourceSet
.
getCompileConfigurationName
());
}
catch
(
NoSuchMethodError
ex
)
{
// Continue
}
configurationNames
.
add
(
sourceSet
.
getCompileOnlyConfigurationName
());
try
{
configurationNames
.
add
(
sourceSet
.
getRuntimeConfigurationName
());
}
catch
(
NoSuchMethodError
ex
)
{
// Continue
}
}
return
configurationNames
;
}
private
void
processConfiguration
(
Configuration
configuration
)
{
if
(
configuration
.
isCanBeResolved
()
&&
!
DEPRECATED_FOR_RESOLUTION_CONFIGURATIONS
.
contains
(
configuration
.
getName
()))
{
&&
!
this
.
deprecatedForResolutionConfigurationNames
.
contains
(
configuration
.
getName
()))
{
this
.
configurationDependencies
.
put
(
configuration
,
new
ResolvedConfigurationDependencies
(
configuration
.
getResolvedConfiguration
()));
}
...
...
spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/BootJarIntegrationTests.java
View file @
ecbc8ea2
...
...
@@ -86,6 +86,11 @@ class BootJarIntegrationTests extends AbstractBootArchiveIntegrationTests {
.
getOutcome
()).
isEqualTo
(
TaskOutcome
.
SUCCESS
);
}
@TestTemplate
void
layersWithCustomSourceSet
()
throws
IOException
{
assertThat
(
this
.
gradleBuild
.
build
(
"bootJar"
).
task
(
":bootJar"
).
getOutcome
()).
isEqualTo
(
TaskOutcome
.
SUCCESS
);
}
@TestTemplate
void
implicitLayers
()
throws
IOException
{
writeMainClass
();
...
...
spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/resources/org/springframework/boot/gradle/tasks/bundling/BootJarIntegrationTests-layersWithCustomSourceSet.gradle
0 → 100644
View file @
ecbc8ea2
plugins
{
id
'java'
id
'org.springframework.boot'
version
'{version}'
}
sourceSets
{
custom
}
bootJar
{
mainClassName
=
'com.example.Application'
layered
()
}
repositories
{
mavenCentral
()
maven
{
url
"file:repository"
}
}
dependencies
{
implementation
(
"com.example:library:1.0-SNAPSHOT"
)
implementation
(
"org.apache.commons:commons-lang3:3.9"
)
implementation
(
"org.springframework:spring-core:5.2.5.RELEASE"
)
}
task
listLayers
(
type:
JavaExec
)
{
classpath
=
bootJar
.
outputs
.
files
systemProperties
=
[
"jarmode"
:
"layertools"
]
args
"list"
}
task
extractLayers
(
type:
JavaExec
)
{
classpath
=
bootJar
.
outputs
.
files
systemProperties
=
[
"jarmode"
:
"layertools"
]
args
"extract"
}
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