How to add a dependency on the com.intellij.lexer classes in Gradle? Follow
I am working on a JFlex lexer for a plugin, and to test it, I have a separate application subproject in gradle. The application has a compile and runtime dependency on the com.intellij.lexer classes, such as FlexAdapter. I am trying to figure out how to add those dependencies to my build.gradle. My first attempt seemed to work, but I think it got the wrong version of the classes:
dependencies {
compile "com.intellij:openapi:7.0.3"
runtime "com.intellij:openapi:7.0.3"
}
For my next attempt, I tried scanning dependencies on the actual gradle plugin project to try and figure out the dependency to add. Using Analyze Dependencies, and selecting the class that uses FlexAdapter, I get this:
But it's unclear to me what to add to build.gradle. I tried:
dependencies {
implementation "com.jetbrains:httpclient-4.5.2:2018.1.5"
}
but it didn't work. Why would httpclient have anything to do with it anyway?
Ultimately I just want to be able to use com.intellij.lexer.FlexAdapter in a non-plugin gradle build for testing purposes.
Please sign in to leave a comment.
Hi Chris,
com.intellij.lexer classes can be found in com.jetbrains.intellij.idea:intellij-core@zip package at https://www.jetbrains.com/intellij-repository/releases repository. List of available versions also can be found there.
Hi Alexander,
Thanks, but that didn't quite do it. I tried adding this to build.gradle:
And it configures OK, but when I try to build I get:
Any idea?
Thanks,
Chris
> Any idea?
Gradle cannot use zip as a compile dependency for Java. You have to unpack it and add jars as dependencies.
OK, thanks. I'll give that a try. I'm very new to Gradle so I appreciate your patience (and quick responses!).
Chris
I got it working, thanks so much Alexander! For the benefit of others, here's what I did.
1. Downloaded the 2018.1.6 version of intellij-core.zip from https://www.jetbrains.com/intellij-repository/releases
2. Unpacked it into src/main/resources for my subproject. The directory looks like:
I only actually need intellij-core.jar, but I left the others there in case I need them in the future.
3. Added the following to my build.gradle:
Side note: Strangely, the 'version:"2018.1.6"' is not actually validated - I can put whatever numbers I want in there and Gradle accepts it. I guess Gradle is not unpacking the manifest from the jar to verify the version.
Hopefully this will help someone.
Chris