Thanks - I did something similar - although now it turns out the "wrong order" with 'package' on top (that was easier with sed)
cd incubator-taverna-plugin-bioinformatics/ git status git checkout master git pull # files that probably are OK grep -r "Licensed to the Apache Software" . | cut -d : -f 1 > OK # Find Java files - naive grep -r ^package . | grep src | cut -d ":" -f 1 | grep java$ > CHECK # Find the differences grep -v -f OK CHECK > MISSING # Check there are not any nonsense here head MISSING | less # Check the current file headers xargs -a MISSING head | less # Remove /***** sillyness cat MISSING | xargs sed -i '\,^.\*\*\*\*\*\*.*, d' git diff git commit -m "Removed /*** comments" tav* git status Now let's add the header. I put the /* .. */ text in a file LICENSE-header.txt vi LICENSE-header.txt /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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. */ cat MISSING | xargs sed -i '/^package/ r LICENSE-header.txt' git diff git commit -m "Added ASF license header" taverna-* git push # Tidy rm CHECK LICENSE-header.txt MISSING OK git status But sadly this means the comment was added below the 'package' line.. Sorry about that. On 7 September 2016 at 14:15, Andy Seaborne <[email protected]> wrote: > PS > > /** > License > */ > > then > > package org.apache.taverna ... ; > > is the usual way - not package then license comment. > > Andy > > > On 07/09/16 14:08, Andy Seaborne wrote: >> >> >> >> On 07/09/16 12:04, Stian Soiland-Reyes wrote: >>> >>> It should - if the script or maven plugin is able to cleanly remove >>> the old header. >> >> >> I use perl: >> >> undef $/ ; >> s!/.*?\npackage!\npackage!s ; >> >> i.e. remove everything up until the "package" on the start of a line. >> >> This avoids having to match different layouts. >> >> Andy >> >> #!/usr/bin/perl >> # find . -name \*.java | xargs -n 1 perl -i.bak SCRIPT >> >> undef $/ ; >> >> $_ = <> ; >> >> # Remove initial comments. >> >> s!/.*?\npackage!\npackage!s ; >> >> # print LICENSE >> >> $HEADER=<<'EOF'; >> /* >> Your license goes here. >> */ >> EOF >> >> print $HEADER ; >> print $_ ; -- Stian Soiland-Reyes http://orcid.org/0000-0001-9842-9718
