Skip to content

Commit

Permalink
fix($Kotlin): fix Kotlin building error cannot find symbol
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnymillergh committed Apr 11, 2022
1 parent fb56033 commit f7a3259
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,13 @@ class MyBatisPlusTests {
@Autowired
private RoleMapper roleMapper;

// @Test
// @Test
@Order(1)
void insertAutoFillTest() {
val role = new Role();
role.setName("role-for-mybatis-plus-tests");
role.setDescription("Role for MyBatis Plus tests. Testing functions");
val role = new Role(
"role-for-mybatis-plus-tests",
"Role for MyBatis Plus tests. Testing functions"
);
int inserted;
try {
inserted = this.roleDomainService.getBaseMapper().insert(role);
Expand All @@ -47,12 +48,13 @@ void insertAutoFillTest() {
Assertions.assertEquals(AFFECTED, inserted);
}

// @Test
// @Test
@Order(2)
void logicDeleteTest() {
val lambdaQuery = Wrappers.lambdaQuery(Role.class);
lambdaQuery.eq(Role::getName, "role-for-mybatis-plus-tests");
var optionalRolePersistence = Optional.ofNullable(this.roleDomainService.getBaseMapper().selectOne(lambdaQuery));
var optionalRolePersistence = Optional.ofNullable(
this.roleDomainService.getBaseMapper().selectOne(lambdaQuery));
if (optionalRolePersistence.isEmpty()) {
optionalRolePersistence = Optional.ofNullable(this.roleMapper.selectByName("role-for-mybatis-plus-tests"));
}
Expand Down
106 changes: 81 additions & 25 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
<!-- Gateway Service. Port range: [8080, 8080]. -->
<api-gateway.port>8080</api-gateway.port>

<kotlin.compiler.incremental>true</kotlin.compiler.incremental>

<!-- Version Definitions. -->
<java.version>17</java.version>
<!--
Expand Down Expand Up @@ -246,6 +248,58 @@
</configuration>
</plugin>

<!-- https://kotlinlang.org/docs/maven.html#compile-kotlin-and-java-sources -->
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<configuration>
<compilerPlugins>
<plugin>spring</plugin>
</compilerPlugins>
<args>
<arg>-Xjsr305=strict</arg>
</args>
</configuration>
<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-noarg</artifactId>
<version>${kotlin.version}</version>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-allopen</artifactId>
<version>${kotlin.version}</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>compile</id>
<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>
<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>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
Expand Down Expand Up @@ -279,6 +333,33 @@
</path>
</annotationProcessorPaths>
</configuration>
<!-- https://kotlinlang.org/docs/maven.html#compile-kotlin-and-java-sources -->
<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>

<plugin>
Expand Down Expand Up @@ -338,31 +419,6 @@
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<configuration>
<compilerPlugins>
<plugin>spring</plugin>
</compilerPlugins>
<args>
<arg>-Xjsr305=strict</arg>
</args>
</configuration>
<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-noarg</artifactId>
<version>${kotlin.version}</version>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-allopen</artifactId>
<version>${kotlin.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>

Expand Down

0 comments on commit f7a3259

Please sign in to comment.