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
6d8c3330
Commit
6d8c3330
authored
Sep 26, 2017
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace convention mappings with PropertyState and Provider
Closes gh-9891
parent
6eee9de3
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
71 additions
and
16 deletions
+71
-16
SpringBootExtension.java
.../springframework/boot/gradle/dsl/SpringBootExtension.java
+3
-6
ApplicationPluginAction.java
...framework/boot/gradle/plugin/ApplicationPluginAction.java
+4
-4
CreateBootStartScripts.java
...boot/gradle/tasks/application/CreateBootStartScripts.java
+50
-0
BuildInfo.java
...pringframework/boot/gradle/tasks/buildinfo/BuildInfo.java
+14
-6
No files found.
spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/dsl/SpringBootExtension.java
View file @
6d8c3330
...
@@ -17,7 +17,6 @@
...
@@ -17,7 +17,6 @@
package
org
.
springframework
.
boot
.
gradle
.
dsl
;
package
org
.
springframework
.
boot
.
gradle
.
dsl
;
import
java.io.File
;
import
java.io.File
;
import
java.util.concurrent.Callable
;
import
org.gradle.api.Action
;
import
org.gradle.api.Action
;
import
org.gradle.api.Project
;
import
org.gradle.api.Project
;
...
@@ -87,11 +86,9 @@ public class SpringBootExtension {
...
@@ -87,11 +86,9 @@ public class SpringBootExtension {
properties
.
setArtifact
(
determineArtifactBaseName
());
properties
.
setArtifact
(
determineArtifactBaseName
());
}
}
});
});
bootBuildInfo
.
getConventionMapping
()
bootBuildInfo
.
setDestinationDir
(
this
.
project
.
map
(
"destinationDir"
,
.
provider
(()
->
new
File
(
determineMainSourceSetResourcesOutputDir
(),
(
Callable
<
File
>)
()
->
new
File
(
"META-INF"
)));
determineMainSourceSetResourcesOutputDir
(),
"META-INF"
));
});
});
if
(
configurer
!=
null
)
{
if
(
configurer
!=
null
)
{
configurer
.
execute
(
bootBuildInfo
);
configurer
.
execute
(
bootBuildInfo
);
...
...
spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/plugin/ApplicationPluginAction.java
View file @
6d8c3330
...
@@ -68,10 +68,10 @@ final class ApplicationPluginAction implements PluginApplicationAction {
...
@@ -68,10 +68,10 @@ final class ApplicationPluginAction implements PluginApplicationAction {
bootStartScripts
.
setClasspath
(
configuration
.
getArtifacts
().
getFiles
());
bootStartScripts
.
setClasspath
(
configuration
.
getArtifacts
().
getFiles
());
}
}
});
});
bootStartScripts
.
getConventionMapping
().
map
(
"outputDir"
,
bootStartScripts
.
setOutputDir
(
()
->
new
File
(
project
.
getBuildDir
(),
"bootScripts"
));
project
.
provider
(()
->
new
File
(
project
.
getBuildDir
(),
"bootScripts"
)
));
bootStartScripts
.
getConventionMapping
().
map
(
"applicationName"
,
bootStartScripts
.
setApplicationName
(
()
->
applicationConvention
.
getApplicationName
(
));
project
.
provider
(()
->
applicationConvention
.
getApplicationName
()
));
CopySpec
binCopySpec
=
project
.
copySpec
().
into
(
"bin"
).
from
(
bootStartScripts
);
CopySpec
binCopySpec
=
project
.
copySpec
().
into
(
"bin"
).
from
(
bootStartScripts
);
binCopySpec
.
setFileMode
(
0x755
);
binCopySpec
.
setFileMode
(
0x755
);
distribution
.
getContents
().
with
(
binCopySpec
);
distribution
.
getContents
().
with
(
binCopySpec
);
...
...
spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/application/CreateBootStartScripts.java
View file @
6d8c3330
...
@@ -16,7 +16,13 @@
...
@@ -16,7 +16,13 @@
package
org
.
springframework
.
boot
.
gradle
.
tasks
.
application
;
package
org
.
springframework
.
boot
.
gradle
.
tasks
.
application
;
import
java.io.File
;
import
org.gradle.api.provider.PropertyState
;
import
org.gradle.api.provider.Provider
;
import
org.gradle.api.tasks.Input
;
import
org.gradle.api.tasks.Optional
;
import
org.gradle.api.tasks.Optional
;
import
org.gradle.api.tasks.OutputDirectory
;
import
org.gradle.jvm.application.tasks.CreateStartScripts
;
import
org.gradle.jvm.application.tasks.CreateStartScripts
;
/**
/**
...
@@ -27,10 +33,54 @@ import org.gradle.jvm.application.tasks.CreateStartScripts;
...
@@ -27,10 +33,54 @@ import org.gradle.jvm.application.tasks.CreateStartScripts;
*/
*/
public
class
CreateBootStartScripts
extends
CreateStartScripts
{
public
class
CreateBootStartScripts
extends
CreateStartScripts
{
private
final
PropertyState
<
File
>
outputDir
=
getProject
().
property
(
File
.
class
);
private
final
PropertyState
<
String
>
applicationName
=
getProject
()
.
property
(
String
.
class
);
@Override
@Override
@Optional
@Optional
public
String
getMainClassName
()
{
public
String
getMainClassName
()
{
return
super
.
getMainClassName
();
return
super
.
getMainClassName
();
}
}
@Input
@Override
public
String
getApplicationName
()
{
return
this
.
applicationName
.
getOrNull
();
}
@Override
public
void
setApplicationName
(
String
applicationName
)
{
this
.
applicationName
.
set
(
applicationName
);
}
/**
* Sets the application name to the value from the given
* {@code applicationNameProvider}.
* @param applicationNameProvider the provider of the application name
*/
public
void
setApplicationName
(
Provider
<
String
>
applicationNameProvider
)
{
this
.
applicationName
.
set
(
applicationNameProvider
);
}
@Override
@OutputDirectory
public
File
getOutputDir
()
{
return
this
.
outputDir
.
getOrNull
();
}
@Override
public
void
setOutputDir
(
File
outputDir
)
{
this
.
outputDir
.
set
(
outputDir
);
}
/**
* Sets the output directory to the value from the given {@code outputDirProvider}.
* @param outputDirProvider the provider of the output directory
*/
public
void
setOutputDir
(
Provider
<
File
>
outputDirProvider
)
{
this
.
outputDir
.
set
(
outputDirProvider
);
}
}
}
spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/buildinfo/BuildInfo.java
View file @
6d8c3330
...
@@ -26,6 +26,8 @@ import org.gradle.api.Action;
...
@@ -26,6 +26,8 @@ import org.gradle.api.Action;
import
org.gradle.api.Project
;
import
org.gradle.api.Project
;
import
org.gradle.api.Task
;
import
org.gradle.api.Task
;
import
org.gradle.api.internal.ConventionTask
;
import
org.gradle.api.internal.ConventionTask
;
import
org.gradle.api.provider.PropertyState
;
import
org.gradle.api.provider.Provider
;
import
org.gradle.api.tasks.Input
;
import
org.gradle.api.tasks.Input
;
import
org.gradle.api.tasks.OutputDirectory
;
import
org.gradle.api.tasks.OutputDirectory
;
import
org.gradle.api.tasks.TaskAction
;
import
org.gradle.api.tasks.TaskAction
;
...
@@ -44,7 +46,7 @@ public class BuildInfo extends ConventionTask {
...
@@ -44,7 +46,7 @@ public class BuildInfo extends ConventionTask {
private
final
BuildInfoProperties
properties
=
new
BuildInfoProperties
(
getProject
());
private
final
BuildInfoProperties
properties
=
new
BuildInfoProperties
(
getProject
());
private
File
destinationDir
;
private
PropertyState
<
File
>
destinationDir
=
getProject
().
property
(
File
.
class
)
;
/**
/**
* Generates the {@code build-info.properties} file in the configured
* Generates the {@code build-info.properties} file in the configured
...
@@ -76,23 +78,30 @@ public class BuildInfo extends ConventionTask {
...
@@ -76,23 +78,30 @@ public class BuildInfo extends ConventionTask {
*/
*/
@OutputDirectory
@OutputDirectory
public
File
getDestinationDir
()
{
public
File
getDestinationDir
()
{
return
this
.
destinationDir
!=
null
?
this
.
destinationDir
return
this
.
destinationDir
.
isPresent
()
?
this
.
destinationDir
.
get
()
:
getProject
().
getBuildDir
();
:
getProject
().
getBuildDir
();
}
}
/**
/**
* Sets the directory to which the {@code build-info.properties} file will be written.
* Sets the directory to which the {@code build-info.properties} file will be written.
*
* @param destinationDir the destination directory
* @param destinationDir the destination directory
*/
*/
public
void
setDestinationDir
(
File
destinationDir
)
{
public
void
setDestinationDir
(
File
destinationDir
)
{
this
.
destinationDir
=
destinationDir
;
this
.
destinationDir
.
set
(
destinationDir
);
}
/**
* Sets the directory to which the {@code build-info.properties} file will be written
* to the value from the given {@code destinationDirProvider}.
* @param destinationDirProvider the provider of the destination directory
*/
public
void
setDestinationDir
(
Provider
<
File
>
destinationDirProvider
)
{
this
.
destinationDir
.
set
(
destinationDirProvider
);
}
}
/**
/**
* Returns the {@link BuildInfoProperties properties} that will be included in the
* Returns the {@link BuildInfoProperties properties} that will be included in the
* {@code build-info.properties} file.
* {@code build-info.properties} file.
*
* @return the properties
* @return the properties
*/
*/
@Input
@Input
...
@@ -102,7 +111,6 @@ public class BuildInfo extends ConventionTask {
...
@@ -102,7 +111,6 @@ public class BuildInfo extends ConventionTask {
/**
/**
* Executes the given {@code action} on the {@link #getProperties()} properties.
* Executes the given {@code action} on the {@link #getProperties()} properties.
*
* @param action the action
* @param action the action
*/
*/
public
void
properties
(
Action
<
BuildInfoProperties
>
action
)
{
public
void
properties
(
Action
<
BuildInfoProperties
>
action
)
{
...
...
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