-
Notifications
You must be signed in to change notification settings - Fork 0
/
copyrightInXSD.groovy
65 lines (52 loc) · 1.91 KB
/
copyrightInXSD.groovy
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
import static groovy.io.FileType.FILES
if(args.length !=2){
println "You need to pass two parameters. First one is path, and second one is file extension."
println "example of calling this script:"
println ">> copyrightInXML.groovy ./src/xsd/soapui .xsd"
System.exit(0)
}
def currentYear = new Date().getYear()+1900
def copyright = """<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright 2004-${currentYear} SmartBear Software
~
~ Licensed under the EUPL, Version 1.1 or - as soon as they will be approved by the European Commission - subsequent
~ versions of the EUPL (the "Licence");
~ You may not use this work except in compliance with the Licence.
~ You may obtain a copy of the Licence at:
~
~ http://ec.europa.eu/idabc/eupl
~
~ Unless required by applicable law or agreed to in writing, software distributed under the Licence is
~ distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
~ express or implied. See the Licence for the specific language governing permissions and limitations
~ under the Licence.
-->
"""
def updatedfiles=[]
def notUpdatedfiles=[]
new File(args[0]).eachFileRecurse(FILES){file->
if(file.absolutePath.contains(File.separator+".svn"+File.separator)) return
println file.absolutePath
if(file.isFile() && file.name.endsWith(args[1])){
def temp = copyright
def schemaPasssed = false
file.eachLine{ line->
if ( line =~'schema *' ){
schemaPasssed = true;
}
if(schemaPasssed){
temp += line + "\n"
}
}
if(schemaPasssed){
file.write(temp)
updatedfiles <<file.absolutePath
}
else{
notUpdatedfiles <<file.absolutePath
}
}
}
updatedfiles.each{ println " UPDATED: ${it}"}
notUpdatedfiles.each{ println "NOT UPDATED: ${it}"}