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
5708eaf4
Commit
5708eaf4
authored
Mar 28, 2017
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify the DSL extension to provide a solid foundation
parent
8048791a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
71 additions
and
319 deletions
+71
-319
SpringBootExtension.java
.../org/springframework/boot/gradle/SpringBootExtension.java
+69
-0
SpringBootPluginExtension.java
...pringframework/boot/gradle/SpringBootPluginExtension.java
+0
-317
SpringBootPlugin.java
.../springframework/boot/gradle/plugin/SpringBootPlugin.java
+2
-2
No files found.
spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/SpringBootExtension.java
0 → 100644
View file @
5708eaf4
/*
* Copyright 2012-2017 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
springframework
.
boot
.
gradle
;
import
org.gradle.api.Action
;
import
org.gradle.api.Project
;
import
org.gradle.api.plugins.JavaPlugin
;
import
org.springframework.boot.gradle.buildinfo.BuildInfo
;
/**
* Gradle DSL extension that provides the entry point to Spring Boot's DSL.
*
* @author Andy Wilkinson
*/
public
class
SpringBootExtension
{
private
final
Project
project
;
/**
* Creates a new {@code SpringBootPluginExtension} that is associated with the given
* {@code project}.
*
* @param project the project
*/
public
SpringBootExtension
(
Project
project
)
{
this
.
project
=
project
;
}
/**
* Creates a new {@link BuildInfo} task named {@code bootBuildInfo} and configures the
* {@code classes} task to depend upon it.
*/
public
void
buildInfo
()
{
this
.
buildInfo
(
null
);
}
/**
* Creates a new {@link BuildInfo} task named {@code bootBuildInfo} and configures the
* {@code classes} task to depend upon it. The task is passed to the given
* {@code configurer} for further configuration.
*
* @param configurer the task configurer
*/
public
void
buildInfo
(
Action
<
BuildInfo
>
configurer
)
{
BuildInfo
bootBuildInfo
=
this
.
project
.
getTasks
().
create
(
"bootBuildInfo"
,
BuildInfo
.
class
);
this
.
project
.
getTasks
().
getByName
(
JavaPlugin
.
CLASSES_TASK_NAME
)
.
dependsOn
(
bootBuildInfo
);
if
(
configurer
!=
null
)
{
configurer
.
execute
(
bootBuildInfo
);
}
}
}
spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/SpringBootPluginExtension.java
deleted
100644 → 0
View file @
8048791a
/*
* Copyright 2012-2017 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
springframework
.
boot
.
gradle
;
import
java.io.File
;
import
java.util.Map
;
import
java.util.Set
;
import
groovy.lang.Closure
;
import
org.gradle.api.Project
;
import
org.gradle.api.plugins.JavaPlugin
;
import
org.springframework.boot.gradle.buildinfo.BuildInfo
;
import
org.springframework.boot.loader.tools.Layout
;
import
org.springframework.boot.loader.tools.LayoutFactory
;
import
org.springframework.boot.loader.tools.Layouts
;
/**
* Gradle DSL Extension for 'Spring Boot'. Most of the time Spring Boot can guess the
* settings in this extension, but occasionally you might need to explicitly set one or
* two of them. E.g.
*
* <pre>
* apply plugin: 'org.springframework.boot'
* springBoot {
* mainClass = 'org.demo.Application'
* layout = 'ZIP'
* }
* </pre>
*
* @author Phillip Webb
* @author Dave Syer
* @author Stephane Nicoll
* @author Andy Wilkinson
*/
public
class
SpringBootPluginExtension
{
private
final
Project
project
;
/**
* The main class that should be run. Instead of setting this explicitly you can use
* the 'mainClassName' of the project or the 'main' of the 'run' task. If not
* specified the value from the MANIFEST will be used, or if no manifest entry is the
* archive will be searched for a suitable class.
*/
String
mainClass
;
/**
* The classifier (file name part before the extension). Instead of setting this
* explicitly you can use the 'classifier' property of the 'bootRepackage' task. If
* not specified the archive will be replaced instead of renamed.
*/
String
classifier
;
/**
* The name of the ivy configuration name to treat as 'provided' (when packaging those
* dependencies in a separate path). If not specified 'providedRuntime' will be used.
*/
String
providedConfiguration
;
/**
* The name of the custom configuration to use.
*/
String
customConfiguration
;
/**
* If the original source archive should be backed-up before being repackaged.
*/
boolean
backupSource
=
true
;
/**
* The layout of the archive if it can't be derived from the file extension. Valid
* values are JAR, WAR, ZIP, DIR (for exploded zip file). ZIP and DIR are actually
* synonymous, and should be used if there is no MANIFEST.MF available, or if you want
* the MANIFEST.MF 'Main-Class' to be PropertiesLauncher. Gradle will coerce literal
* String values to the correct type.
*/
LayoutType
layout
;
/**
* The layout factory that will be used when no explicit layout is specified.
* Alternative layouts can be provided by 3rd parties.
*/
LayoutFactory
layoutFactory
;
/**
* Libraries that must be unpacked from fat jars in order to run. Use Strings in the
* form {@literal groupId:artifactId}.
*/
Set
<
String
>
requiresUnpack
;
/**
* Whether Spring Boot Devtools should be excluded from the fat jar.
*/
boolean
excludeDevtools
=
true
;
/**
* Location of an agent jar to attach to the VM when running the application with
* runJar task.
*/
File
agent
;
/**
* Flag to indicate that the agent requires -noverify (and the plugin will refuse to
* start if it is not set).
*/
Boolean
noverify
;
/**
* If exclude rules should be applied to dependencies based on the
* spring-dependencies-bom.
*/
boolean
applyExcludeRules
=
true
;
/**
* If a fully executable jar (for *nix machines) should be generated by prepending a
* launch script to the jar.
*/
boolean
executable
=
false
;
/**
* The embedded launch script to prepend to the front of the jar if it is fully
* executable. If not specified the 'Spring Boot' default script will be used.
*/
File
embeddedLaunchScript
;
/**
* Properties that should be expanded in the embedded launch script.
*/
Map
<
String
,
String
>
embeddedLaunchScriptProperties
;
public
SpringBootPluginExtension
(
Project
project
)
{
this
.
project
=
project
;
}
/**
* Convenience method for use in a custom task.
* @return the Layout to use or null if not explicitly set
*/
public
Layout
convertLayout
()
{
return
(
this
.
layout
==
null
?
null
:
this
.
layout
.
layout
);
}
public
String
getMainClass
()
{
return
this
.
mainClass
;
}
public
void
setMainClass
(
String
mainClass
)
{
this
.
mainClass
=
mainClass
;
}
public
String
getClassifier
()
{
return
this
.
classifier
;
}
public
void
setClassifier
(
String
classifier
)
{
this
.
classifier
=
classifier
;
}
public
String
getProvidedConfiguration
()
{
return
this
.
providedConfiguration
;
}
public
void
setProvidedConfiguration
(
String
providedConfiguration
)
{
this
.
providedConfiguration
=
providedConfiguration
;
}
public
String
getCustomConfiguration
()
{
return
this
.
customConfiguration
;
}
public
void
setCustomConfiguration
(
String
customConfiguration
)
{
this
.
customConfiguration
=
customConfiguration
;
}
public
boolean
isBackupSource
()
{
return
this
.
backupSource
;
}
public
void
setBackupSource
(
boolean
backupSource
)
{
this
.
backupSource
=
backupSource
;
}
public
LayoutType
getLayout
()
{
return
this
.
layout
;
}
public
void
setLayout
(
LayoutType
layout
)
{
this
.
layout
=
layout
;
}
public
LayoutFactory
getLayoutFactory
()
{
return
this
.
layoutFactory
;
}
public
void
setLayoutFactory
(
LayoutFactory
layoutFactory
)
{
this
.
layoutFactory
=
layoutFactory
;
}
public
Set
<
String
>
getRequiresUnpack
()
{
return
this
.
requiresUnpack
;
}
public
void
setRequiresUnpack
(
Set
<
String
>
requiresUnpack
)
{
this
.
requiresUnpack
=
requiresUnpack
;
}
public
boolean
isExcludeDevtools
()
{
return
this
.
excludeDevtools
;
}
public
void
setExcludeDevtools
(
boolean
excludeDevtools
)
{
this
.
excludeDevtools
=
excludeDevtools
;
}
public
File
getAgent
()
{
return
this
.
agent
;
}
public
void
setAgent
(
File
agent
)
{
this
.
agent
=
agent
;
}
public
Boolean
getNoverify
()
{
return
this
.
noverify
;
}
public
void
setNoverify
(
Boolean
noverify
)
{
this
.
noverify
=
noverify
;
}
public
boolean
isApplyExcludeRules
()
{
return
this
.
applyExcludeRules
;
}
public
void
setApplyExcludeRules
(
boolean
applyExcludeRules
)
{
this
.
applyExcludeRules
=
applyExcludeRules
;
}
public
boolean
isExecutable
()
{
return
this
.
executable
;
}
public
void
setExecutable
(
boolean
executable
)
{
this
.
executable
=
executable
;
}
public
File
getEmbeddedLaunchScript
()
{
return
this
.
embeddedLaunchScript
;
}
public
void
setEmbeddedLaunchScript
(
File
embeddedLaunchScript
)
{
this
.
embeddedLaunchScript
=
embeddedLaunchScript
;
}
public
Map
<
String
,
String
>
getEmbeddedLaunchScriptProperties
()
{
return
this
.
embeddedLaunchScriptProperties
;
}
public
void
setEmbeddedLaunchScriptProperties
(
Map
<
String
,
String
>
embeddedLaunchScriptProperties
)
{
this
.
embeddedLaunchScriptProperties
=
embeddedLaunchScriptProperties
;
}
public
void
buildInfo
()
{
this
.
buildInfo
(
null
);
}
public
void
buildInfo
(
Closure
<?>
taskConfigurer
)
{
BuildInfo
bootBuildInfo
=
this
.
project
.
getTasks
().
create
(
"bootBuildInfo"
,
BuildInfo
.
class
);
this
.
project
.
getTasks
().
getByName
(
JavaPlugin
.
CLASSES_TASK_NAME
)
.
dependsOn
(
bootBuildInfo
);
if
(
taskConfigurer
!=
null
)
{
taskConfigurer
.
setDelegate
(
bootBuildInfo
);
taskConfigurer
.
call
();
}
}
/**
* Layout Types.
*/
enum
LayoutType
{
JAR
(
new
Layouts
.
Jar
()),
WAR
(
new
Layouts
.
War
()),
ZIP
(
new
Layouts
.
Expanded
()),
DIR
(
new
Layouts
.
Expanded
()),
NONE
(
new
Layouts
.
None
());
Layout
layout
;
LayoutType
(
Layout
layout
)
{
this
.
layout
=
layout
;
}
}
}
spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/plugin/SpringBootPlugin.java
View file @
5708eaf4
...
...
@@ -22,7 +22,7 @@ import org.gradle.api.Project;
import
org.gradle.api.Task
;
import
org.gradle.api.tasks.compile.JavaCompile
;
import
org.springframework.boot.gradle.SpringBoot
Plugin
Extension
;
import
org.springframework.boot.gradle.SpringBootExtension
;
import
org.springframework.boot.gradle.application.ApplicationPluginFeatures
;
import
org.springframework.boot.gradle.bundling.BundlingPluginFeatures
;
import
org.springframework.boot.gradle.dependencymanagement.DependencyManagementPluginFeatures
;
...
...
@@ -39,7 +39,7 @@ public class SpringBootPlugin implements Plugin<Project> {
@Override
public
void
apply
(
Project
project
)
{
project
.
getExtensions
().
create
(
"springBoot"
,
SpringBoot
Plugin
Extension
.
class
,
project
.
getExtensions
().
create
(
"springBoot"
,
SpringBootExtension
.
class
,
project
);
new
ApplicationPluginFeatures
().
apply
(
project
);
new
BundlingPluginFeatures
().
apply
(
project
);
...
...
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