-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathremove-lgpl-header.xml
80 lines (67 loc) · 2.72 KB
/
remove-lgpl-header.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?xml version="1.0" encoding="UTF-8"?>
<project default="removeLicenseToAll" basedir="." name="RemoveLicense">
<description>Remove license header</description>
<taskdef resource="net/sf/antcontrib/antlib.xml"/>
<property name="src" location="."/>
<scriptdef name="removeLicenseIfNecessary" language="javascript">
<attribute name="property" />
<attribute name="text" />
<attribute name="license" />
<attribute name="file" />
<![CDATA[
var text = attributes.get("text");
var license = attributes.get("license").trim();
var file = attributes.get("file");
var start=text.indexOf(license);
var end=start+license.length();
if(start!=-1) {
// search for end
var iTag=text.indexOf('--->',end);
var iScript=text.indexOf('*/\n',end);
if(iTag!=-1 || iScript!=-1) {
// find both
var isScript=(iTag!=-1 && iScript!=-1 && iTag>iScript) || (iScript!=-1);
if(isScript) text=text.substring(iScript+3);
else text=text.substring(iTag+4);
}
}
project.setProperty(attributes.get("property"), text);
]]>
</scriptdef>
<property name="license">
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
</property>
<target name="init" description="">
</target>
<target name="removeLicense" description="generate the distribution">
<loadfile property="content" srcFile="${file}"/>
<echo message="----- ${file} -----"/>
<removeLicenseIfNecessary file="${file}" property="content" text="${content}" license="${license}"/>
<echo message="${content}" file="${file}"/>
<!-- -->
</target>
<target name="removeLicenseToAll" description="generate the distribution" depends="init">
<foreach target="removeLicense" param="file">
<path>
<fileset dir="${src}" casesensitive="yes">
<include name="**/*.java"/>
<include name="**/*.cfs"/>
<include name="**/*.cfm"/>
<include name="**/*.cfml"/>
<include name="**/*.cfc"/>
</fileset>
</path>
</foreach>
</target>
</project>