IntelliJ Idea Cannot resolve imported jar at kotlin project

Answered

I create project at this link https://github.com/davidasync/dismember-pedia and use `gradle installDist` to create .jar file.
And I copy paste it at https://github.com/davidasync/aetherlens

I don't know why, the editor cannot resolve the word `dismemberPedia`, but i can run it

I already add this jar to build.gradle https://github.com/davidasync/aetherlens/blob/master/build.gradle

1
4 comments

Hello,

Does  this library mentioned in your module dependencies ("Project Structure | Modules - Dependencies")?

0

I have the same problem. I created a jar from a Kotlin project and imported it into another Kotlin/Maven project. All the dependencies appear fine. I can build the new project with Maven on the command line AND with the Maven IntelliJ plugin, but the editor cannot resolve the referenced classes. The weird thing is, if I create a Java class in the new project, that class can "see it".

 

0

Please share a sample project to reproduce this issue: https://uploads.jetbrains.com.

0

Hi Serge, 

Thanks for the reply. The solution/workaround found here solved the problem. I'm using maven instead of gradle so the solution is to use the maven shade plugin (instead of the the assembly plugin) with the following filters...

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
<exclude>**/*.kotlin_metadata</exclude>
<exclude>**/*.kotlin_module</exclude>
<exclude>**/*.kotlin_builtins</exclude>
</excludes>
</filter>
</filters>
<outputFile>${project.build.directory}/${project.artifactId}-${version}-full.jar</outputFile>
</configuration>
</execution>
</executions>
</plugin>


Now when the resulting jar is installed on another kotlin project, all the classes are visible in the editor. Well....so far. :-)

0

Please sign in to leave a comment.