-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #187 from grails/springbootdevtools
Add SpringBoot devtools feature
- Loading branch information
Showing
6 changed files
with
106 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
grails-forge-core/src/main/java/org/grails/forge/feature/reloading/SpringBootDevTools.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* Copyright 2017-2020 original 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 | ||
* | ||
* https://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.grails.forge.feature.reloading; | ||
|
||
import jakarta.inject.Singleton; | ||
import org.grails.forge.application.generator.GeneratorContext; | ||
import org.grails.forge.build.dependencies.Dependency; | ||
import org.grails.forge.build.dependencies.Scope; | ||
|
||
|
||
@Singleton | ||
public class SpringBootDevTools implements ReloadingFeature { | ||
@Override | ||
public String getName() { | ||
return "spring-boot-devtools"; | ||
} | ||
|
||
@Override | ||
public String getTitle() { | ||
return "SpringBoot Developer Tools"; | ||
} | ||
|
||
@Override | ||
public String getDescription() { | ||
return "Spring Boot Devtools is a powerful tool that enhances development productivity by providing features like automatic application restarts on code changes, live reloading of static resources, and remote debugging support. It enables developers to rapidly iterate and test changes during the development process, making it a valuable asset for Spring Boot projects."; | ||
} | ||
|
||
@Override | ||
public void apply(GeneratorContext generatorContext) { | ||
generatorContext.addDependency(Dependency.builder().groupId("org.springframework.boot") | ||
.artifactId("spring-boot-devtools") | ||
.scope(Scope.DEVELOPMENT_ONLY) | ||
.build()); | ||
} | ||
|
||
@Override | ||
public boolean isVisible() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public String getDocumentation() { | ||
return "https://docs.spring.io/spring-boot/docs/2.7.12/reference/htmlsingle/#using.devtools"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
...rge-core/src/test/groovy/org/grails/forge/feature/reloading/SpringBootDevToolsSpec.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package org.grails.forge.feature.reloading | ||
|
||
import org.grails.forge.ApplicationContextSpec | ||
import org.grails.forge.application.ApplicationType | ||
import org.grails.forge.feature.Features | ||
import org.grails.forge.fixture.CommandOutputFixture | ||
|
||
class SpringBootDevToolsSpec extends ApplicationContextSpec implements CommandOutputFixture { | ||
|
||
void "test spring-boot-devtools feature"() { | ||
|
||
when: | ||
final Features features = getFeatures(["spring-boot-devtools"]) | ||
|
||
then: | ||
features.contains("spring-boot-devtools") | ||
|
||
} | ||
|
||
void "test spring-boot-devtools dependency is present for #applicationType application type"() { | ||
|
||
when: | ||
def output = generate(applicationType, ["spring-boot-devtools"]) | ||
def build = output["build.gradle"] | ||
|
||
then: | ||
build.contains("developmentOnly(\"org.springframework.boot:spring-boot-devtools\"") | ||
|
||
where: | ||
applicationType << [ApplicationType.WEB, ApplicationType.REST_API] | ||
} | ||
|
||
void "test there can be only one of Reloading feature"() { | ||
when: | ||
getFeatures(beanContext.getBeansOfType(ReloadingFeature.class)*.name) | ||
|
||
then: | ||
def ex = thrown(IllegalArgumentException) | ||
ex.message.contains("There can only be one of the following features selected") | ||
} | ||
} |