- Requirements
- Setup
- Main Gradle tasks
- Configuring the sandbox IDE
- Build the plugin archive
- Other important tasks
- Configure IDE to automatically add license header
to update toc, please read this page.
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.
Just clone the project and execute the tests to ensure everything is ok.
# clone the project
$ git clone git@github.com:open-policy-agent/opa-idea-plugin.git
$ cd opa-idea-plugin
# run tests
$ ./gradlew :test
> Task :compileKotlin
w: /Users/vince/workspace/perso/final/opa-idea-plugin/src/main/kotlin/org/openpolicyagent/ideaplugin/ide/actions/CheckAction.kt: (21, 13): Variable 'editor' is never used
w: /Users/vince/workspace/perso/final/opa-idea-plugin/src/main/kotlin/org/openpolicyagent/ideaplugin/openapiext/CommandLineExt.kt: (86, 29): Unnecessary safe call on a non-null receiver of type OutputStream
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.3/userguide/command_line_interface.html#sec:command_line_warnings
BUILD SUCCESSFUL in 20s
15 actionable tasks: 13 executed,2 up-to-date
./gradlew :plugin:buildPlugin
-- fully build the plugin and create an archive atplugin/build/distributions
which can be installed into your IDE viaInstall plugin from disk...
action found inSettings > Plugins
menu../gradlew :plugin:runIde
-- run a development IDE with the plugin installed../gradlew :test
./gradlew clean :plugin:verifyPlugin
-- verify the plugin binary compatibility. More information here.
note: The :
in front of the task name is important because now there are several Gradle modules.
You can use the Gradle task :plugin:runIde
to run sandbox IDE of your choice (IntelliJ or PyCharm) with these plugins
installed:
- opa
- psi viewer
Once the sandbox IDE has started, you will have to create or open an existing project to test the plugin.
In most of the case, we will only need to run IntelliJ as a sandbox IDE. But it may be useful to run another IDE to test
interoperability. For example, even if other IDE than IntelliJ can not create a rego project
, it can open it.
You can choose which sandbox IDE to run, by setting the property baseIDE
in gradle.properties
Note: Sometime you may need to reset your sandbox, you can use the task clean
to do it.
Run the task :plugin:runIde
, the plugin distribution (ie thezip
) will be generated in build/distributions/opa-idea-plugin-<version>-<chanel>.zip
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
the 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
.
If it's not already done, please install the copyright plugin. This plugin will automatically add the license header when you create a file.
To configure it , open the Settings / Preferences dialog
and select Editor | Copyright
. Create a new profile with
this license header:
Use of this source code is governed by the MIT license that can be
found in the LICENSE file.
To check if project file contains the license header, run the script hack/check-license.sh
$ hack/check-license.sh
Checking files contains license header...
Check OK