Compile Kotlin sources with Gant?


Hello everyone,

As you may be aware there’s a Kotlin plugin for Grifofn available at
Given that Kotlin M1 has just been released I wanted to update the plugin to the latest version, however I encountered a few problems.

You see, the Griffon build systm relies on Gant to compile sources,

Apparently Kotlin M1 requires an additional jar (jdk-headers.jar) to be available, if that jar is missing I get the following exception

Caused by: java.lang.IllegalArgumentException: jdkHeaders must be included for mode REGULAR at<init>( at at org.jetbrains.jet.buildtools.core.BytecodeCompiler.env( at org.jetbrains.jet.buildtools.core.BytecodeCompiler.sourcesToDir(

However if the jar is added to the classpath I get another error, this time form Gant itself.
Caused by: java.lang.SecurityException: Prohibited package name: java.lang at at com.intellij.openapi.application.PathManager.extractRoot( at com.intellij.openapi.application.PathManager.getResourceRoot( at org.jetbrains.jet.utils.PathUtil.getJarPathForClass( at org.jetbrains.jet.utils.PathUtil.getDefaultCompilerPath( at org.jetbrains.jet.utils.PathUtil.getAltHeadersPath( at at org.jetbrains.jet.buildtools.core.BytecodeCompiler.env( at org.jetbrains.jet.buildtools.core.BytecodeCompiler.sourcesToDir(

On the previous plugin release it was enough to compile Kotlin source from Gant with

  ant.taskdef(resource: 'org/jetbrains/jet/buildtools/ant/antlib.xml',)   ant.kotlinc(            output: projectMainClassesDir,            src: kotlinSrc,            classpathref: classpathId)

Assuming all jars were in the classpath (as shown in

So. Is it possible to circumvent the requirements of jdk-headers or the SecurityException?



Actually the jdkHeaders.jar is should not be on the class path, but rather on the special path for alternative library headers. Unfortunately, in the M1 version there is no way to alter this path, and teh only place searched for this jar is the lib/alt directory under the compiler installation.

We will fix this in the future version, and for now you can adopt the same approach the Maven plugin uses: just put the headers jar in the appropriate place.


Thanks Andrey, in the end I bundled kotlinc M1 with the plugin and loaded the jars as explained in the Ant integration document. A new release of the griffon-kotlin plugin ahs been posted :-)


PD: keep it up with the good work!


Great! Thanks