Skip to content

Commit

Permalink
Merge pull request #2150 from antarus/feature/devtools
Browse files Browse the repository at this point in the history
Update devtools  to new module system
  • Loading branch information
pascalgrimaud authored Jun 19, 2022
2 parents fa56fc1 + bd40346 commit c9c28e9
Show file tree
Hide file tree
Showing 13 changed files with 161 additions and 334 deletions.
Original file line number Diff line number Diff line change
@@ -1,27 +1,20 @@
package tech.jhipster.lite.generator.server.springboot.devtools.application;

import org.springframework.stereotype.Service;
import tech.jhipster.lite.generator.project.domain.Project;
import tech.jhipster.lite.generator.server.springboot.devtools.domain.DevToolsService;
import tech.jhipster.lite.generator.module.domain.JHipsterModule;
import tech.jhipster.lite.generator.module.domain.properties.JHipsterModuleProperties;
import tech.jhipster.lite.generator.server.springboot.devtools.domain.DevToolsModuleFactory;

@Service
public class DevToolsApplicationService {

private final DevToolsService devToolsService;
private final DevToolsModuleFactory devToolsFactory;

public DevToolsApplicationService(DevToolsService devToolsService) {
this.devToolsService = devToolsService;
public DevToolsApplicationService() {
devToolsFactory = new DevToolsModuleFactory();
}

public void init(Project project) {
devToolsService.init(project);
}

public void addSpringBootDevTools(Project project) {
devToolsService.addSpringBootDevTools(project);
}

public void addProperties(Project project) {
devToolsService.addProperties(project);
public JHipsterModule buildModule(JHipsterModuleProperties properties) {
return devToolsFactory.buildModule(properties);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package tech.jhipster.lite.generator.server.springboot.devtools.domain;

import static tech.jhipster.lite.generator.module.domain.JHipsterModule.*;

import tech.jhipster.lite.error.domain.Assert;
import tech.jhipster.lite.generator.module.domain.JHipsterModule;
import tech.jhipster.lite.generator.module.domain.JHipsterSource;
import tech.jhipster.lite.generator.module.domain.javadependency.GroupId;
import tech.jhipster.lite.generator.module.domain.javaproperties.SpringProfile;
import tech.jhipster.lite.generator.module.domain.properties.JHipsterModuleProperties;

public class DevToolsModuleFactory {

private static final GroupId SPRING_GROUP = groupId("org.springframework.boot");

private static final JHipsterSource SOURCE = from("server/springboot/devtools");

public JHipsterModule buildModule(JHipsterModuleProperties properties) {
Assert.notNull("properties", properties);

//@formatter:off
JHipsterModuleBuilder builder = moduleBuilder(properties)
.context()
.packageName(properties.basePackage())
.put("applicationName", properties.projectBaseName()
.capitalized())
.and();
//@formatter:on

appendDependencies(builder);
appendSpringProperties(builder);

builder.documentation(documentationTitle("Dev tools"), SOURCE.append("devtools.md.mustache"));

return builder.build();
}

private void appendDependencies(JHipsterModuleBuilder builder) {
builder.javaDependencies().add(SPRING_GROUP, artifactId("spring-boot-devtools"));
}

private void appendSpringProperties(JHipsterModuleBuilder builder) {
builder
.springMainProperties()
.set(propertyKey("spring.devtools.livereload.enabled"), propertyValue("false"))
.set(propertyKey("spring.devtools.restart.enabled"), propertyValue("false"));

builder
.springMainProperties(new SpringProfile("local"))
.set(propertyKey("spring.devtools.livereload.enabled"), propertyValue("true"))
.set(propertyKey("spring.devtools.restart.enabled"), propertyValue("true"));
}
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package tech.jhipster.lite.generator.server.springboot.devtools.infrastructure.primary;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import tech.jhipster.lite.generator.module.domain.properties.JHipsterModulePropertiesDefinition;
import tech.jhipster.lite.generator.module.infrastructure.primary.JHipsterModuleApiDoc;
import tech.jhipster.lite.generator.module.infrastructure.primary.JHipsterModuleResource;
import tech.jhipster.lite.generator.server.springboot.devtools.application.DevToolsApplicationService;

@Configuration
class DevToolsModuleConfiguration {

@Bean
JHipsterModuleResource devTools(DevToolsApplicationService devtools) {
return JHipsterModuleResource
.builder()
.legacyUrl("/api/servers/spring-boot/technical-tools/devtools")
.slug("springboot-devtools")
.propertiesDefinition(JHipsterModulePropertiesDefinition.builder().addBasePackage().addProjectBaseName().addIndentation().build())
.apiDoc(new JHipsterModuleApiDoc("Spring Boot - Tools", "Add spring boot tools."))
.factory(devtools::buildModule);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Introduction

Add the spring dev tool and enable it in local profile.

# How to use it

[official documentation:](https://docs.spring.io/spring-boot/docs/2.7.x/reference/html/using.html#using.devtools)

22 changes: 22 additions & 0 deletions src/test/features/dev-tools.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Feature: Cucumber module

Scenario: Should add devtools elements using legacy url
When I apply legacy module "/api/servers/spring-boot/technical-tools/devtools" to default project with maven file
Then I should have files in "documentation"
| dev-tools.md |

Scenario: Should get devtools module properties definition
When I get module "springboot-devtools" properties definition
Then I should have properties definitions
| Key | Type | Mandatory |
| packageName | STRING | true |
| baseName | STRING | true |
| prettierDefaultIndent | INTEGER | false |

Scenario: Should add devtools elements using module url
When I apply "springboot-devtools" module to default project with maven file
| packageName | tech.jhipster.chips |
| baseName | jhipster |
Then I should have files in "documentation"
| dev-tools.md |
And I should have history entry for "springboot-devtools"

This file was deleted.

Loading

0 comments on commit c9c28e9

Please sign in to comment.