Skip to content

Commit

Permalink
Merge pull request #100 from kghackers/feat/#81_migrate-to-kotlin
Browse files Browse the repository at this point in the history
feat: #81 Migrate project to Kotlin (started the migration)
feat: #102 Extract `kgCommon` module, turn off the legacy modules by default (you can enable them via a special maven profile).
feat: #101 Kefir usage reduced, only left in the legacy modules.
  • Loading branch information
dmitry-weirdo authored Nov 26, 2024
2 parents bc94cc4 + 05d0671 commit 5ee1ce9
Show file tree
Hide file tree
Showing 121 changed files with 2,802 additions and 1,936 deletions.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,3 +190,19 @@ mvn compile

:exclamation: Now after making changes in `kgparserSrv`, you have to `mvn install`
this module before running MapStruct in `kgstatsSrv`.

## Legacy modules and Maven profile

By default, the legacy modules `kgparserSrv` and `kgparserWeb` are excluded from the build.

If you want to turn them on, you have to switch on the Maven `legacy-kgparser` profile.

For example:

```bash
mvn clean -P legacy-kgparser
```

```bash
mvn install -P legacy-kgparser
```
227 changes: 227 additions & 0 deletions kgCommon/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,227 @@
<?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>

<parent>
<groupId>ru.klavogonki.kgparser</groupId>
<artifactId>kgparser</artifactId>
<version>1.0</version>
</parent>

<artifactId>kg-common</artifactId>
<name>kg-common</name>
<description>Common module with basic Klavogonki classes, uses by both legacy kgparser and kgstats.</description>

<!-- build as a trivial jar file -->
<packaging>jar</packaging>

<dependencies>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
</dependency>

<!-- mapstruct -->
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct</artifactId>
</dependency>

<!-- 1 generator -->
<dependency>
<groupId>org.openapitools</groupId>
<artifactId>jackson-databind-nullable</artifactId>
<version>${jackson-databind-nullable-version}</version>
</dependency>

<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
<version>${swagger-annotations-version}</version>
</dependency>

</dependencies>

<build>
<plugins>

<!-- see https://kotlinlang.org/docs/maven.html#compile-kotlin-and-java-sources -->
<!-- see https://kotlinlang.org/docs/lombok.html#maven -->
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<version>${kotlin.version}</version>
<extensions>true</extensions> <!-- You can set this option to automatically take information about lifecycles -->

<executions>
<execution>
<id>compile</id>
<goals>
<goal>compile</goal> <!-- You can skip the <goals> element if you enable extensions for the plugin -->
</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>
<goals>
<goal>test-compile</goal> <!-- You can skip the <goals> element if you enable extensions for the plugin -->
</goals>
<configuration>
<sourceDirs>
<sourceDir>${project.basedir}/src/test/kotlin</sourceDir>
<sourceDir>${project.basedir}/src/test/java</sourceDir>
</sourceDirs>
</configuration>
</execution>
</executions>

<!-- Enable use Lombok-generated code from Java classes in Kotlin -->
<!-- see https://github.com/kotlin-hands-on/kotlin-lombok-examples/blob/master/kotlin_lombok_maven/nokapt/pom.xml -->
<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-lombok</artifactId>
<version>${kotlin.version}</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<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>

<!-- MapStruct and Lombok configuration -->
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<annotationProcessorPaths>
<path>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>${org.mapstruct.version}</version>
</path>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</path>

<!-- This is needed when using Lombok 1.8.16 and above -->
<!-- see https://mapstruct.org/faq/#can-i-use-mapstruct-together-with-project-lombok -->
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok-mapstruct-binding</artifactId>
<version>${lombok-mapstruct-binding.version}</version>
</path>

</annotationProcessorPaths>
</configuration>

</plugin>

<!-- add sources generated by OpenAPI Generator to jar -->
<!-- see http://www.jeeatwork.com/?p=166 -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>${build-helper-maven-plugin.version}</version>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${project.build.directory}/generated-sources/openapi/src</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.assertj</groupId>
<artifactId>assertj-assertions-generator-maven-plugin</artifactId>
<version>${assertj-assertions-generator-maven-plugin.version}</version>
<configuration>
<packages>
<param>ru.klavogonki.statistics.entity</param>
<param>ru.klavogonki.statistics.dto</param>
<param>ru.klavogonki.openapi.model</param>
</packages>

<entryPointClassPackage>ru.klavogonki.statistics</entryPointClassPackage>
<hierarchical>true</hierarchical>
</configuration>
<executions>
<execution>
<goals>
<goal>generate-assertions</goal>
</goals>
<phase>generate-test-resources</phase>
</execution>
</executions>
</plugin>

</plugins>
</build>

</project>
Loading

0 comments on commit 5ee1ce9

Please sign in to comment.