Skip to content

Commit

Permalink
feat(custom/test): add kotlin module
Browse files Browse the repository at this point in the history
  • Loading branch information
Alice52 committed Jan 31, 2023
1 parent 0dcd00e commit 6b78156
Show file tree
Hide file tree
Showing 9 changed files with 266 additions and 2 deletions.
133 changes: 133 additions & 0 deletions custom-test/custom-kotlin/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>custom-test</artifactId>
<groupId>io.github.alice52</groupId>
<version>0.0.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>custom-kotlin</artifactId>

<properties>
<!-- kotlin -->
<kotlin.compiler.incremental>false</kotlin.compiler.incremental>
<kotlin.compiler.jvmTarget>1.8</kotlin.compiler.jvmTarget>
<kotlin.version>1.7.21</kotlin.version>
<kotlin.code.style>official</kotlin.code.style>
</properties>

<repositories>
<repository>
<id>mavenCentral</id>
<url>https://repo1.maven.org/maven2/</url>
</repository>
</repositories>

<dependencies>
<!-- kotlin -->
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-jdk8</artifactId>
<version>${kotlin.version}</version>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-reflect</artifactId>
<version>${kotlin.version}</version>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-test-junit</artifactId>
<version>${kotlin.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<version>${kotlin.version}</version>
<configuration>
<compilerPlugins>
<plugin>lombok</plugin>
</compilerPlugins>
</configuration>
<executions>
<execution>
<id>compile</id>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<sourceDirs>
<sourceDir>src/main/kotlin</sourceDir>
<sourceDir>src/main/java</sourceDir>
</sourceDirs>
</configuration>
</execution>
<execution>
<id>test-compile</id>
<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>
<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>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
<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>
</plugin>
</plugins>
</build>


</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package common.kotlin;

public class JavaUsage {

public static void main(String[] args) {
SomePojo obj = new SomePojo();
obj.setAge(12);
boolean v = obj.isHuman();
obj.setHuman(!v);
System.out.println(obj);
}

public static void cycleUsage() {
new SomeKotlinClass().call();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package common.kotlin;

import org.codehaus.commons.nullanalysis.NotNull;
import org.springframework.lang.Nullable;

public class ManualPojo {
private Integer age;
public String getFoo() {
return null;
}

@NotNull
public String getBar() {
return "234";
}

@Nullable
public Object someMethod() {
return null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package common.kotlin;


import lombok.Data;

@Data
public class SomeData {
private String name;
private int age;
private boolean human;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package common.kotlin

class SomeKotlinClass {
fun call() {
val ddd = SomeData()
ddd.age = 12
println(ddd)
}
}


fun main() {
println("something")
val obj = SomePojo()
obj.name = "test"
val s: String = obj.name
obj.age = 12
val v = obj.isHuman
obj.isHuman = !v
println(obj)

val ddd = SomeData()

JavaUsage.cycleUsage()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package common.kotlin;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.springframework.lang.NonNull;

@Getter
@Setter
@ToString
public class SomePojo {

@NonNull private String name;
private int age;

private boolean human;
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- considering control sls by config: include -->
<configuration>
<!-- include: common-core/resource-->
<!-- include: common-log/resource-->
<include resource="logback-include.xml"/>

<springProperty scope="context" name="enabled" source="sls.enabled"/>
Expand Down
1 change: 1 addition & 0 deletions custom-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<module>custom-test-mq</module>
<module>custom-test-log</module>
<module>custom-test-crypt</module>
<module>custom-kotlin</module>
</modules>

<dependencies>
Expand Down
42 changes: 41 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>org.sonatype.oss</groupId>
<artifactId>oss-parent</artifactId>
<version>7</version>
<version>9</version>
</parent>

<groupId>io.github.alice52</groupId>
Expand Down Expand Up @@ -484,6 +484,46 @@
</plugin>
</plugins>
</pluginManagement>

<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring.boot.version}</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven.compiler.plugin}</version>
<configuration>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
<compilerArgs>
<arg>-parameters</arg>
</compilerArgs>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</path>
<path>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>${mapstruct.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>
</build>

<licenses>
Expand Down

0 comments on commit 6b78156

Please sign in to comment.