I'm trying to add some Kotlin classes into my existing Java project under Vaadin Framework (v 8.4.5).
I've fully read the tutorial on how to mixing java and Kotlin, and I've successfully created a Kotlin class inside my existing Java Project.
The new Kotlin class is inside my project (ofc I've cutted away all code for privacy)
package it.projectName.utils
import it.projectName.otherClasses
class SecurityUtils (user: User) {
//various val and var, and of course the isCrypted calculated val
init {
if(!isCrypted){
//encrypt user password
}
}
}
Now I'm using this Kotlin class inside my Java class with
import it.projectName.utils.SecurityUtils;
public class UserDao{
//[... other code ...]
SecurityUtils securityUtils = new SecurityUtils(user);
}
Everything is fine, I don't get any compiler error.
But when I try to run my project with maven with jetty:run
, it throws an error:
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /C:/pathToClass/UserDao.java:[9,36] cannot find symbol
symbol: class SecurityUtils
location: package it.projectName.utils
[INFO] 1 error
[INFO] -------------------------------------------------------------
The line he's referring to is import it.projectName.utils.SecurityUtils;
I've checked my pom.xml
, everything looks fine there aswell:
<properties>
<kotlin.version>1.2.61</kotlin.version>
<kotlin.compiler.incremental>true</kotlin.compiler.incremental>
</properties>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-jdk8</artifactId>
<version>${kotlin.version}</version>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-test</artifactId>
<version>${kotlin.version}</version>
<scope>test</scope>
</dependency>
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<version>${kotlin.version}</version>
<executions>
<execution>
<id>compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<sourceDirs>
<sourceDir>src/main/java</sourceDir>
<sourceDir>src/main/kotlin</sourceDir>
</sourceDirs>
</configuration>
</execution>
<execution>
<id>test-compile</id>
<phase>test-compile</phase>
<goals>
<goal>test-compile</goal>
</goals>
<configuration>
<sourceDirs>
<sourceDir>src/main/java</sourceDir>
<sourceDir>src/main/kotlin</sourceDir>
</sourceDirs>
</configuration>
</execution>
</executions>
<configuration>
<jvmTarget>1.8</jvmTarget>
</configuration>
</plugin>
What I'm missing? Thanks