Error trying to compile a Maven project with annotations


#1

I try this mvn configuration

<plugin>   <artifactId>kotlin-maven-plugin</artifactId>   <groupId>org.jetbrains.kotlin</groupId>   <version>${kotlin.version}</version>   <configuration>   <annotationPaths>   <annotationPath>${project.basedir}/src/main/resources/org/springframework/jdbc/core/annotations.xml</annotationPath>   <annotationPath>${project.basedir}/src/main/resources/org/springframework/jdbc/core/namedparam/annotations.xml</annotationPath>   </annotationPaths>   </configuration>

The Kotlin version is 0.6.800 (But I try with other versions too)

But always I get this error

[INFO] Using kotlin annotations from /Users/mario/.m2/repository/org/jetbrains/kotlin/kotlin-jdk-annotations/0.6.800/kotlin-jdk-annotations-0.6.800.jar:/Users/mario/IdeaProjects/KotlinProjects/KotlinPrimavera__/KotlinPrimavera/jdbc/src/main/resources/org/springframework/jdbc/core/annotations.xml:/Users/mario/IdeaProjects/KotlinProjects/KotlinPrimavera__/KotlinPrimavera/jdbc/src/main/resources/org/springframework/jdbc/core/namedparam/annotations.xml [ERROR] java.lang.IllegalStateException: @NotNull method org/jetbrains/jet/utils/PathUtil.jarFileOrDirectoryToVirtualFile must not return null      at org.jetbrains.jet.utils.PathUtil.jarFileOrDirectoryToVirtualFile(PathUtil.java:144)      at org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment.addExternalAnnotationsRoot(JetCoreEnvironment.java:151)      at org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment.<init>(JetCoreEnvironment.java:120)      at org.jetbrains.jet.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.java:147)      at org.jetbrains.jet.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.java:48)      at org.jetbrains.jet.cli.common.CLICompiler.exec(CLICompiler.java:131)      at org.jetbrains.kotlin.maven.KotlinCompileMojoBase.execute(KotlinCompileMojoBase.java:202)      at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)      at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)      at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)      at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)      at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)      at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)      at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)      at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)      at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)      at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)      at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)      at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)      at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)      at java.lang.reflect.Method.invoke(Method.java:597)      at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)      at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)      at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)      at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)      at org.codehaus.classworlds.Launcher.main(Launcher.java:47)      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)      at java.lang.reflect.Method.invoke(Method.java:597)      at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)


#2

That's the same error message I was getting because of this: http://youtrack.jetbrains.com/issue/KT-4204 See the post "push to maven" from a few days back. The workaround was to rename a parameter.


#3

Stack traces look rather different to me.


#4

You should not specify paths to annotation.xml files. Intead, give a path to the root of the annotation structure (the parent of "org" directory):

<plugin>
  <artifactId>kotlin-maven-plugin</artifactId>
  <groupId>org.jetbrains.kotlin</groupId>
  <version>${kotlin.version}</version>
  <configuration>
    <annotationPaths>
      <annotationPath>${project.basedir}/src/main/resources/</annotationPath>
    </annotationPaths>
  </configuration>

Please let me know if it fixes the problem


#5

Perfect, works fine