Skip to content

Commit e831402

Browse files
committed
Upgrade to Spring Loaded 1.2.5 and allow agent config. Fixes #9309, #9201, #8817 and #9288
1 parent 62cbabc commit e831402

File tree

3 files changed

+55
-4
lines changed

3 files changed

+55
-4
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ ext {
4444
reactorVersion = '2.0.6.RELEASE'
4545

4646
spockVersion = '1.0-groovy-2.4'
47-
springLoadedVersion = "1.2.4.RELEASE"
47+
springLoadedVersion = "1.2.5.RELEASE"
4848
springBootVersion = "1.2.7.RELEASE"
4949
springLoadedCommonOptions = "-Xverify:none -Dspringloaded.synchronize=true -Djdk.reflect.allowGetCallerClass=true"
5050
springVersion = "4.1.8.RELEASE"

grails-gradle-plugin/src/main/groovy/org/grails/gradle/plugin/agent/AgentTasksEnhancer.groovy

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import org.gradle.api.Action
55
import org.gradle.api.Project
66
import org.gradle.api.Task
77
import org.gradle.api.tasks.JavaExec
8+
import org.grails.gradle.plugin.core.GrailsExtension
89

910
/**
1011
* Sets up the reloading agent based on the agent configuration after the project has been configured
@@ -31,8 +32,30 @@ class AgentTasksEnhancer implements Action<Project> {
3132
}
3233

3334
private void addAgent(Project project, JavaExec exec, File agent) {
34-
exec.jvmArgs "-javaagent:$agent.absolutePath"
35-
exec.jvmArgs "-Xverify:none"
36-
exec.jvmArgs "-Dspringloaded=inclusions=grails.plugins..*"
35+
36+
GrailsExtension.Agent agentConfig = project.extensions.findByType(GrailsExtension)?.agent ?: new GrailsExtension.Agent()
37+
38+
exec.jvmArgs "-javaagent:${agentConfig.path?.absolutePath ?: agent.absolutePath}"
39+
40+
for(arg in agentConfig.jvmArgs) {
41+
exec.jvmArgs arg
42+
}
43+
for(entry in agentConfig.systemProperties) {
44+
exec.systemProperty(entry.key, entry.value)
45+
}
46+
47+
Map<String, String> agentArgs= [
48+
inclusions: agentConfig.inclusions,
49+
synchronize: String.valueOf( agentConfig.synchronize ),
50+
allowSplitPackages: String.valueOf( agentConfig.allowSplitPackages ),
51+
cacheDir: agentConfig.cacheDir ? project.mkdir(agentConfig.cacheDir) : project.mkdir("build/springloaded")
52+
]
53+
if(agentConfig.logging != null) {
54+
agentArgs.put("logging", String.valueOf(agentConfig.logging))
55+
}
56+
if(agentConfig.exclusions) {
57+
agentArgs.put('exclusions', agentConfig.exclusions)
58+
}
59+
exec.systemProperty('springloaded', agentArgs.collect { entry -> "$entry.key=$entry.value"}.join(';'))
3760
}
3861
}

grails-gradle-plugin/src/main/groovy/org/grails/gradle/plugin/core/GrailsExtension.groovy

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.grails.gradle.plugin.core
22

33
import org.apache.tools.ant.taskdefs.condition.Os
4+
import org.gradle.util.ConfigureUtil
45

56
/**
67
* A extension to the Gradle plugin to configure Grails settings
@@ -19,4 +20,31 @@ class GrailsExtension {
1920
* Whether assets should be packaged in META-INF/assets for plugins
2021
*/
2122
boolean packageAssets = true
23+
24+
/**
25+
* Configure the reloading agent
26+
*/
27+
Agent agent = new Agent()
28+
29+
/**
30+
* Configure the reloading agent
31+
*/
32+
Agent agent(Closure configurer) {
33+
ConfigureUtil.configure(configurer, agent)
34+
}
35+
/**
36+
* Configuration for the reloading agent
37+
*/
38+
static class Agent {
39+
File path
40+
String inclusions = "grails.plugins..*"
41+
String exclusions
42+
Boolean logging
43+
boolean synchronize = true
44+
boolean allowSplitPackages = true
45+
File cacheDir = new File("build/springloaded")
46+
47+
Map<String, String> systemProperties = ['jdk.reflect.allowGetCallerClass': 'true']
48+
List<String> jvmArgs = ['-Xverify:none']
49+
}
2250
}

0 commit comments

Comments
 (0)