intellij-pants-plugin
- The intellij-pants-plugin supports importing, compiling and testing Pants projects.
- Scala and Java projects are fully supported. Python projects are supported on a best effort basis.
- As of 12/2/2016, latest version of the plugin supports IntelliJ IDEA 2016.3 and up for both Community Edition and Ultimate Edition.
- As of 12/2/2016, the plugin supports 1.1.x, 1.2.x, and current master of Pants.
User documentation
Installing the Plugin
Please use Plugins
tab: (Main menu: Settings | Plugins) to install the plugin.
Find Pants Support
plugin. Install and Restart IntelliJ.
Pants Support
features
Minimum set of plugins is required to enable - Gradle
- Groovy
- Java Bytecode Decompiler
- JUnit
- Python Community Edition (if you are importing python projects)
- Scala
Importing an entire project directory
- Use Main menu: File -> New -> Project From Existing Sources
- Select project directory
- Choose "Pants" on the next screen
- Make sure the check box "All Targets in the directory" is enabled and proceed with the wizard
Importing targets from a BUILD File
- Use Main menu: File -> New -> Project From Existing Sources
- Select a Build File from within the project
- Check the targets you want to Import and proceed with the wizard. (Please wait for the targets to show up)
Importing targets from a script
- Use Main menu: File -> New -> Project From Existing Sources
- Select an executable that will use export goal to produce a desirable project structure. See an integration test as an example.
Importing multiple BUILD files/directories
- Import the first directory/BUILD file
- Use File -> New -> Module From Existing Sources to import next directories/BUILD files
Once you import the project using above steps, you will see the "Project View" with multiple modules configured.
Invoking Pants within IntelliJ
The plugin can invoke any Pants commands via Pants Tasks.
- To configure a Pants Task simply create a new Pants Run Configuration
- Choose a target to run a task for
- Fill the rest of options for the task. Note there is a task for each Pants goal.
- Run the Task
- To debug a task simply press Debug button next to Run button.
- Note: you can create a task for any goal
Predefined Pants Tasks for test targets
The plugin can also generate test configurations.
For example if a test class is opened then with a right click it's easy to create a task to run and debug
With a right click in Project View it's easy to create a test task to run all tests for a target
Compilation
- Pants' compile goal (Default)
The plugin will use
pants compile <list of targets>
to compile your project once aMake
orPantsCompile
command is invoked.
Compilation options can be configured in Preferences -> Build, Execution, Deployment -> Compiler -> Pants:
Plugin Features.
- Project File Tree View.
The plugin configures modules per pants build target. Due to multiple modules, the default "Project View" is not very user friendly.
The Plugin provides a custom view "Project Files Tree View". This view adheres to your repository file hierarchy.
You can switch to this view as follows:
"Project Files Tree View" also provides an ability to filter out files that weren't loaded during project generation.
- Project Regeneration using IntelliJ Action.
If you add a dependency to your project, you can re-resolve project using IntelliJ Action in background.
Use Main Menu: Help -> Find Action or Short hand Cmd+Shift+A and select Action "Refresh all External Projects"
Remember to check "Include non-menu actions"
- Running tests within IntelliJ You can right click on tests and run tests.
Report Bugs
If you encounter a bug, please check for existing issues or file a new one on the project page.