Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document and add copyright headers #756

Merged
merged 10 commits into from Feb 8, 2024

Conversation

Azquelt
Copy link
Contributor

@Azquelt Azquelt commented Feb 5, 2024

  • document the correct copyright header in CONTRIBUTING.adoc
  • add missing copyright headers in non-Java files

When reviewing, please particularly check that I haven't added a copyright header to something that shouldn't have one. The areas I wasn't sure about were:

  • the spec asciidoc files - it looks like we build the spec with an Apache license, except for when we do a final release when we use the EFSL, so guessed that the Apache license for the source files is correct.
  • the docs directory which builds https://jakartaee.github.io/cdi/
  • the .github directry
  • the files in ide-support and jboss_community_formatter.xml - I don't know how these were developed, they may have come form another project and probably started from the defaults of the the software that creates them?

I haven't changed any headers on existing files and I've used the format that includes the original author's name since some of the files pre-date involvement with the Eclipse Foundation.

Script used to generate headers

It's a bit rough, some files needed fixed up by hand, particularly XML ones since the <?xml line must be first if present.

#!/bin/bash

format_header () {
    local top=$1
    local prefix=$2
    local bottom=$3
    local owner=$4
    local year=$5

    commands=()
    if [[ -n "$top" ]]; then
        commands+=("-e" "1i ${top}")
    fi
    if [[ -n "$prefix" ]]; then
        commands+=("-e" "s%^%${prefix}%")
    fi
    if [[ -n "$bottom" ]]; then
        commands+=("-e" "\$a ${bottom}")
    fi

    sed "${commands[@]}" <<END
Copyright (c) ${year} ${owner} and others

This program and the accompanying materials are made available under the
Apache Software License 2.0 which is available at:
https://www.apache.org/licenses/LICENSE-2.0.

SPDX-License-Identifier: Apache-2.0
END
}

add_header() {
    echo "$1" | cat - "$2" > tmp.txt
    mv tmp.txt "$2"
}

missing_extensions=()

for F in $(grep -h ????? target/rat.txt | sed -e 's| !????? ||') ; do

    data=$(git log --format="%ae %as" $F | tail -1)

    if [[ $data =~ redhat || $data =~ starksm || $data =~ pmuir || $data =~ antoine || $data =~ marlow || $data =~ gegastaldi || $data =~ ladicek ]] ; then
        company="Red Hat, Inc."
    elif [[ $data =~ ibm ]] ; then
        company="IBM Corp."
    else
        echo "No known owner for $F, who is $data"
    fi

    year=$(echo $data | cut -d ' ' -f 2 | cut -d '-' -f 1)

    filename=$(basename "$F")
    extension="${filename##*.}"

    if [[ $extension == asciidoc || $extension == adoc ]] ; then
        header=$(format_header "////" "" "////" "$company" "$year")
    elif [[ $extension == xml || $extension == html || $extension == md ]] ; then
        header=$(format_header "<!--" "    " "-->" "$company" "$year")
    elif [[ $extension == yml || $extension == Gemfile || $extension == importorder ]] ; then
        header=$(format_header "" "# " "" "$company" "$year")
    elif [[ $extension == java || $extension == policy ]] ; then
        header=$(format_header "/*" " * " "\\ */" "$company" "$year")
    else
        header="Unknown format: $extension"
        missing_extensions+=("$extension")
    fi

    add_header "$header" "$F"
done

declare -A uniq_ext
for ext in "${missing_extensions[@]}"
do
    uniq_ext[$ext]=0
done

echo "missing extensions: " "${!uniq_ext[@]}"

Fixes #741

@Ladicek
Copy link
Contributor

Ladicek commented Feb 6, 2024

I think we really should get rid of api/src/ide (which contains jboss_community_formatter.xml). The ide-config module was added by @manovotn in #731 (copied from Weld, which coped it from Quarkus, where it was an original creation, albeit derived -- if not just copied -- from the default Eclipse format IIUC).

@manovotn
Copy link
Contributor

manovotn commented Feb 6, 2024

I think we really should get rid of api/src/ide (which contains jboss_community_formatter.xml). The ide-config module was added by @manovotn in #731 (copied from Weld, which coped it from Quarkus, where it was an original creation, albeit derived -- if not just copied -- from the default Eclipse format IIUC).

True, +1 for removing that; I didn't even know it's there, else I'd have removed that as part of the PR you linked :)

.github/dependabot.yml Outdated Show resolved Hide resolved
@Ladicek
Copy link
Contributor

Ladicek commented Feb 7, 2024

I was a bit unsure whether the policy format supports /* ... */ comments, because the documentation doesn't mention comments explicitly, it just shows // comments in some examples. However, the implementation of sun.security.provider.PolicyParser shows that both comment styles are supported, so I guess we should be fine.

Copy link
Contributor

@Emily-Jiang Emily-Jiang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Emily-Jiang Emily-Jiang merged commit 9911d9e into jakartaee:main Feb 8, 2024
4 of 5 checks passed
@Ladicek Ladicek added this to the CDI 4.1 milestone Feb 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add EF copyright and license to all files
4 participants