-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: sample module that add a maven dependency
- Loading branch information
Showing
10 changed files
with
332 additions
and
1 deletion.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
...erver/springboot/startupreport/application/SpringBootStartupReportApplicationService.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,20 @@ | ||
package tech.jhipster.lite.extension.generator.server.springboot.startupreport.application; | ||
|
||
import org.springframework.stereotype.Service; | ||
import tech.jhipster.lite.extension.generator.server.springboot.startupreport.domain.SpringBootStartupReportModuleFactory; | ||
import tech.jhipster.lite.module.domain.JHipsterModule; | ||
import tech.jhipster.lite.module.domain.properties.JHipsterModuleProperties; | ||
|
||
@Service | ||
public class SpringBootStartupReportApplicationService { | ||
|
||
private final SpringBootStartupReportModuleFactory factory; | ||
|
||
public SpringBootStartupReportApplicationService() { | ||
this.factory = new SpringBootStartupReportModuleFactory(); | ||
} | ||
|
||
public JHipsterModule buildModule(JHipsterModuleProperties properties) { | ||
return factory.buildModule(properties); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
...enerator/server/springboot/startupreport/domain/SpringBootStartupReportModuleFactory.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,26 @@ | ||
package tech.jhipster.lite.extension.generator.server.springboot.startupreport.domain; | ||
|
||
import static tech.jhipster.lite.module.domain.JHipsterModule.javaDependency; | ||
import static tech.jhipster.lite.module.domain.JHipsterModule.moduleBuilder; | ||
|
||
import tech.jhipster.lite.module.domain.JHipsterModule; | ||
import tech.jhipster.lite.module.domain.javadependency.JavaDependency; | ||
import tech.jhipster.lite.module.domain.properties.JHipsterModuleProperties; | ||
import tech.jhipster.lite.shared.error.domain.Assert; | ||
|
||
public class SpringBootStartupReportModuleFactory { | ||
|
||
public JHipsterModule buildModule(JHipsterModuleProperties properties) { | ||
Assert.notNull("properties", properties); | ||
return moduleBuilder(properties).javaDependencies().addDependency(startupReportDependency()).and().build(); | ||
} | ||
|
||
private JavaDependency startupReportDependency() { | ||
return javaDependency() | ||
.groupId("com.maciejwalkowiak.spring") | ||
.artifactId("spring-boot-startup-report") | ||
.versionSlug("spring-boot-startup-report") | ||
.optional() | ||
.build(); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
...boot/startupreport/infrastructure/primary/SpringBootStartupReportModuleConfiguration.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,28 @@ | ||
package tech.jhipster.lite.extension.generator.server.springboot.startupreport.infrastructure.primary; | ||
|
||
import static tech.jhipster.lite.extension.shared.slug.domain.JhliteExtensionSampleModuleSlug.*; | ||
import static tech.jhipster.lite.shared.slug.domain.JHLiteModuleSlug.SPRING_BOOT; | ||
|
||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import tech.jhipster.lite.extension.generator.server.springboot.startupreport.application.SpringBootStartupReportApplicationService; | ||
import tech.jhipster.lite.module.domain.resource.JHipsterModuleOrganization; | ||
import tech.jhipster.lite.module.domain.resource.JHipsterModuleResource; | ||
|
||
@Configuration | ||
class SpringBootStartupReportModuleConfiguration { | ||
|
||
@Bean | ||
JHipsterModuleResource springBootStartupReportResource(SpringBootStartupReportApplicationService springBootStartupReport) { | ||
return JHipsterModuleResource.builder() | ||
.slug(SPRING_BOOT_STARTUP_REPORT) | ||
.withoutProperties() | ||
.apiDoc( | ||
"Spring Boot", | ||
"Generates an interactive Spring Boot application startup report that lets you understand what contributes to the application startup time and perhaps helps to optimize it" | ||
) | ||
.organization(JHipsterModuleOrganization.builder().addDependency(SPRING_BOOT).build()) | ||
.tags("server", "spring", "spring-boot") | ||
.factory(springBootStartupReport::buildModule); | ||
} | ||
} |
2 changes: 2 additions & 0 deletions
2
.../tech/jhipster/lite/extension/generator/server/springboot/startupreport/package-info.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,2 @@ | ||
@tech.jhipster.lite.BusinessContext | ||
package tech.jhipster.lite.extension.generator.server.springboot.startupreport; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Feature: Prettier Plugins | ||
|
||
Scenario: Should apply properties plugin | ||
When I apply "spring-boot-startup-report" module to default project with maven file without parameters | ||
Then I should have "spring-boot-startup-report" in "pom.xml" |
45 changes: 45 additions & 0 deletions
45
...ator/server/springboot/startupreport/domain/SpringBootStartupReportModuleFactoryTest.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,45 @@ | ||
package tech.jhipster.lite.extension.generator.server.springboot.startupreport.domain; | ||
|
||
import static tech.jhipster.lite.module.infrastructure.secondary.JHipsterModulesAssertions.*; | ||
|
||
import org.junit.jupiter.api.AfterEach; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import tech.jhipster.lite.TestFileUtils; | ||
import tech.jhipster.lite.extension.UnitTest; | ||
import tech.jhipster.lite.extension.shared.dependencies.infrastructure.secondary.JhliteExtensionSampleMavenDependenciesReader; | ||
import tech.jhipster.lite.module.domain.JHipsterModule; | ||
import tech.jhipster.lite.module.domain.JHipsterModulesFixture; | ||
import tech.jhipster.lite.module.domain.properties.JHipsterModuleProperties; | ||
import tech.jhipster.lite.module.infrastructure.secondary.FileSystemProjectFiles; | ||
import tech.jhipster.lite.module.infrastructure.secondary.JHipsterModulesAssertions; | ||
import tech.jhipster.lite.module.infrastructure.secondary.TestJHipsterModules; | ||
|
||
@UnitTest | ||
class SpringBootStartupReportModuleFactoryTest { | ||
|
||
private final SpringBootStartupReportModuleFactory factory = new SpringBootStartupReportModuleFactory(); | ||
|
||
@BeforeEach | ||
void setup() { | ||
TestJHipsterModules.register(new JhliteExtensionSampleMavenDependenciesReader(new FileSystemProjectFiles())); | ||
} | ||
|
||
@AfterEach | ||
void tearDown() { | ||
TestJHipsterModules.unregisterReaders(); | ||
} | ||
|
||
@Test | ||
void shouldBuildPropertiesPluginModule() { | ||
JHipsterModuleProperties properties = JHipsterModulesFixture.propertiesBuilder(TestFileUtils.tmpDirForTest()).build(); | ||
|
||
JHipsterModule module = factory.buildModule(properties); | ||
|
||
assertThatModuleWithFiles(module, pomFile()).hasFile("pom.xml").containing("spring-boot-startup-report"); | ||
} | ||
|
||
public static JHipsterModulesAssertions.ModuleFile pomFile() { | ||
return file("src/test/resources/projects/init-maven/pom.xml", "pom.xml"); | ||
} | ||
} |
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,196 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<project | ||
xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" | ||
> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>tech.jhipster.jhlitest</groupId> | ||
<artifactId>myapp</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
<name>myapp</name> | ||
<description>My App</description> | ||
<packaging>jar</packaging> | ||
|
||
<!-- jhipster-needle-maven-parent --> | ||
|
||
<repositories> | ||
<!-- jhipster-needle-maven-repository --> | ||
</repositories> | ||
|
||
<pluginRepositories> | ||
<!-- jhipster-needle-maven-plugin-repository --> | ||
</pluginRepositories> | ||
|
||
<properties> | ||
<java.version>21</java.version> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> | ||
|
||
<maven.version>3.6.3</maven.version> | ||
<maven-enforcer-plugin.version>3.0.0</maven-enforcer-plugin.version> | ||
|
||
<junit-jupiter.version>5.8.2</junit-jupiter.version> | ||
<assertj.version>3.22.0</assertj.version> | ||
<mockito.version>4.2.0</mockito.version> | ||
<compiler-plugin.version>3.8.1</compiler-plugin.version> | ||
<surefire-plugin.version>3.0.0-M5</surefire-plugin.version> | ||
<!-- jhipster-needle-maven-property --> | ||
</properties> | ||
|
||
<dependencyManagement> | ||
<dependencies> | ||
<!-- jhipster-needle-maven-add-dependency-management --> | ||
</dependencies> | ||
</dependencyManagement> | ||
|
||
<dependencies> | ||
<!-- jhipster-needle-maven-add-dependency --> | ||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-engine</artifactId> | ||
<version>${junit-jupiter.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-params</artifactId> | ||
<version>${junit-jupiter.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.assertj</groupId> | ||
<artifactId>assertj-core</artifactId> | ||
<version>${assertj.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.mockito</groupId> | ||
<artifactId>mockito-junit-jupiter</artifactId> | ||
<version>${mockito.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.mockito</groupId> | ||
<artifactId>mockito-inline</artifactId> | ||
<version>${mockito.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<!-- jhipster-needle-maven-add-dependency-test --> | ||
</dependencies> | ||
|
||
<build> | ||
<resources> | ||
<resource> | ||
<directory>${basedir}/src/main/resources</directory> | ||
<filtering>true</filtering> | ||
<includes> | ||
<include>config/*.properties</include> | ||
<include>config/*.yml</include> | ||
</includes> | ||
</resource> | ||
<resource> | ||
<directory>${basedir}/src/main/resources</directory> | ||
<excludes> | ||
<exclude>config/*.properties</exclude> | ||
<exclude>config/*.yml</exclude> | ||
</excludes> | ||
</resource> | ||
</resources> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>${compiler-plugin.version}</version> | ||
<configuration> | ||
<release>${java.version}</release> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<version>${surefire-plugin.version}</version> | ||
<configuration> | ||
<!-- Force alphabetical order to have a reproducible build --> | ||
<runOrder>alphabetical</runOrder> | ||
<excludes> | ||
<exclude>**/*IT*</exclude> | ||
</excludes> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-failsafe-plugin</artifactId> | ||
<version>${surefire-plugin.version}</version> | ||
<configuration> | ||
<!-- Due to spring-boot repackage, without adding this property test classes are not found | ||
See https://github.com/spring-projects/spring-boot/issues/6254 --> | ||
<classesDirectory>${project.build.outputDirectory}</classesDirectory> | ||
<!-- Force alphabetical order to have a reproducible build --> | ||
<runOrder>alphabetical</runOrder> | ||
<includes> | ||
<include>**/*IT*</include> | ||
</includes> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<id>integration-test</id> | ||
<goals> | ||
<goal>integration-test</goal> | ||
</goals> | ||
</execution> | ||
<execution> | ||
<id>verify</id> | ||
<goals> | ||
<goal>verify</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<!-- jhipster-needle-maven-add-plugin --> | ||
</plugins> | ||
<pluginManagement> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-enforcer-plugin</artifactId> | ||
<version>${maven-enforcer-plugin.version}</version> | ||
<executions> | ||
<execution> | ||
<id>enforce-versions</id> | ||
<goals> | ||
<goal>enforce</goal> | ||
</goals> | ||
</execution> | ||
<execution> | ||
<id>enforce-dependencyConvergence</id> | ||
<configuration> | ||
<rules> | ||
<DependencyConvergence /> | ||
</rules> | ||
<fail>false</fail> | ||
</configuration> | ||
<goals> | ||
<goal>enforce</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
<configuration> | ||
<rules> | ||
<requireMavenVersion> | ||
<message>You are running an older version of Maven. JHipster requires at least Maven ${maven.version}</message> | ||
<version>[${maven.version},)</version> | ||
</requireMavenVersion> | ||
<requireJavaVersion> | ||
<message>You are running an incompatible version of Java. JHipster engine supports JDK 21+.</message> | ||
<version>[21,22)</version> | ||
</requireJavaVersion> | ||
</rules> | ||
</configuration> | ||
</plugin> | ||
<!-- jhipster-needle-maven-add-plugin-management --> | ||
</plugins> | ||
</pluginManagement> | ||
</build> | ||
</project> |
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