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
e3e3a440
Commit
e3e3a440
authored
Aug 14, 2018
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '2.0.x'
parents
f187ab72
1973e342
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
25 deletions
+38
-25
JavaPluginAction.java
.../springframework/boot/gradle/plugin/JavaPluginAction.java
+38
-25
No files found.
spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/plugin/JavaPluginAction.java
View file @
e3e3a440
...
...
@@ -26,6 +26,7 @@ import java.util.concurrent.Callable;
import
org.gradle.api.Action
;
import
org.gradle.api.Plugin
;
import
org.gradle.api.Project
;
import
org.gradle.api.Task
;
import
org.gradle.api.file.FileCollection
;
import
org.gradle.api.internal.artifacts.publish.ArchivePublishArtifact
;
import
org.gradle.api.plugins.ApplicationPlugin
;
...
...
@@ -145,37 +146,49 @@ final class JavaPluginAction implements PluginApplicationAction {
}
private
void
configureAdditionalMetadataLocations
(
JavaCompile
compile
)
{
compile
.
doFirst
((
task
)
->
{
compile
.
doFirst
(
new
AdditionalMetadataLocationsConfigurer
());
}
private
static
class
AdditionalMetadataLocationsConfigurer
implements
Action
<
Task
>
{
@Override
public
void
execute
(
Task
task
)
{
if
(!(
task
instanceof
JavaCompile
))
{
return
;
}
JavaCompile
compile
=
(
JavaCompile
)
task
;
if
(
hasConfigurationProcessorOnClasspath
(
compile
))
{
findMatchingSourceSet
(
compile
).
ifPresent
(
(
sourceSet
)
->
configureAdditionalMetadataLocations
(
compile
,
sourceSet
));
}
});
}
private
Optional
<
SourceSet
>
findMatchingSourceSet
(
JavaCompile
compile
)
{
return
compile
.
getProject
().
getConvention
().
getPlugin
(
JavaPluginConvention
.
class
)
.
getSourceSets
().
stream
().
filter
((
sourceSet
)
->
sourceSet
.
getCompileJavaTaskName
().
equals
(
compile
.
getName
()))
.
findFirst
();
}
private
boolean
hasConfigurationProcessorOnClasspath
(
JavaCompile
compile
)
{
Set
<
File
>
files
=
(
compile
.
getOptions
().
getAnnotationProcessorPath
()
!=
null
)
?
compile
.
getOptions
().
getAnnotationProcessorPath
().
getFiles
()
:
compile
.
getClasspath
().
getFiles
();
return
files
.
stream
().
map
(
File:
:
getName
).
anyMatch
(
(
name
)
->
name
.
startsWith
(
"spring-boot-configuration-processor"
));
}
}
private
boolean
hasConfigurationProcessorOnClasspath
(
JavaCompile
compile
)
{
Set
<
File
>
files
=
(
compile
.
getOptions
().
getAnnotationProcessorPath
()
!=
null
)
?
compile
.
getOptions
().
getAnnotationProcessorPath
().
getFiles
()
:
compile
.
getClasspath
().
getFiles
();
return
files
.
stream
().
map
(
File:
:
getName
).
anyMatch
(
(
name
)
->
name
.
startsWith
(
"spring-boot-configuration-processor"
));
}
private
Optional
<
SourceSet
>
findMatchingSourceSet
(
JavaCompile
compile
)
{
return
compile
.
getProject
().
getConvention
().
getPlugin
(
JavaPluginConvention
.
class
)
.
getSourceSets
().
stream
().
filter
((
sourceSet
)
->
sourceSet
.
getCompileJavaTaskName
().
equals
(
compile
.
getName
()))
.
findFirst
();
}
private
void
configureAdditionalMetadataLocations
(
JavaCompile
compile
,
SourceSet
sourceSet
)
{
String
locations
=
StringUtils
.
collectionToCommaDelimitedString
(
sourceSet
.
getResources
().
getSrcDirs
());
compile
.
getOptions
().
getCompilerArgs
().
add
(
"-Aorg.springframework.boot.configurationprocessor.additionalMetadataLocations="
+
locations
);
}
private
void
configureAdditionalMetadataLocations
(
JavaCompile
compile
,
SourceSet
sourceSet
)
{
String
locations
=
StringUtils
.
collectionToCommaDelimitedString
(
sourceSet
.
getResources
().
getSrcDirs
());
compile
.
getOptions
().
getCompilerArgs
().
add
(
"-Aorg.springframework.boot.configurationprocessor.additionalMetadataLocations="
+
locations
);
}
}
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