JetBrains / sbt-idea-plugin

Develop IntelliJ plugins with Scala and SBT
Apache License 2.0
98 stars 28 forks source link

Compile errors because package name conflicts in SDK jars #24

Closed rikvdkleij closed 5 years ago

rikvdkleij commented 5 years ago

SDK jars contains libraries with package names which are conflicting.

The IntelliJ-Haskell plugin uses the CompileContextImpl of package com.intellij.compiler.impl. sbt compile gives this error:

[error] /home/rik/idea/intellij-haskell/src/main/scala/intellij/haskell/external/execution/StackCommandLine.scala:21:30: object impl is not a member of package com.intellij.compiler
[error] import com.intellij.compiler.impl._

That is because also library javac2.jar exports package com.intellij.compiler. It should use library java-impl.jar

How to prevent this compile error? Is it possible to exclude javac2.jar?

Also this error:

[error] /home/rik/idea/intellij-haskell/src/main/scala/intellij/haskell/external/execution/CommandLine.scala:28:26: object incremental is not a member of package org.jetbrains.jps
[error] import org.jetbrains.jps.incremental.messages.BuildMessage

Btw, in the past this wasn't issue.

Compiling the plugin in IntelliJ gives no errors.

Using version 2.4.1 of sbt-idea-plugin and IntelliJ version 192.6603.28

rikvdkleij commented 5 years ago

I have tried to get it working by excluding jars like in IntelliJ-Scala project but without success.

ideaMainJars := ideaMainJars.value.filterNot(file => excludeJarsFromPlatformDependencies(file.data)),

val excludeJarsFromPlatformDependencies: File => Boolean = { file =>
  (file.getName.contains("openapi") || file.getName.contains("javac2") || file.getName.contains("java-api"))   // version conflict with bsp4j in ultimate platformt
mutcianm commented 5 years ago

The reason behind this issue is not package name conflict(multiple jars may share the same package safely)

This error occurs because classes you're using in StackCommandLine.scala are part of Java plugin implementation, which has been extracted into a separate entity in IDEA 192.X

The solution would be to add Java plugin as an internal plugin dependency in build:

ideaInternalPlugins += "java"

Also don't forget to add dependency in plugin.xml:

<depends>com.intellij.modules.java</depends>