Create a copyright and licence header generator tool
As part of moving the documentation generator off of the website, we need a means of generating a copyright and licence header generator for committers.
The projects API provides metadata for Eclipse projects.
What I'd like is a command-line tool that takes a project ID as parameter, uses that project ID to query the API to get the licence information for the project, and writes a copyright header to standard out.
All projects have an ID. The Eclipse Dash project, for example, has technology.dash
for an ID. To query the API, we need to change dots (.) to underscores (_). We can get the Eclipse Dash project's metadata from the API as such:
$ curl --silent --get https://projects.eclipse.org/api/projects/technology_dash | json_pp
[
{
"committers" : [
...
],
...
"licenses" : [
{
"name" : "Eclipse Public License 2.0",
"short_name" : "EPL-2.0",
"url" : "http://www.eclipse.org/legal/epl-2.0"
}
],
...
}
]
A first pass implementation would generate a copyright and licence statement that looks something like this:
/********************************************************************************
* Copyright (c) {date} {owner}[ and others]
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* https://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
********************************************************************************/
We can make this more interesting by accepting parameters that fill in the template parts. For example:
$ header -project technology.dash --date==2025 --owner="Wayne Beaton" --andothers
/********************************************************************************
* Copyright (c) 2025 Wayne Beaton and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* https://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
********************************************************************************/
The programme and argument names are just suggestions.
The decoration around the header should be configurable.
We need to support the alternative copyright statement as well:
Copyright (c) {date} Contributors to the Eclipse Foundation
See the NOTICE file(s) distributed with this work for additional
information regarding copyright ownership.
There's more information in the handbook.
In cases where a project has multiple licences, we'll have to decide how to combine them.
- The basic option is to assume dual licensing and combine them using "or"
- In the case of the
EPL-2.0
being combined withGPL-2.0+
and variants, we might assume secondary licensing, but support (perhaps via arguments) forcing it to be dual licensing.
We can explore these concepts once we have a working prototype.
Note that when the licence is Apache-2.0
, we add the following under the licence notice:
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.
The implementation will be made open source under the Eclipse Dash project. Let's use this issue to discuss high-level requirements. When we're ready to start this work, we'll propose this to the Eclipse Dash project, and create a repository for the work. More detailed discussion should be held in a Eclipse Dash project repository's issue tracker.
Ideally, we should be able to extract a reusable library out of the implementation that we could use to, for example, create an extention or another application/script that applies the header to multiple files.