Skip to content

Latest commit

 

History

History
73 lines (52 loc) · 2.72 KB

setup_development_env.md

File metadata and controls

73 lines (52 loc) · 2.72 KB

Table of Content

to update toc, please read this page.

Requirements

To build the project, you will need the following requirement

  • JDK 1.8
  • OPA binary (must be in the path, check version in the readme)
  • IntelliJ (community or ultimate version)

It's optional but we recommend you to install the following IntelliJ plugin:

  • Grammar-Kit to get highlighting of the grammar file.
  • PsiViewer to view the AST of Rust files right in the IDE.

Setup

Just clone the project and execute the tests to ensure everything is ok.

# clone the project 
$ git clone git@github.com:vgramer/opa-idea-plugin.git
$ cd opa-idea-plugin

# run tests
$ ./gradlew  test        

> Task :generateRegoLexer
Reading "/tmp/a/opa-idea-plugin/src/main/grammar/RegoLexer.flex"

Warning : Macro "EOL" has been declared but never used.
Constructing NFA : 193 states in NFA
Converting NFA to DFA : 
........................................................................................................
106 states before minimization, 96 states in minimized DFA
Writing code to "/tmp/a/opa-idea-plugin/src/main/gen/org/openpolicyagent/ideaplugin/lang/lexer/_RegoLexer.java"

> Task :generateRegoParser
Rego.bnf parser generated to /tmp/a/opa-idea-plugin/src/main/gen

BUILD SUCCESSFUL in 13s
16 actionable tasks: 16 executed
 

Run a Sandbox ide to test plugin

You can use the gradle task runIde to run an IntelliJ sandbox with

  • opa plugin installed
  • psi viewer installed

Once the sandbox ide has started, you will have to create or open an existing project to test the plugin.
Sometime you may need to reset your sandbox, you can use the task clean to do it.

Build the plugin archive

Run the task buildPlugin, the jar will be generated in build/libs/opa-idea-plugin-<version>.jar

Other important tasks

The lexer and parser code which are generated by tools are not committed in git. They can respectively be generated by the tasks generateRegoLexer and generateRegoParser.

These tasks are linked to the KotlinCompile task so if you try to build, test or run the sandbox ide, the lexer and parser will be automatically generated.

The code is generated in the gen folder. If you want to reset the generated, just delete the content of the gen folder and launch tasks generateRegoLexer and generateRegoParser.