Skip to content

Commit

Permalink
Merge pull request #394 from mshima/kotlin-generator
Browse files Browse the repository at this point in the history
add kotlin generator
  • Loading branch information
DanielFran committed Jul 26, 2024
2 parents 00884dd + 53e3610 commit 85a8592
Show file tree
Hide file tree
Showing 18 changed files with 737 additions and 368 deletions.
5 changes: 5 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,8 @@ updates:
schedule:
interval: 'daily'
open-pull-requests-limit: 5
- package-ecosystem: 'gradle'
directory: '/generators/kotlin/resources/'
schedule:
interval: 'daily'
open-pull-requests-limit: 5
8 changes: 7 additions & 1 deletion .yo-rc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"generator-jhipster": {
"additionalSubGenerators": "detekt,ktlint,migration",
"additionalSubGenerators": "detekt,ktlint,kotlin,migration",
"baseName": "kotlin",
"cli": true,
"cliName": "khipster",
Expand All @@ -12,6 +12,12 @@
"sbs": null,
"written": true
},
"kotlin": {
"command": false,
"priorities": ["loading", "default", "postWriting"],
"sbs": null,
"written": true
},
"ktlint": {
"command": false,
"priorities": ["default"],
Expand Down
2 changes: 1 addition & 1 deletion generators/detekt/__snapshots__/generator.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ exports[`SubGenerator detekt of kotlin JHipster blueprint > maven > should match
"versions": [
{
"name": "maven-antrun-plugin",
"version": "3.0.0",
"version": "'MAVEN-ANTRUN-PLUGIN-VERSION'",
},
{
"name": "detekt",
Expand Down
5 changes: 3 additions & 2 deletions generators/detekt/generator.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import BaseApplicationGenerator from 'generator-jhipster/generators/base-application';
import { DETEKT_CONFIG_FILE, MAVEN_ANTRUN_VERSION } from '../spring-boot/kotlin-constants.js';

const DETEKT_CONFIG_FILE = 'detekt-config.yml';

export default class extends BaseApplicationGenerator {
constructor(args, opts, features) {
Expand Down Expand Up @@ -75,7 +76,7 @@ export default class extends BaseApplicationGenerator {
if (application.buildToolMaven) {
source.addJavaDefinition({
versions: [
{ name: 'maven-antrun-plugin', version: MAVEN_ANTRUN_VERSION },
{ name: 'maven-antrun-plugin', version: application.javaDependencies['maven-antrun-plugin'] },
{ name: 'detekt', version: application.javaDependencies['detekt-cli'] },
],
});
Expand Down
282 changes: 282 additions & 0 deletions generators/kotlin/__snapshots__/generator.spec.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,282 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`SubGenerator kotlin of kotlin JHipster blueprint > gradle > should match source calls 1`] = `
{
"addGradlePluginToBuildScript": [
{
"group": "org.jetbrains.kotlin",
"name": "kotlin-gradle-plugin",
"version": "\${kotlin_version}",
},
{
"group": "org.jetbrains.kotlin",
"name": "kotlin-allopen",
"version": "\${kotlin_version}",
},
{
"group": "org.jetbrains.kotlin",
"name": "kotlin-noarg",
"version": "\${kotlin_version}",
},
],
"addGradleProperty": [
{
"property": "kotlin_version",
"value": "'KOTLIN-VERSION'",
},
],
"applyFromGradle": [
{
"script": "gradle/kotlin.gradle",
},
],
}
`;

exports[`SubGenerator kotlin of kotlin JHipster blueprint > gradle > should succeed 1`] = `
{
".yo-rc.json": {
"stateCleared": "modified",
},
"buildSrc/build.gradle": {
"stateCleared": "modified",
},
"buildSrc/gradle/libs.versions.toml": {
"stateCleared": "modified",
},
"gradle/kotlin.gradle": {
"stateCleared": "modified",
},
"gradle/libs.versions.toml": {
"stateCleared": "modified",
},
"gradle/wrapper/gradle-wrapper.jar": {
"stateCleared": "modified",
},
"gradle/wrapper/gradle-wrapper.properties": {
"stateCleared": "modified",
},
"gradlew": {
"stateCleared": "modified",
},
"gradlew.bat": {
"stateCleared": "modified",
},
}
`;

exports[`SubGenerator kotlin of kotlin JHipster blueprint > maven > should match source calls 1`] = `
{
"addJavaDefinition": [
{
"dependencies": [
{
"artifactId": "kotlin-stdlib-jdk8",
"groupId": "org.jetbrains.kotlin",
},
{
"artifactId": "kotlin-reflect",
"groupId": "org.jetbrains.kotlin",
},
{
"artifactId": "kotlin-test-junit",
"groupId": "org.jetbrains.kotlin",
"scope": "test",
},
{
"artifactId": "mockito-kotlin",
"groupId": "org.mockito.kotlin",
"scope": "test",
"version": "'MOCKITO-KOTLIN-VERSION'",
},
],
"versions": [
{
"name": "kotlin",
"version": "'KOTLIN-VERSION'",
},
],
},
],
"addMavenDefinition": [
{
"dependencyManagement": [
{
"artifactId": "kotlin-bom",
"groupId": "org.jetbrains.kotlin",
"scope": "import",
"type": "pom",
"version": "\${kotlin.version}",
},
],
"plugins": [
{
"additionalContent": "
<executions>
<!-- Replacing default-compile as it is treated specially by maven -->
<execution>
<id>default-compile</id>
<phase>none</phase>
</execution>
<!-- Replacing default-testCompile as it is treated specially by maven -->
<execution>
<id>default-testCompile</id>
<phase>none</phase>
</execution>
<execution>
<id>java-compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>java-test-compile</id>
<phase>test-compile</phase>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
<configuration>
<proc>none</proc>
</configuration>",
"artifactId": "maven-compiler-plugin",
"groupId": "org.apache.maven.plugins",
"version": "\${maven-compiler-plugin.version}",
},
{
"additionalContent": "
<executions>
<execution>
<id>kapt</id>
<goals>
<goal>kapt</goal>
</goals>
<configuration>
<sourceDirs>
<sourceDir>\${project.basedir}/src/main/kotlin</sourceDir>
<sourceDir>\${project.basedir}/src/main/java</sourceDir>
</sourceDirs>
<annotationProcessorPaths>
<annotationProcessorPath>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>\${mapstruct.version}</version>
</annotationProcessorPath>
<!-- For JPA static metamodel generation -->
<annotationProcessorPath>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-jpamodelgen</artifactId>
<version>\${hibernate.version}</version>
</annotationProcessorPath>
<annotationProcessorPath>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>\${jaxb-runtime.version}</version>
</annotationProcessorPath>
</annotationProcessorPaths>
</configuration>
</execution>
<execution>
<id>compile</id>
<phase>process-sources</phase>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<sourceDirs>
<sourceDir>\${project.basedir}/src/main/kotlin</sourceDir>
<sourceDir>\${project.basedir}/src/main/java</sourceDir>
</sourceDirs>
</configuration>
</execution>
<execution>
<id>test-compile</id>
<phase>process-test-sources</phase>
<goals>
<goal>test-compile</goal>
</goals>
<configuration>
<sourceDirs>
<sourceDir>\${project.basedir}/src/test/kotlin</sourceDir>
<sourceDir>\${project.basedir}/src/test/java</sourceDir>
</sourceDirs>
</configuration>
</execution>
</executions>
<configuration>
<jvmTarget>\${java.version}</jvmTarget>
<javaParameters>true</javaParameters>
<args>
<arg>-Xjvm-default=all</arg>
</args>
<compilerPlugins>
<plugin>spring</plugin>
<plugin>jpa</plugin>
<plugin>all-open</plugin>
</compilerPlugins><pluginOptions>
<!-- Each annotation is placed on its own line -->
<option>all-open:annotation=javax.persistence.Entity</option>
<option>all-open:annotation=javax.persistence.MappedSuperclass</option>
<option>all-open:annotation=javax.persistence.Embeddable</option>
</pluginOptions>
</configuration>
<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-allopen</artifactId>
<version>\${kotlin.version}</version>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-noarg</artifactId>
<version>\${kotlin.version}</version>
</dependency>
</dependencies>",
"artifactId": "kotlin-maven-plugin",
"groupId": "org.jetbrains.kotlin",
"version": "\${kotlin.version}",
},
],
},
],
"mergeMavenPomContent": [
{
"project": {
"build": {
"sourceDirectory": "src/main/kotlin/",
"testSourceDirectory": "src/test/kotlin/",
},
},
},
],
}
`;

exports[`SubGenerator kotlin of kotlin JHipster blueprint > maven > should succeed 1`] = `
{
".mvn/jvm.config": {
"stateCleared": "modified",
},
".mvn/wrapper/maven-wrapper.jar": {
"stateCleared": "modified",
},
".mvn/wrapper/maven-wrapper.properties": {
"stateCleared": "modified",
},
".yo-rc.json": {
"stateCleared": "modified",
},
"mvnw": {
"stateCleared": "modified",
},
"mvnw.cmd": {
"stateCleared": "modified",
},
"pom.xml": {
"stateCleared": "modified",
},
}
`;
Loading

0 comments on commit 85a8592

Please sign in to comment.