Adoptable Cookbooks List

Looking for a cookbook to adopt? You can now see a list of cookbooks available for adoption!
List of Adoptable Cookbooks

Supermarket Belongs to the Community

Supermarket belongs to the community. While Chef has the responsibility to keep it running and be stewards of its functionality, what it does and how it works is driven by the community. The chef/supermarket repository will continue to be where development of the Supermarket application takes place. Come be part of shaping the direction of Supermarket by opening issues and pull requests or by joining us on the Chef Mailing List.

Select Badges

Select Supported Platforms

Select Status

RSS

intellij (11) Versions 0.3.0

Manages the installation and configuration of the IntelliJ IDEA

Policyfile
Berkshelf
Knife
cookbook 'intellij', '= 0.3.0', :supermarket
cookbook 'intellij', '= 0.3.0'
knife supermarket install intellij
knife supermarket download intellij
README
Dependencies
Changelog
Quality 17%

intellij

This cookbook allows installing and configuring the IntelliJ IDEA IDE. It can
install/update the IntelliJ package, configure "workspace" (the configuration from the idea.config.path directory),
install plugins from the Plugins Repository and configure projects (artifacts, run configurations, SDKs, modules etc.).

The main purpose of this cookbook is to be used as automatic environment configuration for developers.

Every project has its own configuration which should be added to IDE in order to make it work.
Configuring the IntelliJ IDEA can take some time (there are a lot of places which you can adjust to your needs!)
and - what is worse - can be forgotten, which leads to having a hard time when there is need to create a new environment
(for example, a new person comes to the project).

Storing your project's configuration inside Chef scripts is good not only because it can configure
the whole IJ configuration for you - it can also be used as a documentation for any new person.

NOTICE: This cookbook is NOT idempotent!

One of the Chef's ideology is to create idempotent cookbooks
that will always configure the environment the same way. This is NOT the case for this cookbook.

IntelliJ is a great tool with many configurations and developers are usually customising their environments. It means that
Chef should not update all of the configuration, which would lead to losing any changes made by the developer, but instead
it should only make sure that the base configuration stays the same. This way you can always repair your environment by
running the cookbook again - it will only restore the exact configuration written in the recipe and leave your personal
changes.

Platforms

The cookbook is mainly tested on the Windows systems. It uses mainly Ruby generic functionality
(such as zipfile, nokogiri etc.) so it is highly possible that it could be used also on any other systems by simply
modifying the paths. The support for other systems will be probably soon added.

Usage

The main way of using the cookbook is to use it's LWRP resources.

Recipes

Default.rb

The [default recipe](recipes/default.rb) will only install the IntelliJ IDEA without configuring anything. It uses
following attributes:

Attribute Default value Description
['intellij']['recipe']['path'] C:/Program Files/JetBrains/IntelliJ Path where the IntelliJ will be installed. If the path is not empty, the IntelliJ will be updated to specific version/edition.
['intellij']['recipe']['source'] nil Source from which the cookbook will download the IntelliJ package. If empty, Chef will download it from the Jetbrains site.
['intellij']['recipe']['checksum'] nil Checksum for the IntelliJ package. If you did not set the source parameter, Chef will automatically download it from the Jetbrains site.
['intellij']['recipe']['edition'] :community Edition of the IntelliJ to be downloaded. Can be :community or :ultimate.
['intellij']['recipe']['version'] nil Version of the IntelliJ to be downloaded. If empty, Chef will automatically use the latest version.
['intellij']['recipe']['user'] nil The user used to install the IntelliJ package.
['intellij']['recipe']['group'] nil The group used to install the IntelliJ package.

Resources

The main functionality of the cookbook lies within it's resources. You can use them by defining dependency for
the cookbook inside the metadata.rb file:

depends 'intellij'

Default

[Default resource](resources/default.rb) intellij is used to download/update the IntelliJ installation.

Action Description
install This action will install new IntelliJ package. If the path is used by the different installation, it will compare them and display warning if the versions are not the same. Default action.
delete This action will remove the IntelliJ package from the specified path.
update This action is mainly the same as the install action, but will update the existing installation rather than just displaying a warning message.
Property Type Description
path String Path where the IntelliJ package will be installed. Defined also as name attribute.
version String Version of the IntelliJ to be downloaded. If empty, Chef will automatically use the latest version.
source String Source from which the cookbook will download the IntelliJ package. If empty, Chef will download it from the Jetbrains site. If you are specifying your own source, please set also the checksum, version and edition parameters.
checksum String Checksum for the IntelliJ package. If you did not set the source parameter, Chef will automatically download it from the Jetbrains site.
edition Symbol Edition of the IntelliJ to be downloaded. Can be :community or :ultimate.
user String The user used to install the IntelliJ package.
group String The group used to install the IntelliJ package.

Example:

intellij 'Installing the 2018.3.4 IntelliJ from the Jetbrains download site' do
  path '/home/myuser/IntelliJ'
  version '2018.3.4'
  user 'myuser'
  group 'mygroup'
  edition :community
  action :update
end

intellij 'This will use source defined as property. Version and edition are useful.' do
  path '/home/myuser/IntelliJ'
  version '2018.3.4'
  source 'https://download.jetbrains.com/idea/ideaIU-2018.3.4.win.zip'
  checksum 'bff5d4f07762f2582db80240cfe1e6586cf47c304a7a2c50eb672e63be98229a'
  user 'myuser'
  group 'mygroup'
  edition :community
  action :update
end

Workspace

Normally there is one "workspace" defined for all IntelliJ projects. Default path is stored within the idea.properties
as the idea.config.path parameter. Having the same configuration for all projects not always is good (shared configuration
is for example IDEA's theme, plugins, installed SDKs etc.). If you will break this configuration, it is highly possible
that all of your projects will stop working.

Creating separated workspace is not as easy as it would seem to. IntelliJ supports changing the path for configuration by
changing the IDEA_PROPERTIES environment variable,
but the change would affect all of the projects if set globally. Unfortunately, you can not change it by setting the
-Didea.config.path parameter during the IDEA's execution as it would try to open it as a file.

As a workaround of this problem, the cookbook will create special shortcut that is changing this location only for the
specific workspace. It will be created inside path parameter - you should start the IntelliJ only from this shortcut
if you want to have your configuration loaded properly.

[Resource's configuration](resources/workspace.rb):

Action Description
create This action will prepare new workspace for the IntelliJ and update all configuration that's had changed. Default action.
delete This action will remove the IntelliJ's workspace.
Property Type Description
path String Path where the workspace will be created.
intellij_path String Path where the IntelliJ package is installed. It is used to create the shortcut to the workspace.
default_project String If set, the cookbook will set the project from this path as the default one (meaning that the IntelliJ will not ask you to open project location during the first usage).
color_scheme Symbol Color scheme to be used. Can be :IntelliJ or :Darcula.
user String The user used to create the workspace.
group String The group used to create the workspace.

Example:

intellij_workspace 'Creating the separated Intellij configuration' do
  path '/home/myuser/workspace'
  default_project '/home/myuser/workspace/project'
  intellij_path '/home/myuser/IntelliJ'
  color_scheme :IntelliJ
  user 'myuser'
  group 'mygroup'
  action :create
end

intellij_workspace 'This will configure the global instance of configuration' do
  path '/home/myuser/.IdeaIC14'
  default_project '/home/myuser/workspace/project'
  intellij_path '/home/myuser/IntelliJ'
  color_scheme :Darcula
  user 'myuser'
  group 'mygroup'
  action :create
end

Plugin

[This resource](resources/plugin.rb) can be used to install the plugin from the Jetbrains plugins repository.
It will use the Jetbrains API to find plugins matching the specified name. It also allows downloading the plugin from
the specific update ("version"). If the plugin is downloaded as the .zip file, it will also automatically unzip it in the
proper location, so the user will not have to do it manually.

Action Description
install This action will download the plugin and then install it inside the proper directory. Default action.
Property Type Description
name String Name of the plugin. Should be defined as resource's name. Has to match exactly the name displayed inside the plugins repository, otherwise Chef will raise error.
workspace String Path for the IntelliJ's workspace. It is used to define the proper path for the plugins installations. Can be also set up as the "global workspace" path.
source String If set, the cookbook download the plugins from the different source than official repository.
update Integer Version of the plugin to be downloaded. If empty, the cookbook will download the latest version.
edition Symbol Some plugins are available only for one edition. To make sure that correct plugin will be installed, you should pass the edition parameter. Can be :community or :ultimate.
user String The user used to install the plugin.
group String The group used to install the plugin.

Example:

intellij_plugin 'Chef integration' do
  workspace '/home/myuser/.IdeaIC14'
  update 57884
  edition :ultimate
  action :install
end

SDK

[This resource](resources/sdk.rb) can be used to install the SDK for all projects using the workspace.
Please not that not all SDK types are available in the community edition of the IntelliJ.

Action Description
add This action configures the SDK inside the workspace.
delete This action will delete the SDK from the workspace.
Property Type Description
sdk_name String Name of the SDK. Should be defined as resource's name.
workspace String Path for the IntelliJ's workspace.
path String Path where the SDK is installed.
type Symbol Type of the SDK. Can be :JavaSDK or :RUBY_SDK. More SDK's will be added if needed.
user String The user used to install the IntelliJ's SDK.
group String The group used to install the IntelliJ's SDK.

Example:

intellij_sdk 'Ruby 2.6.1' do
  workspace  '/home/myuser/.IdeaIC14'
  path '/home/myuser/Ruby26-x64'
  type :RUBY_SDK
  action :add
end

Project

[This resource](resources/project.rb) will create a new IntelliJ IDEA's project.

Action Description
create This action will create and configure the project.
delete This action will delete the project.
Property Type Description
path String Path where the project will be created. Name attribute.
project_name String Optional project's name. If empty, the name of the directory will be used.
default_sdk_name String Optional. Name of the SDK that will be set up as default one.
default_sdk_type Symbol Type of the SDK. Can be :JavaSDK or :RUBY_SDK. More SDK's will be added if needed.
language_level String Language level of Java used within the project. Default: JDK_10.
user String The user used to create the project.
group String The group used to create the project.

Example:

intellij_project '/home/myuser/workspace/project' do
  project_name 'My fantastic project'
  default_sdk_name 'Ruby 2.6.1'
  default_sdk_type :RUBY_SDK
  action :create
end

Module

[This resource](resources/project.rb) will create new module to the existing IntelliJ IDEA's project.
Modules are usually root directories of source codes for your applications. The resource assumes that you already have
them on the disk (either downloaded from repository or simply created before using this cookbook.).

The resource will automatically detect whether the project is Maven project. If yes, it will add it to the IJ's
Maven configuration.

It also tries to automatically detect which control version system is used (if any). Currently only
Git repositories will be detected - support for CVS and other ones will be added if needed.

Action Description
create This action will create and configure the module.
delete This action will delete the module.
Property Type Description
path String Path where the module is created.
type Symbol Type of the module. IntelliJ has different types for different languages/frameworks. Currently possible options are: :JAVA_MODULE, :RUBY_MODULE and :WEB_MODULE. Defaults to :WEB_MODULE.
sdk_type Symbol Optional SDK type for this specific module. Can be :JavaSDK, :RUBY_SDK or :none.
sdk_name String Optional SDK name for this specific module.
module_name String Optional module's name. If not set, the name of the directory will be used.
project_path String Path where the project is created. Required.
user String The user used to install the module.
group String The group used to install the module.

Example:

intellij_module '/home/myuser/Maven-module' do
  project_path '/home/myuser/workspace/project'
  type :JAVA_MODULE
  module_name 'sample-maven-module'
  sdk_name 'JDK 10.0'
  sdk_type :JavaSDK
  action :create
end

Run configuration

[This resource](resources/run_configuration.rb) can be used to define Run configurations used within the project.

Run configurations are usually stored within the .idea/workspace.xml file, inside the RunManager component.
There are many plugins which are adding new possible templates for RC, so it is almost impossible to cover
all of the types in this cookbook. Instead of making resource for every type, you should provide the configuration as XML.
When using the resource, please make sure that the configuration will be taken from the workspace.xml file.

Action Description
create This action will create and configure the Run Configuration.
delete This action will delete the Run Configuration.
Property Type Description
config_name String Name of the Run configuration. Should be defined as resource's name.
type String Type for the Run configuration. Please check the workspace.xml file to get this value.
factory String Factory for the Run configuration. Please check the workspace.xml file to get this value.
folder String Optional. If set, the resource will move this configuration inside this folder.
body String Body of the run configuration. Please check the workspace.xml file to get this value. You should copy the XML fragment INSIDE the <configuration> element.
project_path String Path where the project is created. Required.
user String The user used to install the run configuration.
group String The group used to install the run configuration.

Example:

intellij_run_configuration 'Start simple batch script' do
  project_path '/home/myuser/workspace/project'
  type 'BatchConfigurationType'
  factory 'Batch'
  body <<-EOH
    <option name="INTERPRETER_OPTIONS" value="" />
    <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
    <option name="PARENT_ENVS" value="true" />
    <module name="" />
    <option name="SCRIPT_NAME" value="$PROJECT_DIR$/example.bat" />
    <option name="PARAMETERS" value="Hello" />
    <method v="2" />
  EOH
  action :create
end

Artifact

[This resource](resources/artifact.rb) can be used to add an IntelliJ's artifact inside the project.
Similar to the Run configuration resource, it uses whole XML fragments to avoid making very complicated logic for all
possible types of artifacts.

Action Description
create This action will create and configure the artifact.
delete This action will delete the artifact.
Property Type Description
artifact_name String Name of the artifact. Resource's name attribute.
output_path String Path where the artifact will be created after rebuilding sources within IntelliJ.
root String <root> element of the artifact. Please check the original artifact file (in ./idea/artifacts directory) to get this value.
project_path String Path where the project is created. Required.
type String The type of the artifact. Please check the original artifact file (in ./idea/artifacts directory) to get this value.
user String The user used to install the artifact.
group String The group used to install the artifact.

Example:

intellij_artifact 'sample-maven-module:jar' do
  project_path 'C:/Test/Workspace/My Project'
  type 'jar'
  root <<-EOH
    <root id="archive" name="sample-maven-module.jar">
      <element id="module-output" name="sample-maven-module" />
    </root>
  EOH
  action :create
end

Changelist

[This resource](resources/changelist.rb) allows configuring the change lists within the IntelliJ.
Change lists are useful because they allow the user to distinguish the changes made in code into the smaller groups.
Another great way to use them is to mark changes as "not pushable" (sometimes project requires to change the files
without committing them - this way you will not push them by mistake).

Action Description
create The changelist will be set as exactly as defined with this resource. Any existing changelist will be completely replaced.
delete The changelist, if existing, will be removed.
update If the change list does not exist, it creates it with parameters defined within the resource. If it does exist, only provided parameters will be updated (not replacing unspecified attributes).
add_files If the changelist exists, the resource will update provided parameters. If the changelist had files other than provided ones, the latter will be added to changelist (not removing existing files). If the changelist does not exist, it will add it.
delete_files If the changelist exists, the resource will update provided parameters. If the user specified files, the resource will remove them from the existing changelist. If the changelist did not exist, it will create it with empty files list.
Property Type Description
changelist_name String Name of the change list. Resource's name attribute.
comment String Optional description for the change list.
default Boolean Sets the resource as default if true.
files String, Array The list of files to be included within the change list. The resource will remove those files from different change lists.
project_path String Path where the project is created. Required.
user String The user used to create the workspace file.
group String The group used to create the workspace file.

Examples:

intellij_changelist 'This will make sure that the change list will be defined exactly as specified' do
  project_path '/home/user/my/project'
  changelist_name 'My changelist'
  comment 'Testing the change lists mechanism'
  files %w(/home/user/my/project/file1.txt /home/user/my/project/file2.txt)
  action :create
end

intellij_changelist 'This will only update the comment and set up the changelist as default' do
  project_path '/home/user/my/project'
  changelist_name 'My changelist'
  comment 'Changed the comment'
  default true
  action :update
end

intellij_changelist 'This will only update the files within the change list exactly as provided' do
  project_path '/home/user/my/project'
  changelist_name 'My changelist'
  files %w(/home/user/my/project/new-file.txt)
  action :update
end

intellij_changelist 'This will update the changelist and add files instead of replacing them' do
  project_path '/home/user/my/project'
  changelist_name 'My changelist'
  comment 'Changed the comment again'
  files %w(/home/user/my/project/added-file.txt)
  action :add_files
end

intellij_changelist 'This will update the changelist and remove the file from it' do
  project_path '/home/user/my/project'
  changelist_name 'My changelist'
  default false
  files %w(/home/user/my/project/new-file.txt)
  action :delete_files
end

intellij_changelist 'This will completely remove the change list' do
  project_path node['intellij']['tests']['project_path']
  changelist_name 'My changelist'
  action delete
end

More examples

You can find more examples of usage for every resource inside the [recipes](recipes) directory.

Dependent cookbooks

zipfile >= 0.0.0
xmledit >= 0.0.0
tar >= 0.0.0

Contingent cookbooks

There are no cookbooks that are contingent upon this one.

intellij CHANGELOG

0.3.0

  • Added ChefSpec and Kitchen tests for the cookbook
  • Fixed error with intellij_module not creating the module correctly
  • Added support for the IntelliJ change lists
  • Updated README for better displaying information
  • Refactored resources to use only resources directory - change made to write tests

0.2.0

  • Added support for the Linux platforms
  • Passing the linters (the rubocop and foodcritic from the delivery local verify)
  • Added TESTING and CHANGELOG to increase the cookbook quality

0.1.0

Initial release.

  • Added support for resources: artifact, default, module, plugin, project, run_configuration, sdk, workspace

Collaborator Number Metric
            

0.3.0 failed this metric

Failure: Cookbook has 0 collaborators. A cookbook must have at least 2 collaborators to pass this metric.

Contributing File Metric
            

0.3.0 failed this metric

Failure: To pass this metric, your cookbook metadata must include a source url, the source url must be in the form of https://github.com/user/repo, and your repo must contain a CONTRIBUTING.md file

Foodcritic Metric
            

0.3.0 passed this metric

No Binaries Metric
            

0.3.0 failed this metric

Failure: Cookbook should not contain binaries. Found:
intellij/test/cookbooks/test_intellij/recipes/default.rb

Testing File Metric
            

0.3.0 failed this metric

Failure: To pass this metric, your cookbook metadata must include a source url, the source url must be in the form of https://github.com/user/repo, and your repo must contain a TESTING.md file

Version Tag Metric
            

0.3.0 failed this metric

Failure: To pass this metric, your cookbook metadata must include a source url, the source url must be in the form of https://github.com/user/repo, and your repo must include a tag that matches this cookbook version number