IntelliJ IDEA 14.1.0 Help

Generating and Updating Copyright Notice

In this section:

Basics

Your project can contain files to be protected by copyright. Instead of generating and editing copyright notices in each file separately, IntelliJ IDEA suggests that you use copyright profiles. Each copyright profile is associated with a certain scope and defines the text and formatting of the copyright notice to be inserted in the files within this scope.

You may need several different copyright notices for files within the same project. In this case, IntelliJ IDEA enables you to define several profiles and associate them with relevant scopes.

You can also declare one of the available profiles as default project copyright profile. The settings of this profile will be applied to any project file that is not included in any scope or belongs to a scope, which has no associated copyright profile.

A copyright profile can contain an explicit plain text of the copyright notice or its definition through a Velocity template. You can type the desired text or a Velocity template manually or import a copyright notice definition from an existing profile.

Note the following:

  • If a file does not belong to any scope with a copyright profile assigned, the default copyright profile is used.
  • If the No copyright option has been set as the Default Copyright Profile in the Copyright settings dialog box, no copyright notice will be created or updated and IntelliJ IDEA will prompt you to configure a profile to apply.

Prerequisite

Before using copyright profiles and generating copyright notices, make sure that the Copyright plugin is enabled.

Creating, importing and deleting the copyright profiles

To create a copyright profile from scratch

  1. Open the Settings dialog box, and then open the Copyright Profiles page below the Copyright node.
  2. Click the Add button add on the toolbar.
  3. In the Create new copyright profile dialog box that opens specify the name of the new profile and click OK. You return to the Copyright Profiles page where the new profile is added to the list of available copyright profiles.
  4. Specify the copyright notice to be generated. Do one of the following:
    • Type the desired plain text.
    • Define a Velocity template, then click the Validate button to check that the template has been specified correctly. Find the list of supported Velocity variables in the Copyright Profiles dialog box reference.
  5. In the Keyword to detect copyright in comments text box, type a character string to distinguish copyright notices from other comments during copyright update.

To create a copyright profile based on the settings of an existing profile

  1. Open the Settings dialog box, and then open the Copyright Profiles page below the Copyright node.
  2. Select the desired profile to inherit the settings from.
  3. Click the Copy button copyProfileButton on the toolbar.
  4. In the Create new copyright profile dialog box that opens specify the name of the new profile and click OK. You return to the Copyright Profiles page where the new profile is added to the list of available copyright profiles.
  5. View and edit the profile settings. Proceed as during creation of a profile from scratch.

To import an existing copyright notice text

  1. Open the Settings dialog box, and then open the Copyright Profiles page below the Copyright node.
  2. Click the Import button importFromXML on the toolbar.
  3. In the dialog that opens, choose the location of the .ipr file that refers to the copyright profile with the desired notice definition.
  4. From the Choose profile to import list, that appears, select the desired copyright profile.
  5. In the Create new copyright profile dialog box that opens specify the name of the new profile and click OK. You return to the Copyright Profiles page where the new profile is added to the list of available copyright profiles.
  6. Proceed as during creation of a profile from scratch.

To discard a copyright profile

  1. Open the Settings dialog box, and then open the Copyright Profiles page below the Copyright node.
  2. Select the profile you want to discard and click the Delete button delete on the toolbar.

Adding and updating copyright notices

To add a copyright notice

  1. Open the desired file in the editor.
  2. Press Alt+Insert.
  3. From the list that is displayed in the editor, choose Copyright.
  4. The following steps depend on the belonging of a file to a certain scope and the value of the Default project copyright field in the Copyright page.
    • If the file where you want to generate a copyright notice belongs to a certain scope, the copyright notice is generated according to the copyright profile settings.
    • If the field Default project copyright has the value No copyright and the file where you want to generate a copyright notice does not belong to any scope, IntelliJ IDEA prompts you to configure copyright settings:
      copyright

      Click OK to open the Copyright page and configure the desired settings.

Note that if a file belongs to several scopes, these scopes are checked upside down. So doing, the first scope with this file is declared the proper one, and its copyright profile is used.

To update a copyright notice

  1. In the Project tool window, select files or directories where you want the copyright notice to be updated or just open the desired file in the editor.
  2. Right-click the selection, and choose Update Copyright on the context menu.

    To have copyright notices updated correctly, make sure that the keyword specified in the copyright profile is a part of the notice definition. Otherwise, IntelliJ IDEA will not detect copyright notices and, instead of updating existing notices, will insert new ones.

See Also

Concepts:

Reference:

Web Resources:

Last modified: 14 July 2015