Build against Rubymine SDK not working when using depends optional=true

Following the instructions on https://confluence.jetbrains.com/display/IDEADEV/Plugin+Compatibility+with+IntelliJ+Platform+Products, I moved my projectStructureDetector extension to rich-platform-plugin.xml:

 
<!-- Extensions that use extension points that are only available in IntelliJ IDEA, but not in the language-specific
     IDEs need to be declared here so that they are optional.  Extension points that are only available in IntelliJ IDEA
     are declared in https://github.com/JetBrains/intellij-community/blob/432621e024f9a2a97d24351eb9dfa5bc03184aac/resources/src/idea/RichPlatformPlugin.xml#L29-L88.
     Thanks to Sergey Ignatov (@ignatov) for explaining this distinction. -->
<idea-plugin version="2">
  <extensions defaultExtensionNs="com.intellij">
      <projectStructureDetector implementation="org.elixir_lang.mix.ProjectStructureDetector"/>
  </extensions>
</idea-plugin>


rich-platform-plugin.xml is an optional dependency in plugin.xml

 
<!-- please see http://confluence.jetbrains.com/display/IDEADEV/Plugin+Compatibility+with+IntelliJ+Platform+Products
     on how to target different products -->
<depends config-file="rich-platform-plugin.xml" optional="true">com.intellij.modules.java</depends>


Then, to test that this will work against Rubymine, I selected the install location and tried to rebuild with Rubymine as my SDK, but I get compilation errors:

/Users/luke.imhoff/git/KronicDeth/intellij-elixir/src/org/elixir_lang/mix/DetectedProjectRoot.java
Error:(7, 91) java: /Users/luke.imhoff/git/KronicDeth/intellij-elixir/src/org/elixir_lang/mix/DetectedProjectRoot.java:7: package com.intellij.ide.util.projectWizard.importSources does not exist
Error:(13, 5) java: /Users/luke.imhoff/git/KronicDeth/intellij-elixir/src/org/elixir_lang/mix/DetectedProjectRoot.java:13: method does not override or implement a method from a supertype
/Users/luke.imhoff/git/KronicDeth/intellij-elixir/src/org/elixir_lang/mix/ProjectStructureDetector.java
Error:(4, 43) java: /Users/luke.imhoff/git/KronicDeth/intellij-elixir/src/org/elixir_lang/mix/ProjectStructureDetector.java:4: package com.intellij.ide.util.importProject does not exist
Error:(5, 43) java: /Users/luke.imhoff/git/KronicDeth/intellij-elixir/src/org/elixir_lang/mix/ProjectStructureDetector.java:5: package com.intellij.ide.util.importProject does not exist
Error:(6, 43) java: /Users/luke.imhoff/git/KronicDeth/intellij-elixir/src/org/elixir_lang/mix/ProjectStructureDetector.java:6: package com.intellij.ide.util.importProject does not exist
Error:(8, 43) java: /Users/luke.imhoff/git/KronicDeth/intellij-elixir/src/org/elixir_lang/mix/ProjectStructureDetector.java:8: cannot find symbol
symbol  : class ProjectJdkForModuleStep
location: package com.intellij.ide.util.projectWizard
Error:(9, 57) java: /Users/luke.imhoff/git/KronicDeth/intellij-elixir/src/org/elixir_lang/mix/ProjectStructureDetector.java:9: package com.intellij.ide.util.projectWizard.importSources does not exist
Error:(10, 62) java: /Users/luke.imhoff/git/KronicDeth/intellij-elixir/src/org/elixir_lang/mix/ProjectStructureDetector.java:10: package com.intellij.ide.util.projectWizard.importSources.impl does not exist
Error:(33, 96) java: /Users/luke.imhoff/git/KronicDeth/intellij-elixir/src/org/elixir_lang/mix/ProjectStructureDetector.java:33: package com.intellij.ide.util.projectWizard.importSources does not exist
Error:(33, 162) java: /Users/luke.imhoff/git/KronicDeth/intellij-elixir/src/org/elixir_lang/mix/ProjectStructureDetector.java:33: package ProjectFromSourcesBuilderImpl does not exist
Error:(36, 178) java: /Users/luke.imhoff/git/KronicDeth/intellij-elixir/src/org/elixir_lang/mix/ProjectStructureDetector.java:36: package com.intellij.ide.util.projectWizard.importSources does not exist
Error:(36, 12) java: /Users/luke.imhoff/git/KronicDeth/intellij-elixir/src/org/elixir_lang/mix/ProjectStructureDetector.java:36: cannot find symbol
symbol  : class DirectoryProcessingResult
location: class org.elixir_lang.mix.ProjectStructureDetector
Error:(57, 53) java: /Users/luke.imhoff/git/KronicDeth/intellij-elixir/src/org/elixir_lang/mix/ProjectStructureDetector.java:57: cannot find symbol
symbol  : class ProjectFromSourcesBuilder
location: class org.elixir_lang.mix.ProjectStructureDetector
Error:(57, 88) java: /Users/luke.imhoff/git/KronicDeth/intellij-elixir/src/org/elixir_lang/mix/ProjectStructureDetector.java:57: cannot find symbol
symbol  : class ProjectDescriptor
location: class org.elixir_lang.mix.ProjectStructureDetector
Error:(72, 108) java: /Users/luke.imhoff/git/KronicDeth/intellij-elixir/src/org/elixir_lang/mix/ProjectStructureDetector.java:72: package com.intellij.ide.util.projectWizard.importSources does not exist
Error:(72, 146) java: /Users/luke.imhoff/git/KronicDeth/intellij-elixir/src/org/elixir_lang/mix/ProjectStructureDetector.java:72: cannot find symbol
symbol  : class ProjectDescriptor
location: class org.elixir_lang.mix.ProjectStructureDetector
Error:(72, 192) java: /Users/luke.imhoff/git/KronicDeth/intellij-elixir/src/org/elixir_lang/mix/ProjectStructureDetector.java:72: cannot find symbol
symbol  : class ProjectFromSourcesBuilder
location: class org.elixir_lang.mix.ProjectStructureDetector
Error:(37, 9) java: /Users/luke.imhoff/git/KronicDeth/intellij-elixir/src/org/elixir_lang/mix/ProjectStructureDetector.java:37: cannot find symbol
symbol  : class DirectoryProcessingResult
location: class org.elixir_lang.mix.ProjectStructureDetector
Error:(37, 63) java: /Users/luke.imhoff/git/KronicDeth/intellij-elixir/src/org/elixir_lang/mix/ProjectStructureDetector.java:37: cannot find symbol
symbol  : variable DirectoryProcessingResult
location: class org.elixir_lang.mix.ProjectStructureDetector
Error:(44, 45) java: /Users/luke.imhoff/git/KronicDeth/intellij-elixir/src/org/elixir_lang/mix/ProjectStructureDetector.java:44: cannot find symbol
symbol  : variable DirectoryProcessingResult
location: class org.elixir_lang.mix.ProjectStructureDetector
Error:(35, 5) java: /Users/luke.imhoff/git/KronicDeth/intellij-elixir/src/org/elixir_lang/mix/ProjectStructureDetector.java:35: method does not override or implement a method from a supertype
Error:(60, 9) java: /Users/luke.imhoff/git/KronicDeth/intellij-elixir/src/org/elixir_lang/mix/ProjectStructureDetector.java:60: cannot find symbol
symbol  : class ProjectJdkForModuleStep
location: class org.elixir_lang.mix.ProjectStructureDetector
Error:(60, 63) java: /Users/luke.imhoff/git/KronicDeth/intellij-elixir/src/org/elixir_lang/mix/ProjectStructureDetector.java:60: cannot find symbol
symbol  : class ProjectJdkForModuleStep
location: class org.elixir_lang.mix.ProjectStructureDetector
Error:(56, 5) java: /Users/luke.imhoff/git/KronicDeth/intellij-elixir/src/org/elixir_lang/mix/ProjectStructureDetector.java:56: method does not override or implement a method from a supertype
Error:(73, 9) java: /Users/luke.imhoff/git/KronicDeth/intellij-elixir/src/org/elixir_lang/mix/ProjectStructureDetector.java:73: cannot find symbol
symbol  : class ProjectFromSourcesBuilderImpl
location: class org.elixir_lang.mix.ProjectStructureDetector
Error:(73, 54) java: /Users/luke.imhoff/git/KronicDeth/intellij-elixir/src/org/elixir_lang/mix/ProjectStructureDetector.java:73: cannot find symbol
symbol  : class ProjectFromSourcesBuilderImpl
location: class org.elixir_lang.mix.ProjectStructureDetector
Error:(77, 18) java: /Users/luke.imhoff/git/KronicDeth/intellij-elixir/src/org/elixir_lang/mix/ProjectStructureDetector.java:77: cannot find symbol
symbol  : class LibraryDescriptor
location: class org.elixir_lang.mix.ProjectStructureDetector
Error:(77, 63) java: /Users/luke.imhoff/git/KronicDeth/intellij-elixir/src/org/elixir_lang/mix/ProjectStructureDetector.java:77: cannot find symbol
symbol  : class LibraryDescriptor
location: class org.elixir_lang.mix.ProjectStructureDetector
Error:(78, 18) java: /Users/luke.imhoff/git/KronicDeth/intellij-elixir/src/org/elixir_lang/mix/ProjectStructureDetector.java:78: cannot find symbol
symbol  : class ModuleDescriptor
location: class org.elixir_lang.mix.ProjectStructureDetector
Error:(81, 41) java: /Users/luke.imhoff/git/KronicDeth/intellij-elixir/src/org/elixir_lang/mix/ProjectStructureDetector.java:81: cannot find symbol
symbol  : class ModuleDescriptor
location: class org.elixir_lang.mix.ProjectStructureDetector
Error:(83, 71) java: /Users/luke.imhoff/git/KronicDeth/intellij-elixir/src/org/elixir_lang/mix/ProjectStructureDetector.java:83: package com.intellij.ide.util.projectWizard.importSources does not exist
Error:(85, 32) java: /Users/luke.imhoff/git/KronicDeth/intellij-elixir/src/org/elixir_lang/mix/ProjectStructureDetector.java:85: type parameter org.elixir_lang.mix.DetectedSourceRoot is not within its bound
Error:(85, 80) java: /Users/luke.imhoff/git/KronicDeth/intellij-elixir/src/org/elixir_lang/mix/ProjectStructureDetector.java:85: type parameter org.elixir_lang.mix.DetectedSourceRoot is not within its bound
Error:(100, 33) java: /Users/luke.imhoff/git/KronicDeth/intellij-elixir/src/org/elixir_lang/mix/ProjectStructureDetector.java:100: cannot find symbol
symbol  : class ModuleDescriptor
location: class org.elixir_lang.mix.ProjectStructureDetector
Error:(113, 45) java: /Users/luke.imhoff/git/KronicDeth/intellij-elixir/src/org/elixir_lang/mix/ProjectStructureDetector.java:113: cannot find symbol
symbol  : class LibraryDescriptor
location: class org.elixir_lang.mix.ProjectStructureDetector
Error:(71, 5) java: /Users/luke.imhoff/git/KronicDeth/intellij-elixir/src/org/elixir_lang/mix/ProjectStructureDetector.java:71: method does not override or implement a method from a supertype
Error:(139, 5) java: /Users/luke.imhoff/git/KronicDeth/intellij-elixir/src/org/elixir_lang/mix/ProjectStructureDetector.java:139: method does not override or implement a method from a supertype
/Users/luke.imhoff/git/KronicDeth/intellij-elixir/src/org/elixir_lang/mix/DetectedSourceRoot.java
Error:(7, 90) java: /Users/luke.imhoff/git/KronicDeth/intellij-elixir/src/org/elixir_lang/mix/DetectedSourceRoot.java:7: package com.intellij.ide.util.projectWizard.importSources does not exist
Error:(13, 5) java: /Users/luke.imhoff/git/KronicDeth/intellij-elixir/src/org/elixir_lang/mix/DetectedSourceRoot.java:13: method does not override or implement a method from a supertype
/Users/luke.imhoff/git/KronicDeth/intellij-elixir/src/org/elixir_lang/action/CreateElixirModuleAction.java


If I marked the projectStructureDetector as optional, why is running my plugin with the Rubymine SDK trying to build ProjectStructureDetector?  If you want the follow source where I attempted this, it's here: https://github.com/KronicDeth/intellij-elixir/commit/902118bce53b324464640a38c479191ce62b8cd0.  Note, when I tried building this for IntelliJ using an SDK based on my ultimate install, then the projectStructureDetector worked in the Run Configuration, but not in the prepare for deployment zip when I installed it back into Intellij IDEA Ultimate.  Why would making the dependency optional make it not even available for IntelliJ IDEA?

5 comments
Comment actions Permalink

When you change the SDK in your plugin project and compile your project, IntelliJ IDEA will recompile your plugin against the new SDK. The compilation is not aware of the concept of optional dependencies; it will recompile the entire source code of your plugin against the new SDK, and the compilation will fail because of the classes missing in the RubyMine API. To test your plugin against RubyMine, you can, for example, turn off the "Before launch | Make" option in your plugin run configuration and copy the compiled plugin manually to the sandbox directory of your RubyMine SDK.

I don't know why the extension point doesn't work when you build a deployment jar. Can you check that the jar contains all necessary classes and .xml descriptors?

0
Comment actions Permalink

If compiling against the new SDK is not the correct steps then https://confluence.jetbrains.com/display/IDEADEV/Plugin+Compatibility+with+IntelliJ+Platform+Products needs to be changed because it says

Before marking a plugin as compatible with all products, you need to verify that it doesn't use any APIs which are specific to IntelliJ IDEA. In order to do that, you can create an IntelliJ Platform SDK pointing to an installation of RubyMine/PyCharm/..., compile your plugin against that SDK and verify that everything compiles.

Or at least a note added that if you're using the optional=true then you can't check this way as immediately above that quoted paragraph is where optional=true is described.

When I prepare for deployment I get a zip and not a jar.  Is the fact that I'm getting a zip an indication that my project is setup incorrectly?

0
Comment actions Permalink

You get a .zip file because your plugin depends on some libraries; they are packaged into the .zip file together with the .jar file of your plugin. You can extract the .zip file and then check the contents of your plugin .jar contained in it.

0
Comment actions Permalink

My intellij-elixir.zip contains OtpErlang.jar, hamcrest-core-1.3.jar, hamcrest-library-1.3.jar, intellij-elixir.jar, junit-4.11.jar, and junit.jar.  I really don't think I should be shipping hamcrest or junit.  I suppose I somehow got my test jars mixed into production?  Do I need to mark something to stop deploying the hamcrest and junit jars?

Inside of intellij-elixir.jar (after adding it as a library) I can see the org.elixir_lang.mix.ProjectStructureDetector, but I don't get any Elixir root detection when I install the zip into IntelliJ Ultimate or community with these plugin.xml and optional rich-platform-plugin.xml:

 
<!-- please see http://confluence.jetbrains.com/display/IDEADEV/Build+Number+Ranges for description -->
<idea-version since-build="131"/>

<!-- please see http://confluence.jetbrains.com/display/IDEADEV/Plugin+Compatibility+with+IntelliJ+Platform+Products
     on how to target different products -->
<depends>com.intellij.modules.lang</depends>
<depends config-file="rich-platform-plugin.xml" optional="true">
com.intellij.modules.java</depends>

<extensions defaultExtensionNs="com.intellij">
  <colorSettingsPage implementation="org.elixir_lang.ElixirColorSettingsPage"/>
  <moduleConfigurationEditorProvider implementation="org.elixir_lang.ModuleConfigurationEditorProvider" order="first"/>
  <fileTypeFactory implementation="org.elixir_lang.ElixirFileTypeFactory"/>
  <internalFileTemplate name="Elixir Module"/>
  <lang.parserDefinition language="Elixir" implementationClass="org.elixir_lang.ElixirParserDefinition"/>
  <lang.syntaxHighlighterFactory key="Elixir" implementationClass="org.elixir_lang.ElixirSyntaxHighlighterFactory"/>
  <localInspection displayName="Ambiguous nested calls" enabledByDefault="true" groupName="Elixir"
                   implementationClass="org.elixir_lang.inspection.NoParenthesesManyStrict" language="Elixir"
                   level="ERROR" shortName="NoParenthesesManyStrict"/>
  <localInspection displayName="Ambiguous parentheses" enabledByDefault="true" groupName="Elixir"
                   implementationClass="org.elixir_lang.inspection.NoParenthesesStrict" language="Elixir"
                   level="ERROR" shortName="NoParenthesesStrict"/>
  <localInspection displayName="Missing End-of-Expression" enabledByDefault="true" groupName="Elixir"
                   implementationClass="org.elixir_lang.inspection.MissingEndOfExpression" language="Elixir"
                   level="ERROR" shortName="MissingEndOfExpression"/>
  <localInspection displayName="Keywords Not At End" enabledByDefault="true"
                   groupName="Elixir" implementationClass="org.elixir_lang.inspection.KeywordsNotAtEnd"
                   language="Elixir" level="ERROR" shortName="KeywordsNotAtEnd"/>
  <moduleType id="ELIXIR_MIX_PROJECT" implementationClass="org.elixir_lang.mix.ModuleType"/>
  <sdkType implementation="org.elixir_lang.SdkType"/>
</extensions>

 
<!-- Extensions that use extension points that are only available in IntelliJ IDEA, but not in the language-specific
     IDEs need to be declared here so that they are optional.  Extension points that are only available in IntelliJ IDEA
     are declared in https://github.com/JetBrains/intellij-community/blob/432621e024f9a2a97d24351eb9dfa5bc03184aac/resources/src/idea/RichPlatformPlugin.xml#L29-L88.
     Thanks to Sergey Ignatov (@ignatov) for explaining this distinction. -->
<idea-plugin version="2">
  <extensions defaultExtensionNs="com.intellij">
      <projectStructureDetector implementation="org.elixir_lang.mix.ProjectStructureDetector"/>
  </extensions>
</idea-plugin>


The META-INF directory in intellij-elixir.jar only has MANIFEST.MF and plugin.xml.  It is missing rich-platform-plugin.xml!  How do I get the build to include rich-platform-plugin.xml?

Screen Shot 2015-04-27 at 4.21.20 PM.png

0
Comment actions Permalink

Ok, so this mix is completely non-obvious to me, but the trick was to mark the parent of the META-INF directory as a Sources Root.  Since META-INF was at the top of my project, I had to move META-INF to the src directory that I already had marked as Sources Root.

Screen Shot 2015-04-27 at 4.43.40 PM.png
Screen Shot 2015-04-27 at 4.43.59 PM.png
Screen Shot 2015-04-27 at 4.44.06 PM.png
I figured this out after comparing the project layout with intellij-erlang.  First, I marked META-INF itself as a Sources Root, but that led to the contents of META-INF being at the top of the jar.  When I marked the parent of META-INF as a Source Root instead, the Sources Roots packaging overwrites or merges (not sure which) the META-INF created by the the Plugin Deployment and I get rich-platform-plugin.xml next to plugin.xml.

Screen Shot 2015-04-27 at 4.45.27 PM.png

The file resolution works (I guess) and I can use the Project Structure Detector in IntelliJ Community and Ultimate.

0

Please sign in to leave a comment.