EDIT: fixed first version, now I have a different problem
Hi, I’m trying to make the kotlin annotation processor work from the command line kotlinc
.
I have a small example here https://github.com/sky87/kapt-cli-example
What I’m doing right now is this (build.sh)
#!/usr/bin/env bash
if [ -z "$KOTLIN_HOME" ]; then
KOTLIN_HOME=kotlinc
PATH=$KOTLIN_HOME/bin:$PATH
fi
CLASSPATH=lib/org.mapstruct-mapstruct-1.2.0.Final.jar:lib/org.mapstruct-mapstruct-jdk8-1.2.0.Final.jar:build/classes
KT_DEPS=$KOTLIN_HOME/lib/kotlin-runtime.jar:$KOTLIN_HOME/lib/kotlin-stdlib-jdk8.jar:$KOTLIN_HOME/lib/kotlin-reflect.jar
rm -rf build
mkdir -p \
build/classes \
build/kapt/sources \
build/kapt/classes \
build/kapt/stubs
kotlinc \
-cp $CLASSPATH \
-d build/classes \
-Xplugin=$KOTLIN_HOME/lib/kotlin-annotation-processing.jar \
-P plugin:org.jetbrains.kotlin.kapt3:sources=build/kapt/sources \
-P plugin:org.jetbrains.kotlin.kapt3:classes=build/kapt/classes \
-P plugin:org.jetbrains.kotlin.kapt3:stubs=build/kapt/stubs \
-P plugin:org.jetbrains.kotlin.kapt3:apclasspath=lib/org.mapstruct-mapstruct-processor-1.2.0.Final.jar \
-P plugin:org.jetbrains.kotlin.kapt3:processors=org.mapstruct.ap.MappingProcessor \
-P plugin:org.jetbrains.kotlin.kapt3:aptMode=stubsAndApt \
-P plugin:org.jetbrains.kotlin.kapt3:verbose=1 \
src
java \
-cp $KT_DEPS:$CLASSPATH \
MainKt
When I run this I get
error: [kapt] 'com.sun.tools.javac.util.Context' class can't be found ('tools.jar' is absent in the plugin classpath). Kapt won't work.
even though
> ls $JAVA_HOME/lib | grep tools
tools.jar
any idea?
Thanks,
Fra