Skip to content

Commit b168932

Browse files
authored
Merge pull request #14921 from apache/spring-dev-tools-default
Set spring boot dev tools as a default feature in forge to match profiles
2 parents e8701f1 + 68cb2a0 commit b168932

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

grails-forge/grails-forge-core/src/main/java/org/grails/forge/build/gradle/GradleDependency.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,10 @@ public String toSnippet() {
116116
if (isPom() || gradleConfiguration == INTEGRATION_TEST_IMPLEMENTATION_TEST_FIXTURES) {
117117
snippet += ")";
118118
}
119+
if (getArtifactId() == "spring-boot-devtools") {
120+
snippet += " // Spring Boot DevTools may cause performance slowdowns or compatibility issues on larger applications";
121+
}
122+
119123
return snippet;
120124
}
121125
}

grails-forge/grails-forge-core/src/main/java/org/grails/forge/feature/reloading/SpringBootDevTools.java

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,18 @@
1919
package org.grails.forge.feature.reloading;
2020

2121
import jakarta.inject.Singleton;
22+
import org.grails.forge.application.ApplicationType;
2223
import org.grails.forge.application.generator.GeneratorContext;
2324
import org.grails.forge.build.dependencies.Dependency;
2425
import org.grails.forge.build.dependencies.Scope;
26+
import org.grails.forge.feature.DefaultFeature;
27+
import org.grails.forge.feature.Feature;
28+
import org.grails.forge.options.Options;
2529

30+
import java.util.Set;
2631

2732
@Singleton
28-
public class SpringBootDevTools implements ReloadingFeature {
33+
public class SpringBootDevTools implements ReloadingFeature, DefaultFeature {
2934
@Override
3035
public String getName() {
3136
return "spring-boot-devtools";
@@ -54,8 +59,18 @@ public boolean isVisible() {
5459
return true;
5560
}
5661

62+
@Override
63+
public boolean shouldApply(ApplicationType applicationType, Options options, Set<Feature> selectedFeatures) {
64+
return true;
65+
}
66+
67+
@Override
68+
public boolean supports(ApplicationType applicationType) {
69+
return true;
70+
}
71+
5772
@Override
5873
public String getDocumentation() {
59-
return "https://docs.spring.io/spring-boot/docs/2.7.12/reference/htmlsingle/#using.devtools";
74+
return "https://docs.spring.io/spring-boot/reference/using/devtools.html";
6075
}
6176
}

grails-gradle/plugins/src/main/groovy/org/grails/gradle/plugin/core/GrailsGradlePlugin.groovy

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -846,6 +846,11 @@ class GrailsGradlePlugin extends GroovyPlugin {
846846
SourceSet mainSourceSet = SourceSets.findMainSourceSet(project)
847847
it.classpath = mainSourceSet.runtimeClasspath + project.configurations.getByName('console')
848848
it.systemProperty(Environment.KEY, System.getProperty(Environment.KEY, Environment.DEVELOPMENT.getName()))
849+
850+
// devtools' automatic restart mechanism uses a specialized classloader setup, which can interfere
851+
// with Grails' plugin management and bean wiring when running CLI scripts via Gradle
852+
it.systemProperty 'spring.devtools.restart.enabled', 'false'
853+
849854
List<Object> args = []
850855
def otherArgs = project.findProperty('args')
851856
if (otherArgs) {
@@ -873,6 +878,10 @@ class GrailsGradlePlugin extends GroovyPlugin {
873878
it.classpath = mainSourceSet.runtimeClasspath + project.configurations.getByName('console')
874879
it.systemProperty(Environment.KEY, System.getProperty(Environment.KEY, Environment.DEVELOPMENT.getName()))
875880

881+
// devtools' automatic restart mechanism uses a specialized classloader setup, which can interfere
882+
// with Grails' plugin management and bean wiring when running CLI commands via Gradle
883+
it.systemProperty 'spring.devtools.restart.enabled', 'false'
884+
876885
List<Object> args = []
877886
def otherArgs = project.findProperty('args')
878887
if (otherArgs) {

0 commit comments

Comments
 (0)