Page tree
Skip to end of metadata
Go to start of metadata

There are many ways to provide a header in a file you are contributing to open source.  The following section provides a few file header examples that follow good practices for a variety of languages.  Following a good practice makes it easy for others, and tools that may be scanning your code, to quickly recognise how they should handle and behave with your code.

Apache licence header examples

Apache 2.0 is a common and popular license in open source projects.  You will likely come across it in your daily work with open source development, below are some examples of Apache code headers for popular languages.

C/C++/Java

/*******************************************************************************
 * Copyright (c) 2018 <Company or Individual> and others. 
 *
 * All rights reserved. This program and the accompanying materials 
 * are made available under the terms of the Apache License, Version 2.0 
 * which accompanies this distribution, and is available at 
 * http://www.apache.org/licenses/LICENSE-2.0
 *******************************************************************************/

Bash/Python

##############################################################################

# Copyright (c) 2018 <Company or Individual> and others.

#

# All rights reserved. This program and the accompanying materials

# are made available under the terms of the Apache License, Version 2.0

# which accompanies this distribution, and is available at

# http://www.apache.org/licenses/LICENSE-2.0

##############################################################################

XML

<!--

 Copyright (c) 2018 <Company or Individual> and others.


 All rights reserved. This program and the accompanying materials

 are made available under the terms of the Apache License, Version 2.0

 which accompanies this distribution, and is available at

 http://www.apache.org/licenses/LICENSE-2.0

-->

Creative Commons Attribution 4.0 International License

Creative Commons is a common method for working with documentation in open source projects.  The following is an example of a documentation header you may use in an RST file for instance that you will use for documentation.

Documentation

.. This work is licensed under a Creative Commons Attribution 4.0 International License.

.. http://creativecommons.org/licenses/by/4.0

.. (c) <optionally add copywriters name>


More License Header Example
Bash/Python, .properties, NGINX

#  ============LICENSE_START===============================================
#  Copyright (C) [years] Nordix Foundation. All rights reserved.
#  ========================================================================
#  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.
#  ============LICENSE_END=================================================


SQL

--  ============LICENSE_START===============================================
--  Copyright (C) [years] Nordix Foundation. All rights reserved.
--  ========================================================================
--  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.
--  ============LICENSE_END=================================================

Go-lang

// -
//   ========================LICENSE_START=================================
//   O-RAN-SC
//   %%
//   Copyright (C) [years] Nordix Foundation. All rights reserved.
//   %%
//   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.
//   ========================LICENSE_END===================================

Java

/*-
 * ========================LICENSE_START=================================
 * Copyright (C) [years] Nordix Foundation. All rights reserved.
 * ======================================================================
 * 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.
 * ========================LICENSE_END===================================
 */

XML

<!--
  ============LICENSE_START=======================================================
   Copyright (C) [years] Nordix Foundation. All rights reserved.
  ================================================================================
  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.
  ============LICENSE_END=========================================================
-->


TPL

{{/*
#  Copyright (C) [years] Nordix Foundation. All rights reserved.
#  ========================================================================
#  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.
#  ============LICENSE_END=================================================
*/}}
  • No labels