/intellij-pants-plugin

IntelliJ Plug-in for Pants Build

Primary LanguageJavaApache License 2.0Apache-2.0

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.

Minimum set of plugins is required to enable Pants Support features

  • 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 Import project from 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 Import project from BUILD file
  • Check the targets you want to Import and proceed with the wizard. (Please wait for the targets to show up) Choose Targets

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 Creating of a new Pants Run Configuration
  • Choose a target to run a task for Choosing a target Configured target
  • Fill the rest of options for the task. Note there is a task for each Pants goal. Configure Pants Task
  • Run the Task Configured Pants Task
  • To debug a task simply press Debug button next to Run button.
  • Note: you can create a task for any goal Bundle Task

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 Run Configuration Producer Preconfigured Run Configuration

With a right click in Project View it's easy to create a test task to run all tests for a target Run Configuration Producer

Compilation

  • Pants' compile goal (Default) The plugin will use pants compile <list of targets> to compile your project once a Make or PantsCompile command is invoked. Compilation via compile goal

Compilation options can be configured in Preferences -> Build, Execution, Deployment -> Compiler -> Pants: Compilation Options

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 "Project Files Tree View" also provides an ability to filter out files that weren't loaded during project generation. Show Only Loaded Files
  • 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" Refresh Project
  • 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.