Tinkerpop-3 Gremlin Not Found For Groovy-Project In IntelliJ IDEA

78 Views Asked by At

Why can IntelliJ IDEA not resolve Gremlin for its SimpleExample?
I need to make a program that doesn't require intervention / manual steps, so I can't use the gremlin/groovy-shell at time of graph-database demonstration. How can you make a simple Gremlin-Groovy project?

Cannot resolve symbol 'Gremlin'

Reproduction

Steps

  1. Select-Click a new project in IntelliJ IDEA
  2. Fill-in fields and confirm for Gremlin-Project
    1. Language: Groovy
    2. Build System: IntelliJ
    3. JDK: corretto-11
    4. Groovy SDK: 4.0.2 enter image description here enter image description here
  3. Navigate-open Project Structure (IntelliJ IDEA)
  4. Add libraries to Project Settings > Libraries or Platform Settings > Global Libraries
    1. compile group: 'org.apache.tinkerpop', name: 'gremlin-core', version: '3.6.3'
    2. compile group: 'org.apache.tinkerpop', name: 'gremlin-driver', version: '3.6.3'
    3. If I don't import these directly, then it will suggest older TinkerPop-2 which we don't plan to evaluate
      1. import com.tinkerpop.blueprints.Graph
      2. import com.tinkerpop.gremlin.groovy.Gremlin
  5. Copy-paste latest found Groovy Classes with Gremlin found
    1. I couldn't find anything newer
  6. Results:
    1. Expected: Import for Gremlin would be found: automatically or recommending
    2. Actually: No Gremlin found for IntelliJ IDEA to import for Groovy
      Cannot resolve symbol 'Gremlin'

Layout

│   SimpleProject.iml
│
├───.idea
│   │   .gitignore
│   │   misc.xml
│   │   modules.xml
│   │   vcs.xml
│   │
│   └───libraries
│           apache_tinkerpop_gremlin_core.xml
│           apache_tinkerpop_gremlin_driver.xml
│           groovy_4_0_2.xml
│
├───lib
│
└───src
        SimpleExample.groovy

Code

SimpleProject.groovy

import org.apache.tinkerpop.gremlin.structure.Graph

class SimpleExample {
  static {
    Gremlin.load()
  }
  public List exampleMethod() {
    Graph g = TinkerGraphFactory.createTinkerGraph()
    def results = []
    g.v(1).out('knows').fill(results)
    return results
  }
}

SimpleProject.iml

<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
  <component name="NewModuleRootManager" inherit-compiler-output="true">
    <exclude-output />
    <content url="file://$MODULE_DIR$">
      <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
    </content>
    <orderEntry type="jdk" jdkName="corretto-11" jdkType="JavaSDK" />
    <orderEntry type="sourceFolder" forTests="false" />
    <orderEntry type="library" name="groovy-4.0.2" level="project" />
    <orderEntry type="library" name="tinkerpop.gremlin.groovy" level="application" />
    <orderEntry type="library" name="apache.tinkerpop.gremlin.core" level="project" />
    <orderEntry type="library" name="apache.tinkerpop.gremlin.driver" level="project" />
  </component>
</module>
misc.xml
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
  <component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="corretto-11" project-jdk-type="JavaSDK">
    <output url="file://$PROJECT_DIR$/out" />
  </component>
</project> 
0

There are 0 best solutions below