forked from SmartBear/soapui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
copyrightInXSD.groovy
61 lines (48 loc) · 1.74 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
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"?>
<!--
~ soapUI, copyright (C) 2004-${currentYear} eviware.com
~
~ soapUI is free software; you can redistribute it and/or modify it under the
~ terms of version 2.1 of the GNU Lesser General Public License as published by
~ the Free Software Foundation.
~
~ soapUI 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 at gnu.org.
-->
"""
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}"}