Skip to content

Commit

Permalink
Merge pull request #1228 from pascalgrimaud/maven-context
Browse files Browse the repository at this point in the history
Maven context
  • Loading branch information
pascalgrimaud authored Apr 3, 2022
2 parents bad1327 + f6ceaa9 commit e4e101d
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Maven

## Description

This context is used to add Maven to an existing project:

- `pom.xml` for Java with some libraries
- maven wrapper

This context is used by other contexts for:

- managing dependencies
- adding properties
- adding plugins
- etc.

## Maintainers

- [Pascal Grimaud](https://github.com/pascalgrimaud)
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public MavenResource(MavenApplicationService mavenApplicationService) {
@Operation(summary = "Init", description = "Init Maven project with pom.xml and wrapper")
@ApiResponse(responseCode = "500", description = "An error occurred while initializing Maven project")
@PostMapping
@GeneratorStep(id = GeneratorAction.MAVEN)
@GeneratorStep(id = GeneratorAction.MAVEN_JAVA)
public void init(@RequestBody ProjectDTO projectDTO) {
Project project = ProjectDTO.toProject(projectDTO);
mavenApplicationService.init(project);
Expand All @@ -36,7 +36,7 @@ public void init(@RequestBody ProjectDTO projectDTO) {
@Operation(summary = "Add pom.xml")
@ApiResponse(responseCode = "500", description = "An error occurred while adding pom.xml to project")
@PostMapping("/pom-xml")
@GeneratorStep(id = GeneratorAction.POM_XML)
@GeneratorStep(id = GeneratorAction.MAVEN_JAVA_POM_XML)
public void addPomXml(@RequestBody ProjectDTO projectDTO) {
Project project = ProjectDTO.toProject(projectDTO);
mavenApplicationService.addPomXml(project);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@ public class GeneratorAction {

private GeneratorAction() {}

// init
// Init
public static final String INIT = "init";
public static final String DOWNLOAD = "download";

// Maven
public static final String MAVEN_JAVA = "maven-java";
public static final String MAVEN_JAVA_POM_XML = "maven-java-pom-xml";
public static final String MAVEN_WRAPPER = "maven-wrapper";

public static final String NPM_INSTALL = "npm-install";
public static final String NPM_PRETTIFY = "npm-prettify";

Expand All @@ -25,10 +30,6 @@ private GeneratorAction() {}
public static final String SVELTE = "svelte";
public static final String SVEKTEKIT_STYLE = "svektekit-styled";

public static final String MAVEN = "maven";
public static final String POM_XML = "pom.xml";
public static final String MAVEN_WRAPPER = "maven-wrapper";

public static final String CONSUL = "consul";

public static final String EHCACHE_WITH_JAVA_CONFIG = "ehcache-with-java-config";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import tech.jhipster.lite.TestUtils;
import tech.jhipster.lite.common.domain.FileUtils;
import tech.jhipster.lite.error.domain.GeneratorException;
import tech.jhipster.lite.generator.project.domain.GeneratorAction;
import tech.jhipster.lite.generator.project.infrastructure.primary.dto.ProjectDTO;

@IntegrationTest
Expand Down Expand Up @@ -53,8 +54,8 @@ void shouldGetHistory() throws Exception {
.perform(get("/api/projects/history").param("folder", projectDTO.getFolder()))
.andExpect(status().isOk())
.andExpect(jsonPath("$.serviceIds", Matchers.hasSize(3)))
.andExpect(jsonPath("$.serviceIds[0]").value("init"))
.andExpect(jsonPath("$.serviceIds[1]").value("maven"))
.andExpect(jsonPath("$.serviceIds[2]").value("github-actions"));
.andExpect(jsonPath("$.serviceIds[0]").value(GeneratorAction.INIT))
.andExpect(jsonPath("$.serviceIds[1]").value(GeneratorAction.MAVEN_JAVA))
.andExpect(jsonPath("$.serviceIds[2]").value(GeneratorAction.GITHUB_ACTIONS));
}
}

0 comments on commit e4e101d

Please sign in to comment.