Ross Gardler wrote:
I have a very rough implementation of licence appending in RAT, that is,
you can optionally add licence headers to files that do not currently
have a recognised licence header and are not in the excludes list.
This proved so useful I've done some more work on it
The implementation is very limited (only able to ad Apache Software
Licence, only works on java files), but it is a starting point.
It is now handling many more file formats:
private static final int TYPE_JAVA = 1;
private static final int TYPE_XML = 2;
private static final int TYPE_HTML = 3;
private static final int TYPE_CSS = 4;
private static final int TYPE_JAVASCRIPT = 5;
private static final int TYPE_APT = 6;
private static final int TYPE_PROPERTIES = 7;
I've run this against a number of our projects and it seems to be
working very well (processed around 7000 files of various types so far).
Potential refactoring:
- make this a single pass process by adding a hooker into the analysis
thread. I didn't do it this way initially as I prefer a "get it working
then improve it approach" and besides, it seems wrong for an analysis
class to actually change the source files. It would seem this is a much
bigger refactoring.
Not done
- add an option to modify the java files themselves, i.e. don't create
"test.java.new". I think having the default set to create alternative
files is safer as this will allow for an additional sanity check before
actually modfiying the source
Done.
- make LicenceAppender an abstract class and provide other appender
implementations for other licences
Done.
- move the logic out of Report.main(args) and into LicenceAppender
(probably do that in a few minutes)
Not done, pending a decision on how to implement single pass processing.
One last question. What is the policy for code submissions with respect
to unit tests.
Anticipating the "right" answer of "all contributions must be
accompanied by tests", I've implemented basic tests.
Ross