Skip to content

Commit 6b78156

Browse files
committed
feat(custom/test): add kotlin module
1 parent 0dcd00e commit 6b78156

File tree

9 files changed

+266
-2
lines changed

9 files changed

+266
-2
lines changed

custom-test/custom-kotlin/pom.xml

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<project xmlns="http://maven.apache.org/POM/4.0.0"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
6+
<parent>
7+
<artifactId>custom-test</artifactId>
8+
<groupId>io.github.alice52</groupId>
9+
<version>0.0.1</version>
10+
</parent>
11+
<modelVersion>4.0.0</modelVersion>
12+
13+
<artifactId>custom-kotlin</artifactId>
14+
15+
<properties>
16+
<!-- kotlin -->
17+
<kotlin.compiler.incremental>false</kotlin.compiler.incremental>
18+
<kotlin.compiler.jvmTarget>1.8</kotlin.compiler.jvmTarget>
19+
<kotlin.version>1.7.21</kotlin.version>
20+
<kotlin.code.style>official</kotlin.code.style>
21+
</properties>
22+
23+
<repositories>
24+
<repository>
25+
<id>mavenCentral</id>
26+
<url>https://repo1.maven.org/maven2/</url>
27+
</repository>
28+
</repositories>
29+
30+
<dependencies>
31+
<!-- kotlin -->
32+
<dependency>
33+
<groupId>org.jetbrains.kotlin</groupId>
34+
<artifactId>kotlin-stdlib-jdk8</artifactId>
35+
<version>${kotlin.version}</version>
36+
</dependency>
37+
<dependency>
38+
<groupId>org.jetbrains.kotlin</groupId>
39+
<artifactId>kotlin-reflect</artifactId>
40+
<version>${kotlin.version}</version>
41+
</dependency>
42+
<dependency>
43+
<groupId>org.jetbrains.kotlin</groupId>
44+
<artifactId>kotlin-test-junit</artifactId>
45+
<version>${kotlin.version}</version>
46+
<scope>test</scope>
47+
</dependency>
48+
</dependencies>
49+
50+
<build>
51+
<plugins>
52+
<plugin>
53+
<groupId>org.jetbrains.kotlin</groupId>
54+
<artifactId>kotlin-maven-plugin</artifactId>
55+
<version>${kotlin.version}</version>
56+
<configuration>
57+
<compilerPlugins>
58+
<plugin>lombok</plugin>
59+
</compilerPlugins>
60+
</configuration>
61+
<executions>
62+
<execution>
63+
<id>compile</id>
64+
<goals>
65+
<goal>compile</goal>
66+
</goals>
67+
<configuration>
68+
<sourceDirs>
69+
<sourceDir>src/main/kotlin</sourceDir>
70+
<sourceDir>src/main/java</sourceDir>
71+
</sourceDirs>
72+
</configuration>
73+
</execution>
74+
<execution>
75+
<id>test-compile</id>
76+
<goals>
77+
<goal>test-compile</goal>
78+
</goals>
79+
<configuration>
80+
<sourceDirs>
81+
<sourceDir>${project.basedir}/src/test/kotlin</sourceDir>
82+
<sourceDir>${project.basedir}/src/test/java</sourceDir>
83+
</sourceDirs>
84+
</configuration>
85+
</execution>
86+
</executions>
87+
<dependencies>
88+
<dependency>
89+
<groupId>org.jetbrains.kotlin</groupId>
90+
<artifactId>kotlin-maven-lombok</artifactId>
91+
<version>${kotlin.version}</version>
92+
</dependency>
93+
</dependencies>
94+
</plugin>
95+
<plugin>
96+
<groupId>org.apache.maven.plugins</groupId>
97+
<artifactId>maven-compiler-plugin</artifactId>
98+
<configuration>
99+
<source>1.8</source>
100+
<target>1.8</target>
101+
</configuration>
102+
<executions>
103+
<!-- Replacing default-compile as it is treated specially by maven -->
104+
<execution>
105+
<id>default-compile</id>
106+
<phase>none</phase>
107+
</execution>
108+
<!-- Replacing default-testCompile as it is treated specially by maven -->
109+
<execution>
110+
<id>default-testCompile</id>
111+
<phase>none</phase>
112+
</execution>
113+
<execution>
114+
<id>java-compile</id>
115+
<phase>compile</phase>
116+
<goals>
117+
<goal>compile</goal>
118+
</goals>
119+
</execution>
120+
<execution>
121+
<id>java-test-compile</id>
122+
<phase>test-compile</phase>
123+
<goals>
124+
<goal>testCompile</goal>
125+
</goals>
126+
</execution>
127+
</executions>
128+
</plugin>
129+
</plugins>
130+
</build>
131+
132+
133+
</project>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package common.kotlin;
2+
3+
public class JavaUsage {
4+
5+
public static void main(String[] args) {
6+
SomePojo obj = new SomePojo();
7+
obj.setAge(12);
8+
boolean v = obj.isHuman();
9+
obj.setHuman(!v);
10+
System.out.println(obj);
11+
}
12+
13+
public static void cycleUsage() {
14+
new SomeKotlinClass().call();
15+
}
16+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package common.kotlin;
2+
3+
import org.codehaus.commons.nullanalysis.NotNull;
4+
import org.springframework.lang.Nullable;
5+
6+
public class ManualPojo {
7+
private Integer age;
8+
public String getFoo() {
9+
return null;
10+
}
11+
12+
@NotNull
13+
public String getBar() {
14+
return "234";
15+
}
16+
17+
@Nullable
18+
public Object someMethod() {
19+
return null;
20+
}
21+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package common.kotlin;
2+
3+
4+
import lombok.Data;
5+
6+
@Data
7+
public class SomeData {
8+
private String name;
9+
private int age;
10+
private boolean human;
11+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package common.kotlin
2+
3+
class SomeKotlinClass {
4+
fun call() {
5+
val ddd = SomeData()
6+
ddd.age = 12
7+
println(ddd)
8+
}
9+
}
10+
11+
12+
fun main() {
13+
println("something")
14+
val obj = SomePojo()
15+
obj.name = "test"
16+
val s: String = obj.name
17+
obj.age = 12
18+
val v = obj.isHuman
19+
obj.isHuman = !v
20+
println(obj)
21+
22+
val ddd = SomeData()
23+
24+
JavaUsage.cycleUsage()
25+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package common.kotlin;
2+
3+
import lombok.Getter;
4+
import lombok.Setter;
5+
import lombok.ToString;
6+
import org.springframework.lang.NonNull;
7+
8+
@Getter
9+
@Setter
10+
@ToString
11+
public class SomePojo {
12+
13+
@NonNull private String name;
14+
private int age;
15+
16+
private boolean human;
17+
}

custom-test/custom-test-log/src/main/resources/logback-spring.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<!-- considering control sls by config: include -->
33
<configuration>
4-
<!-- include: common-core/resource-->
4+
<!-- include: common-log/resource-->
55
<include resource="logback-include.xml"/>
66

77
<springProperty scope="context" name="enabled" source="sls.enabled"/>

custom-test/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
<module>custom-test-mq</module>
2424
<module>custom-test-log</module>
2525
<module>custom-test-crypt</module>
26+
<module>custom-kotlin</module>
2627
</modules>
2728

2829
<dependencies>

pom.xml

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<parent>
88
<groupId>org.sonatype.oss</groupId>
99
<artifactId>oss-parent</artifactId>
10-
<version>7</version>
10+
<version>9</version>
1111
</parent>
1212

1313
<groupId>io.github.alice52</groupId>
@@ -484,6 +484,46 @@
484484
</plugin>
485485
</plugins>
486486
</pluginManagement>
487+
488+
<plugins>
489+
<plugin>
490+
<groupId>org.springframework.boot</groupId>
491+
<artifactId>spring-boot-maven-plugin</artifactId>
492+
<version>${spring.boot.version}</version>
493+
<executions>
494+
<execution>
495+
<goals>
496+
<goal>repackage</goal>
497+
</goals>
498+
</execution>
499+
</executions>
500+
</plugin>
501+
502+
<plugin>
503+
<groupId>org.apache.maven.plugins</groupId>
504+
<artifactId>maven-compiler-plugin</artifactId>
505+
<version>${maven.compiler.plugin}</version>
506+
<configuration>
507+
<source>${maven.compiler.source}</source>
508+
<target>${maven.compiler.target}</target>
509+
<compilerArgs>
510+
<arg>-parameters</arg>
511+
</compilerArgs>
512+
<annotationProcessorPaths>
513+
<path>
514+
<groupId>org.projectlombok</groupId>
515+
<artifactId>lombok</artifactId>
516+
<version>${lombok.version}</version>
517+
</path>
518+
<path>
519+
<groupId>org.mapstruct</groupId>
520+
<artifactId>mapstruct-processor</artifactId>
521+
<version>${mapstruct.version}</version>
522+
</path>
523+
</annotationProcessorPaths>
524+
</configuration>
525+
</plugin>
526+
</plugins>
487527
</build>
488528

489529
<licenses>

0 commit comments

Comments
 (0)