Copyright
Your project may contain files that you want to protect by copyright. Instead of inserting a copyright notice in each file separately, you can use copyright profiles.
A profile defines copyright notice text and a set of files (a scope) in which this text will be incorporated.
You may need several different copyright notices for files within the same project. In this case, you can configure several profiles and associate them with different scopes.
Configure a new copyright profile
Press Ctrl+Alt+S to open IDE settings and select Editor | Copyright | Copyright Profiles.
To configure the default profile for all newly created projects, select
.Click and name the new profile.
Enter copyright notice text.
You can enter plain text, or configure a Velocity template. For the template, use variables, and click Validate to make sure that it is configured correctly.
Assign a profile to a scope of files
Press Ctrl+Alt+S to open IDE settings and select Editor | Copyright.
Click Alt+Insert, and select an existing shared scope from the list.
You can define a new scope if necessary. Click the Select Scopes to add scopes or modify existing ones link in the lower part of the page.
From the Copyright list, select the profile that you want to link with the scope.
Apply the changes and close the dialog.
Configure the copyright text format
By default, the IDE pastes a block comment before other comments with a prefix in each line and adds a blank line after the block.
You can change the default format in the settings:
Press Ctrl+Alt+S to open IDE settings and select Editor | Copyright | Formatting.
On this page, you can configure the formatting for all types of files. If you want to change the formatting for a specific file type, select it under the Formatting node.
Configure the formatting options. Use the preview section to make sure that the new formatting looks as intended.
Insert copyright text into files
To insert the text into a single file, open it in the editor, press Alt+Insert, and select Copyright from the popup.
To insert the text into a group of files, right-click a node in the Project tool window, and select Update Copyright. You will be prompted to select in which scope you want to update the notice.
A node may include files that belong to different scopes. In this case, copyright notices will be generated according to the assigned profiles.
If a node contains a file that doesn't belong to any scope, the IDE will assign the default profile to it.
Update copyright text
Press Ctrl+Alt+S to open IDE settings and select Editor | Copyright | Copyright Profiles.
Select the necessary profile and edit the copyright text.
In the Regex to detect copyright in comments field, specify a regular expression that will be used to find existing copyright notices in files.
The IDE will use this expression to identify the copyright comment among other comments. For example, such comments normally contain the word
Copyright
.In the Allow replacing copyright if old copyright matches field, specify a regular expression that the IDE will use to search for the files in which copyright text should be updated.
For example, if you want to update the copyright text in all files that contain years 2000-2006 and 2010-2016 in their copyright, specify
20[0-1][0-6]
.Apply the changes and close the dialog.
In the Project tool window, right-click the node for which you want to update the text, and select Update Copyright.
Set the default copyright profile
The settings of the default profile will be applied to files that are not explicitly included in any scope covered by a profile.
Press Ctrl+Alt+S to open IDE settings and select Editor | Copyright.
From the Default project copyright list, select the profile you want to use as the default profile.