-
-
Notifications
You must be signed in to change notification settings - Fork 216
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP working but need to be reworked, add feature test, ci test, canno…
…t test on mssql
- Loading branch information
1 parent
0c7ee08
commit dff693e
Showing
24 changed files
with
985 additions
and
9 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
...er/lite/generator/server/springboot/database/jooq/application/JooqApplicationService.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,33 @@ | ||
package tech.jhipster.lite.generator.server.springboot.database.jooq.application; | ||
|
||
import org.springframework.stereotype.Service; | ||
import tech.jhipster.lite.generator.server.springboot.database.jooq.domain.JooqModuleFactory; | ||
import tech.jhipster.lite.module.domain.JHipsterModule; | ||
import tech.jhipster.lite.module.domain.docker.DockerImages; | ||
import tech.jhipster.lite.module.domain.properties.JHipsterModuleProperties; | ||
|
||
@Service | ||
public class JooqApplicationService { | ||
|
||
private final JooqModuleFactory factory; | ||
|
||
public JooqApplicationService(DockerImages dockerImages) { | ||
factory = new JooqModuleFactory(dockerImages); | ||
} | ||
|
||
public JHipsterModule buildPostgresql(JHipsterModuleProperties properties) { | ||
return factory.buildPostgresql(properties); | ||
} | ||
|
||
public JHipsterModule buildMariaDB(JHipsterModuleProperties properties) { | ||
return factory.buildMariaDB(properties); | ||
} | ||
|
||
public JHipsterModule buildMsSQL(JHipsterModuleProperties properties) { | ||
return factory.buildMsSQL(properties); | ||
} | ||
|
||
public JHipsterModule buildMySQL(JHipsterModuleProperties properties) { | ||
return factory.buildMySQL(properties); | ||
} | ||
} |
89 changes: 89 additions & 0 deletions
89
...h/jhipster/lite/generator/server/springboot/database/jooq/domain/CommonModuleBuilder.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,89 @@ | ||
package tech.jhipster.lite.generator.server.springboot.database.jooq.domain; | ||
|
||
import static tech.jhipster.lite.module.domain.JHipsterModule.*; | ||
|
||
import tech.jhipster.lite.module.domain.DocumentationTitle; | ||
import tech.jhipster.lite.module.domain.JHipsterModule; | ||
import tech.jhipster.lite.module.domain.docker.DockerImageVersion; | ||
import tech.jhipster.lite.module.domain.file.JHipsterSource; | ||
import tech.jhipster.lite.module.domain.javabuild.ArtifactId; | ||
import tech.jhipster.lite.module.domain.javadependency.JavaDependency; | ||
import tech.jhipster.lite.module.domain.javadependency.JavaDependencyScope; | ||
import tech.jhipster.lite.module.domain.javaproperties.PropertyValue; | ||
import tech.jhipster.lite.module.domain.properties.JHipsterModuleProperties; | ||
import tech.jhipster.lite.shared.error.domain.Assert; | ||
|
||
final class CommonModuleBuilder { | ||
|
||
private static final PropertyValue FALSE = propertyValue(false); | ||
|
||
private CommonModuleBuilder() {} | ||
|
||
public static JHipsterModule.JHipsterModuleBuilder commonModuleBuilder( | ||
JHipsterModuleProperties properties, | ||
DatabaseType databaseType, | ||
DockerImageVersion dockerImage, | ||
DocumentationTitle documentationTitle, | ||
ArtifactId testContainerArtifactId | ||
) { | ||
Assert.notNull("properties", properties); | ||
Assert.notNull("databaseType", databaseType); | ||
Assert.notNull("dockerImage", dockerImage); | ||
Assert.notNull("documentationTitle", documentationTitle); | ||
Assert.notNull("testContainerArtifactId", testContainerArtifactId); | ||
|
||
String databaseId = databaseType.id(); | ||
JHipsterSource source = from("server/springboot/database/common"); | ||
|
||
//@formatter:off | ||
return moduleBuilder(properties) | ||
.context() | ||
.put("srcMainDocker", "src/main/docker") // To be used in <databaseId>>.md file | ||
.put("databaseType", databaseId) | ||
.put(databaseId + "DockerImageWithVersion", dockerImage.fullName()) // To be used in <databaseId>.yml docker-compose file | ||
.and() | ||
.documentation(documentationTitle, source.template("databaseType.md")) | ||
.startupCommands() | ||
.dockerCompose(startupCommand(databaseId)) | ||
.and() | ||
.files() | ||
.add(source.append("docker").template(databaseId + ".yml"), toSrcMainDocker().append(databaseId + ".yml")) | ||
.and() | ||
.javaDependencies() | ||
.addDependency(groupId("org.springframework.boot"), artifactId("spring-boot-starter-jooq")) | ||
.addDependency(groupId("com.zaxxer"), artifactId("HikariCP")) | ||
.addDependency(testContainer(testContainerArtifactId)) | ||
.and() | ||
.springMainProperties() | ||
.set(propertyKey("spring.datasource.password"), propertyValue("")) | ||
.set(propertyKey("spring.datasource.type"), propertyValue("com.zaxxer.hikari.HikariDataSource")) | ||
.set(propertyKey("spring.datasource.hikari.poolName"), propertyValue("Hikari")) | ||
.set(propertyKey("spring.datasource.hikari.auto-commit"), FALSE) | ||
.and() | ||
.springTestProperties() | ||
.set( | ||
propertyKey("spring.datasource.url"), | ||
propertyValue("jdbc:tc:" + dockerImage.fullName() + ":///" + properties.projectBaseName().name()) | ||
) | ||
.set(propertyKey("spring.datasource.username"), propertyValue(properties.projectBaseName().name())) | ||
.set(propertyKey("spring.datasource.password"), propertyValue("")) | ||
.set(propertyKey("spring.datasource.driver-class-name"), propertyValue("org.testcontainers.jdbc.ContainerDatabaseDriver")) | ||
.set(propertyKey("spring.datasource.hikari.maximum-pool-size"), propertyValue(2)) | ||
.and(); | ||
//@formatter:on | ||
} | ||
|
||
private static String startupCommand(String databaseId) { | ||
return "src/main/docker/" + databaseId + ".yml"; | ||
} | ||
|
||
private static JavaDependency testContainer(ArtifactId testContainerArtifactId) { | ||
return javaDependency() | ||
.groupId("org.testcontainers") | ||
.artifactId(testContainerArtifactId) | ||
.dependencySlug("%s-%s".formatted("testcontainers", testContainerArtifactId)) | ||
.versionSlug("testcontainers") | ||
.scope(JavaDependencyScope.TEST) | ||
.build(); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...ava/tech/jhipster/lite/generator/server/springboot/database/jooq/domain/DatabaseType.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,18 @@ | ||
package tech.jhipster.lite.generator.server.springboot.database.jooq.domain; | ||
|
||
enum DatabaseType { | ||
POSTGRESQL("postgresql"), | ||
MYSQL("mysql"), | ||
MARIADB("mariadb"), | ||
MSSQL("mssql"); | ||
|
||
private final String id; | ||
|
||
DatabaseType(String id) { | ||
this.id = id; | ||
} | ||
|
||
public String id() { | ||
return id; | ||
} | ||
} |
Oops, something went wrong.