title: How to add janus graph imports to gremlin groovy script engine?
body: <p>I use GremlinGroovyScriptEngine, which is part of gremlin-server to evaluate string gremlin queries - like this:</p>
  <pre><code>final ScriptEngine engine = new GremlinGroovyScriptEngine();
  engine.eval(&quot;g.V().count().next();&quot;);
  </code></pre>
  <p>... everything was good until I have started to use janus-graph specific elements in queries - like that (last string):</p>
  <pre><code>final ScriptEngine engine = new GremlinGroovyScriptEngine();
  
  //== Set binding with traversal/graph/transaction to script engine ===
  JanusGraphManagement mgmt = jg.openManagement();
  SimpleBindings trBinding = new SimpleBindings();
  trBinding.putAll(this.bindings);
  trBinding.put(&quot;mgmt&quot;, mgmt);
  engine.setBindings(trBinding, ScriptContext.ENGINE_SCOPE);
  
  result = engine.eval(&quot;mgmt.makePropertyKey('zzzzzz').dataType(String.class).cardinality(Cardinality.SINGLE).make();&quot;);
  </code></pre>
  <p>... in that case I got:</p>
  <pre><code>MissingPropertyException: No such property: SINGLE for class: org.apache.tinkerpop.gremlin.structure.VertexProperty$Cardinality
  </code></pre>
  <p>As workaround I define whole class name <code>org.janusgraph.core.Cardinality.SINGLE</code> in query.</p>
  <p>As I understand it is possible to set up all specific import to script engine during its creation.
  Janus specific imports is defined in <a href="https://github.com/JanusGraph/janusgraph/blob/master/janusgraph-all/src/main/java/org/janusgraph/graphdb/tinkerpop/plugin/JanusGraphGremlinPlugin.java" rel="nofollow noreferrer">JanusGraphGremlinPlugin</a> class which I use during gremlin-script-engine initialization in this way:</p>
  <pre><code>JanusGraphGremlinPlugin graphGremlinPlugin = JanusGraphGremlinPlugin.instance();
          
  GremlinScriptEngineManager engineManager = new CachedGremlinScriptEngineManager();
  
  /* Create gremlin script engine */
  GremlinGroovyScriptEngine engine = GremlinGroovyScriptEngine.class
  .cast(engineManager.getEngineByName(&quot;gremlin-groovy&quot;));
  </code></pre>
  <p>... but it does not work. It seems that <code>engineManager</code> not set any plugins because after creation of engine <code>engine.getPlugins().size()</code> gives 0.</p>
  <p>Also there is direct method of engine for loading plugin:</p>
  <pre><code>...
   engine.loadPlugins(Collections.singletonList(graphGremlinPlugin))
  ...
  </code></pre>
  <p>... but it receive <code>List</code> of instances of <code>org.apache.tinkerpop.gremlin.groovy.plugin.GremlinPlugin</code> class which is deprecated (replaced by <code>org.apache.tinkerpop.gremlin.jsr223.GremlinPlugin</code>).
  Moreover <a href="https://github.com/JanusGraph/janusgraph/blob/master/janusgraph-all/src/main/java/org/janusgraph/graphdb/tinkerpop/plugin/JanusGraphGremlinPlugin.java" rel="nofollow noreferrer">JanusGraphGremlinPlugin</a> class is descendant of <code>org.apache.tinkerpop.gremlin.jsr223.AbstractGremlinPlugin</code> so that it cannot be used in <code>.loadPlugins()</code> method.</p>
  <p>Do you know how it is possible to use JanusGraphGremlinPlugin class to add janus-specific imports to gremlin-groovy-engine?</p>