Over a million developers have joined DZone.

Copyright Notices and Year Stamps are Always Up-to-Date


Suppose your project contains files to be supplied with the different copyright notices. Most likely, the copyright policy of your company requires that these notices should be kept up-to-date. Your next step? Edit copyright notice in each file manually? This is where IntelliJ IDEA 8.1 comes to help with its Copyright plugin.

This plugin comes bundled with the product and lets you insert and update copyright notices automatically or semi-automatically.

Moreover, due to the use of Velocity templates, the timestamp will be automatically refreshed every time you apply the plugin.

Now, how will you actually update copyright notices? Depending on your copyright policy, you may need to do it either during commit or in the batch mode.

When you check in your changes to version control, make sure that the option Update Copyright in the Commit Changes dialog is selected:


















If you want to update copyright notices in batch mode in a whole directory, select this directory in the Project view, and then choose Update Copyright on its context menu:












In either case, IntelliJ IDEA 8.1 detects the scope each file belongs to and inserts or updates the copyright notice text according to the corresponding Copyright profile definition. Profiles are associated with scopes in the Copyright page of the Settings dialog box:













The plugin also helps you keep the time stamps in copyright notices up-to-date by using templates with the Velocity variables, instead of explicitly specified year, month, day, etc. The time stamp will be re-generated every time you update the copyright notice.

For example, to keep the current year, use the following template:

Copyright (c) $today.year, Foo Corporation. All Rights Reserved.

By default, a copyright notice is inserted as a block comment in the header, above other comments but you can change these settings to meet the requirements of your copyright policy.

Needless to say, that the Copyright plugin works for all file formats supported by IntelliJIDEA.




The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}