My favorites | Sign in
Project Logo
                
Search
for
Updated Nov 01, 2009 by mathieu.carbou
Labels: Featured
AdvancedHeaders  
Give an example of an additional header definition for .Net regions.

Introduction

This page will show you how you can define extended header definitions to feet your needs. The next example will define headers in a region area allowed in C# source files:

<?xml version="1.0" encoding="ISO-8859-1"?>
<additionalHeaders>
    <csregion_style>
        <firstLine>#region LicenseEOL/**</firstLine>
        <beforeEachLine> * </beforeEachLine>
        <endLine> */EOL#endregion</endLine>
        <firstLineDetectionPattern>#region.*^EOL/\*\*.*$</firstLineDetectionPattern>
        <lastLineDetectionPattern>\*/EOL#endregion"</lastLineDetectionPattern>
        <allowBlankLines>true</allowBlankLines>
        <isMultiline>true</isMultiline>
    </csregion_style>
</additionalHeaders>

You now have to add this new header definition file to the plugin configuration. It is done as the following in your pom:

<headerDefinitions>
   <headerDefinition>yourdefinition.xml</headerDefinition>
</headerDefinitions>

You now have to add the new mapping for *.cs files to use this new header definition. It is done as the following in your pom:

<mapping>
    <cs>CSREGION_STYLE</cs>
</mapping>

If you need more information on the pom configuration, just read the Configuration page.

And it should generate headers like:

#region License
/**
 * Copyright (C) 2008 http://code.google.com/p/maven-license-plugin/
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
#endregion

Comment by leedm777, Apr 02, 2009

I'd like to be able to define my own header definition that is a single line. Is there any way to configure a header to do that?

  // Copyright (c) ${year}, ${user}.  All Rights Reserved.
Comment by mathieu.carbou, Apr 16, 2009

Hi,

Yes probably. I do not have time to try now but perhaps dealing with an empty start line and end line would do the trick, otherwise by adding some delimiters like // --- before and after.

But i will keep this case to be sure it will be possible in the future 2.0 version

Comment by babasholaking, Jun 01, 2009

Hi, I had got my answer to this suggestion from you via email but when considering your next release. Please provide some form of exclusions so that you don't update already copywrighted years that are in the past.


Sign in to add a comment
Hosted by Google Code