You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@creadur.apache.org by Gavin <ga...@16degrees.com.au> on 2008/09/01 12:44:50 UTC

Auto adding license headers

Hi All,

I see that this has been addressed and committed (RAT-30), however I must be
doing something wrong as it does not work for me.

I only downloaded trunk today so bear with me, this is what I did after the
download of trunk.

ant build (did not work)
mvn install (aha now it does)
cd /project/to/test
java -jar /path/to/rat-core/target/rat-core-0.6-SNAPSHOT.jar -a .

The above does create filename.ext.new files but they are identical to the
old ones.

I have not come across any docs that tell me what else I should be doing, is
the AL license embedded or does it need to refer to an existing one
somewhere or ?

Thanks

Gav...


Re: Auto adding license headers

Posted by Craig L Russell <Cr...@Sun.COM>.
Hi,

All of my .java files have the Apache copyright as *the first lines*  
in the file.

I don't really understand why you would do anything except find out  
that there was no license and then insert the license at the top of  
the file (yes, even in front of the package statement).

Craig

On Sep 2, 2008, at 3:52 AM, Ross Gardler wrote:

> Gavin wrote:
>
> ...
>
>>>>> cd /project/to/test
>>>>> java -jar /path/to/rat-core/target/rat-core-0.6-SNAPSHOT.jar -a .
>>> That should all be rat-app , not app-core.
>>>
>>>>> The above does create filename.ext.new files but they are  
>>>>> identical to
>>>> the
>>>>> old ones.
>
> ...
>
>>>> Strange, the contribution does have tests with it [2]. The tests  
>>>> are run
>>>> on a "mvn install":
>>>>
>>>> Running org.apache.rat.annotation.TestLicenceAppender
>>>> Tests run: 8, Failures: 0, Errors: 0, Skipped: 0, Time elapsed:  
>>>> 0.047
>>> sec
>>>
>>> Yep I get all tests pass also.
>
> ...
>
>> Well, I now know what the problem is.
>> In the AbstractLicenseAppender.java file you have
>> if (type == TYPE_JAVA && line.startsWith("package "))
>> So, your looking to insert the License after the package line.
>> Your also assuming that all java files have a package line :)
>
> Well it conforms to *my* coding standards ;-)
>
> However, there are use cases where this would fail for genuine  
> reasons. For example some projects add version control keywords in  
> the first line.
>
>> So, what's the solution, 2 choices I see :-
>> 1. Do nothing (almost) - Document that a package line must exist  
>> and that
>> the license will be appended after that line. Therefore you are  
>> actively
>> forcing this limitation as an intentional design feature.
>> If this route is chosen then you should bail out without writing  
>> a .new file
>> if there is no package line, perhaps with a WARNING message  
>> appended to the
>> output. A .new file is currently written anyway because the file  
>> has already
>> been opened and written ("\n") to before that 'package' check above.
>> 2. If no package line exists then put the license in anyway at the  
>> very top.
>
> Option 2 is certainly easier and would catch cases like CVS  
> keywords. However, I'm guessing I put the check for a package name  
> in for good reason. I can't think why at this moment, but if it  
> wasn't just some random strangeness I probably put a test in place  
> for it.
>
> Please raise an issue complete with your suggestions (even providing  
> a patch if you feel the urge - start with option 2 and see what  
> happens to the tests).
>
> Ross

Craig L Russell
Architect, Sun Java Enterprise System http://java.sun.com/products/jdo
408 276-5638 mailto:Craig.Russell@sun.com
P.S. A good JDO? O, Gasp!


Re: Auto adding license headers

Posted by Ross Gardler <rg...@apache.org>.
Gavin wrote:

...

>>>> cd /project/to/test
>>>> java -jar /path/to/rat-core/target/rat-core-0.6-SNAPSHOT.jar -a .
>> That should all be rat-app , not app-core.
>>
>>>> The above does create filename.ext.new files but they are identical to
>>> the
>>>> old ones.

...

>>> Strange, the contribution does have tests with it [2]. The tests are run
>>> on a "mvn install":
>>>
>>> Running org.apache.rat.annotation.TestLicenceAppender
>>> Tests run: 8, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.047
>> sec
>>
>> Yep I get all tests pass also.

...

> Well, I now know what the problem is.
> 
> In the AbstractLicenseAppender.java file you have
> 
> if (type == TYPE_JAVA && line.startsWith("package "))
> 
> So, your looking to insert the License after the package line.
> Your also assuming that all java files have a package line :)

Well it conforms to *my* coding standards ;-)

However, there are use cases where this would fail for genuine reasons. 
For example some projects add version control keywords in the first line.

> So, what's the solution, 2 choices I see :-
> 
> 1. Do nothing (almost) - Document that a package line must exist and that
> the license will be appended after that line. Therefore you are actively
> forcing this limitation as an intentional design feature.
> 
> If this route is chosen then you should bail out without writing a .new file
> if there is no package line, perhaps with a WARNING message appended to the
> output. A .new file is currently written anyway because the file has already
> been opened and written ("\n") to before that 'package' check above.
> 
> 2. If no package line exists then put the license in anyway at the very top.

Option 2 is certainly easier and would catch cases like CVS keywords. 
However, I'm guessing I put the check for a package name in for good 
reason. I can't think why at this moment, but if it wasn't just some 
random strangeness I probably put a test in place for it.

Please raise an issue complete with your suggestions (even providing a 
patch if you feel the urge - start with option 2 and see what happens to 
the tests).

Ross

RE: Auto adding license headers

Posted by Gavin <ga...@16degrees.com.au>.

> -----Original Message-----
> From: Gavin [mailto:gavin@16degrees.com.au]
> Sent: Tuesday, 2 September 2008 11:28 AM
> To: rat-dev@incubator.apache.org
> Subject: RE: Auto adding license headers
> 
> 
> 
> > -----Original Message-----
> > From: Ross Gardler [mailto:rgardler@apache.org]
> > Sent: Tuesday, 2 September 2008 7:11 AM
> > To: rat-dev@incubator.apache.org
> > Subject: Re: Auto adding license headers
> >
> > Gavin wrote:
> > > Hi All,
> > >
> > > I see that this has been addressed and committed (RAT-30), however I
> > must be
> > > doing something wrong as it does not work for me.
> >
> > Not necessarily - it might be you are the first person to actually do it
> > other than me ;-)
> >
> > I often fall foul of the fact that I run things from within Eclipse
> > which manages the classpath for you and sometimes I forget to test in
> > the command line. Let me see now... (using command line only)...
> >
> > > I only downloaded trunk today so bear with me, this is what I did
> after
> > the
> > > download of trunk.
> > >
> > > ant build (did not work)
> >
> > Yep, seems there is no build.xml - docs need updating
> >
> > > mvn install (aha now it does)
> >
> > Good, that's a start then, didn't work for me like that. I tried:
> >
> > cd rat-trunk/rat
> > mvn installed
> >
> > This failed due to a missing dependency on rat-core, so I had to:
> >
> > cd rat-trunk/rat/rat-core
> > mvn install
> >
> > > cd /project/to/test
> > > java -jar /path/to/rat-core/target/rat-core-0.6-SNAPSHOT.jar -a .
> 
> That should all be rat-app , not app-core.
> 
> > >
> > > The above does create filename.ext.new files but they are identical to
> > the
> > > old ones.
> >
> > Strange, the contribution does have tests with it [2]. The tests are run
> > on a "mvn install":
> >
> > Running org.apache.rat.annotation.TestLicenceAppender
> > Tests run: 8, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.047
> sec
> 
> Yep I get all tests pass also.
> 
> >
> > I've also tested this on my own application here and can't reproduce the
> > problem.
> 
> Well, in case it was my environment or a Windows thing, I installed rat
> and
> my source files to convert on my Ubuntu box and I get exactly the same
> results, that is I get .new files which are just copies of the originals.

Well, I now know what the problem is.

In the AbstractLicenseAppender.java file you have

if (type == TYPE_JAVA && line.startsWith("package "))

So, your looking to insert the License after the package line.
Your also assuming that all java files have a package line :)

None of my java files have package lines, I haven't got that far yet.

So, what's the solution, 2 choices I see :-

1. Do nothing (almost) - Document that a package line must exist and that
the license will be appended after that line. Therefore you are actively
forcing this limitation as an intentional design feature.

If this route is chosen then you should bail out without writing a .new file
if there is no package line, perhaps with a WARNING message appended to the
output. A .new file is currently written anyway because the file has already
been opened and written ("\n") to before that 'package' check above.

2. If no package line exists then put the license in anyway at the very top.

or something else.

Either way, I now need to go make some package name and add them in to my
project, then I can use the License appender as is.

Gav...

> 
> >
> > What is the extension of the files you are hoping to relicence? The
> > appender does not work on every file type. Currently supported filetypes
> > are:
> >
> > .java
> > .xml
> > .html
> > .js
> > .apt
> > .properties
> 
> Currently just .java files, there are other files there too, but RAT
> correctly ignores those and only copies the .java files.
> 
> >
> > There is patch against issue Rat-30 that adds .rdf but it has not yet
> > been applied to head.
> >
> > > I have not come across any docs that tell me what else I should be
> > doing, is
> > > the AL license embedded or does it need to refer to an existing one
> > > somewhere or ?
> >
> > The licence header is in [1] so it does not need to be added or managed
> > by the user.
> 
> excellent.
> 
> >
> > I note that the rat website has broken links and old docs for the
> > rat-core module. I assume you are reading the docs from source otherwise
> > the above was a pretty good guess (or perhaps the help option is
> > actually helpful?).
> 
> looking at source and yes the help was most useful, if an option is missed
> then help automatically comes up which is good.
> 
> I also tried the full path to the directory as well as just '.' with no
> difference in output. Copying the jar to the directory also makes no
> difference, just saying some of the things I tried.
> 
> >
> > Anyway, docs are pretty sparse aren't they? You're going to add this
> > stuff to the docs, right? (note there is a patch attached to issue
> > Rat-30 that has some extra docs, but nothing more useful to you)
> 
> Yes, very sparse, but at this stage and for the audience I guess it is
> better for those working on the program to concentrate on getting it
> working. Does anything work with this program; I can't even get an audit
> report from it?
> 
> Add to the docs, sure, when I get something working (ugh maven generated
> docs), but I think I should try get something working first when I get
> time.
> 
> If anyone can help debug what's wrong with what I'm doing I'll document it
> also in return.
> 
> Gav...
> 
> >
> > Ross
> >
> > [1]
> > http://svn.apache.org/repos/asf/incubator/rat/main/trunk/rat/rat-
> >
> core/src/main/java/org/apache/rat/annotation/ApacheV2LicenceAppender.java
> > [2]
> > http://svn.apache.org/repos/asf/incubator/rat/main/trunk/rat/rat-
> > core/src/test/java/org/apache/rat/annotation/TestLicenceAppender.java
> >
> >
> 
> 
> --
> No virus found in this incoming message.
> Checked by AVG.
> Version: 7.5.524 / Virus Database: 270.6.14/1645 - Release Date: 9/1/2008
> 7:19 AM


RE: Auto adding license headers

Posted by Gavin <ga...@16degrees.com.au>.

> -----Original Message-----
> From: Ross Gardler [mailto:rgardler@apache.org]
> Sent: Tuesday, 2 September 2008 7:11 AM
> To: rat-dev@incubator.apache.org
> Subject: Re: Auto adding license headers
> 
> Gavin wrote:
> > Hi All,
> >
> > I see that this has been addressed and committed (RAT-30), however I
> must be
> > doing something wrong as it does not work for me.
> 
> Not necessarily - it might be you are the first person to actually do it
> other than me ;-)
> 
> I often fall foul of the fact that I run things from within Eclipse
> which manages the classpath for you and sometimes I forget to test in
> the command line. Let me see now... (using command line only)...
> 
> > I only downloaded trunk today so bear with me, this is what I did after
> the
> > download of trunk.
> >
> > ant build (did not work)
> 
> Yep, seems there is no build.xml - docs need updating
> 
> > mvn install (aha now it does)
> 
> Good, that's a start then, didn't work for me like that. I tried:
> 
> cd rat-trunk/rat
> mvn installed
> 
> This failed due to a missing dependency on rat-core, so I had to:
> 
> cd rat-trunk/rat/rat-core
> mvn install
> 
> > cd /project/to/test
> > java -jar /path/to/rat-core/target/rat-core-0.6-SNAPSHOT.jar -a .

That should all be rat-app , not app-core.

> >
> > The above does create filename.ext.new files but they are identical to
> the
> > old ones.
> 
> Strange, the contribution does have tests with it [2]. The tests are run
> on a "mvn install":
> 
> Running org.apache.rat.annotation.TestLicenceAppender
> Tests run: 8, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.047 sec

Yep I get all tests pass also.

> 
> I've also tested this on my own application here and can't reproduce the
> problem.

Well, in case it was my environment or a Windows thing, I installed rat and
my source files to convert on my Ubuntu box and I get exactly the same
results, that is I get .new files which are just copies of the originals.

> 
> What is the extension of the files you are hoping to relicence? The
> appender does not work on every file type. Currently supported filetypes
> are:
> 
> .java
> .xml
> .html
> .js
> .apt
> .properties

Currently just .java files, there are other files there too, but RAT
correctly ignores those and only copies the .java files.

> 
> There is patch against issue Rat-30 that adds .rdf but it has not yet
> been applied to head.
> 
> > I have not come across any docs that tell me what else I should be
> doing, is
> > the AL license embedded or does it need to refer to an existing one
> > somewhere or ?
> 
> The licence header is in [1] so it does not need to be added or managed
> by the user.

excellent.

> 
> I note that the rat website has broken links and old docs for the
> rat-core module. I assume you are reading the docs from source otherwise
> the above was a pretty good guess (or perhaps the help option is
> actually helpful?).

looking at source and yes the help was most useful, if an option is missed
then help automatically comes up which is good.

I also tried the full path to the directory as well as just '.' with no
difference in output. Copying the jar to the directory also makes no
difference, just saying some of the things I tried.

> 
> Anyway, docs are pretty sparse aren't they? You're going to add this
> stuff to the docs, right? (note there is a patch attached to issue
> Rat-30 that has some extra docs, but nothing more useful to you)

Yes, very sparse, but at this stage and for the audience I guess it is
better for those working on the program to concentrate on getting it
working. Does anything work with this program; I can't even get an audit
report from it?

Add to the docs, sure, when I get something working (ugh maven generated
docs), but I think I should try get something working first when I get time.

If anyone can help debug what's wrong with what I'm doing I'll document it
also in return.

Gav...

> 
> Ross
> 
> [1]
> http://svn.apache.org/repos/asf/incubator/rat/main/trunk/rat/rat-
> core/src/main/java/org/apache/rat/annotation/ApacheV2LicenceAppender.java
> [2]
> http://svn.apache.org/repos/asf/incubator/rat/main/trunk/rat/rat-
> core/src/test/java/org/apache/rat/annotation/TestLicenceAppender.java
> 
> 


Re: Auto adding license headers

Posted by Robert Burrell Donkin <ro...@blueyonder.co.uk>.
On Mon, 2008-09-01 at 22:10 +0100, Ross Gardler wrote:
> Gavin wrote:
> > Hi All,
> > 
> > I see that this has been addressed and committed (RAT-30), however I must be
> > doing something wrong as it does not work for me.
> 
> Not necessarily - it might be you are the first person to actually do it 
> other than me ;-)
> 
> I often fall foul of the fact that I run things from within Eclipse 
> which manages the classpath for you and sometimes I forget to test in 
> the command line. Let me see now... (using command line only)...
> 
> > I only downloaded trunk today so bear with me, this is what I did after the
> > download of trunk.
> > 
> > ant build (did not work)
> 
> Yep, seems there is no build.xml - docs need updating

yep

unless anyone wants to jump in with a patch, i'll try to take a look at
this sometime soon

<snip>

> > I have not come across any docs that tell me what else I should be doing, is
> > the AL license embedded or does it need to refer to an existing one
> > somewhere or ?
> 
> The licence header is in [1] so it does not need to be added or managed 
> by the user.
> 
> I note that the rat website has broken links and old docs for the 
> rat-core module. I assume you are reading the docs from source otherwise 
> the above was a pretty good guess (or perhaps the help option is 
> actually helpful?).

now there's some interest, i'd best take a look at sorting them out...

> Anyway, docs are pretty sparse aren't they? You're going to add this 
> stuff to the docs, right? (note there is a patch attached to issue 
> Rat-30 that has some extra docs, but nothing more useful to you)

i'll take a look at getting that patch applied soon

- robert



Re: Auto adding license headers

Posted by Ross Gardler <rg...@apache.org>.
Gavin wrote:
> Hi All,
> 
> I see that this has been addressed and committed (RAT-30), however I must be
> doing something wrong as it does not work for me.

Not necessarily - it might be you are the first person to actually do it 
other than me ;-)

I often fall foul of the fact that I run things from within Eclipse 
which manages the classpath for you and sometimes I forget to test in 
the command line. Let me see now... (using command line only)...

> I only downloaded trunk today so bear with me, this is what I did after the
> download of trunk.
> 
> ant build (did not work)

Yep, seems there is no build.xml - docs need updating

> mvn install (aha now it does)

Good, that's a start then, didn't work for me like that. I tried:

cd rat-trunk/rat
mvn installed

This failed due to a missing dependency on rat-core, so I had to:

cd rat-trunk/rat/rat-core
mvn install

> cd /project/to/test
> java -jar /path/to/rat-core/target/rat-core-0.6-SNAPSHOT.jar -a .
> 
> The above does create filename.ext.new files but they are identical to the
> old ones.

Strange, the contribution does have tests with it [2]. The tests are run 
on a "mvn install":

Running org.apache.rat.annotation.TestLicenceAppender
Tests run: 8, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.047 sec

I've also tested this on my own application here and can't reproduce the 
problem.

What is the extension of the files you are hoping to relicence? The 
appender does not work on every file type. Currently supported filetypes 
are:

.java
.xml
.html
.js
.apt
.properties

There is patch against issue Rat-30 that adds .rdf but it has not yet 
been applied to head.

> I have not come across any docs that tell me what else I should be doing, is
> the AL license embedded or does it need to refer to an existing one
> somewhere or ?

The licence header is in [1] so it does not need to be added or managed 
by the user.

I note that the rat website has broken links and old docs for the 
rat-core module. I assume you are reading the docs from source otherwise 
the above was a pretty good guess (or perhaps the help option is 
actually helpful?).

Anyway, docs are pretty sparse aren't they? You're going to add this 
stuff to the docs, right? (note there is a patch attached to issue 
Rat-30 that has some extra docs, but nothing more useful to you)

Ross

[1] 
http://svn.apache.org/repos/asf/incubator/rat/main/trunk/rat/rat-core/src/main/java/org/apache/rat/annotation/ApacheV2LicenceAppender.java
[2] 
http://svn.apache.org/repos/asf/incubator/rat/main/trunk/rat/rat-core/src/test/java/org/apache/rat/annotation/TestLicenceAppender.java