-
Notifications
You must be signed in to change notification settings - Fork 57
/
build.xml
118 lines (104 loc) · 4.41 KB
/
build.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<?xml version="1.0" encoding="UTF-8"?>
<project default="build" name="canonical-latinLit">
<xmlproperty file="expath-pkg.xml"/>
<property name="project.version" value="${package(version)}"/>
<property name="project.app" value="canonical-latinLit"/>
<property name="build.dir" value="build"/>
<property name="copy.dir" value="pre-build"/>
<property name="data.dir" value="data"/>
<property name="root.dir" value="."/>
<property name="data.required" value="__cts__.xml"/>
<condition property="fileSep" value="\">
<os family="windows" />
</condition>
<condition property="fileSep" value="/">
<os family="unix" />
</condition>
<condition property="fileSepTest" value="\\">
<os family="windows" />
</condition>
<condition property="fileSepTest" value="/">
<os family="unix" />
</condition>
<target name="copy">
<copy todir="${copy.dir}" verbose="true">
<fileset dir="${root.dir}">
<include name="*"/>
</fileset>
</copy>
</target>
<target name="include" depends="copy">
<!-- Remove files if they are not neighbour of required ${data.checkfile} -->
<script language="javascript"> <![CDATA[
var getInclude = function(list) {
var o = {};
var fileSep = self.getProject().getProperty("fileSep");
var fileSepTest = self.getProject().getProperty("fileSepTest")
for (i=0; i<list.length; i++) {
var f = list[i];
if(f.indexOf(inc_file) > 0) {
var folder = f.split(fileSepTest).slice(0,-1).join(fileSep);;
o[folder] = f;
}
}
return o;
}
importClass(java.io.File);
importClass(java.io.FileReader);
importClass(java.io.BufferedReader);
importClass(org.apache.tools.ant.filters.TokenFilter);
importClass(org.apache.tools.ant.util.FileUtils);
Validator = new TokenFilter.ContainsString();
Validator.setContains("cRefPattern");
Reader = function(file) {
return FileUtils.readFully(new FileReader(file));
}
// Access to Ant-Properties by their names
data_dir = project.getProperty("data.dir"); // The directory where you want to check for subdirectory including X
copy_dir = project.getProperty("copy.dir"); // The directory where you want to check for subdirectory including X
inc_file = project.getProperty("data.required"); // The file which says if a folder should be copie
// Create a <fileset dir="" includes=""/> to retrieve everything from this folder
fs = project.createDataType("fileset");
fs.setDir( new File(data_dir) );
fs.setIncludes("**");
ds = fs.getDirectoryScanner(project); // Get the files (array) of that fileset
files = ds.getIncludedFiles(); // Get only the files
//Create destination and sourceDir File instances
basedir = new File(".");
destination = new File(basedir, [copy_dir, data_dir].join(fileSep));
source = new File(basedir, data_dir);
//We create an object where key are folder containing said inc_file
exist = getInclude(files);
includes = [];
for (i=0; i<files.length; i++) {
filename = files[i];
folder = filename.split(fileSepTest).slice(0,-1).join(fileSep);
if(exist[folder]) {
f = new File(source, filename);
ff = filename.split(fileSepTest).slice(-1)[0];
if(ff == "__cts__.xml" || Validator.filter(Reader(f))) {
copy = project.createTask("copy");
copy.setTofile(new File(destination, filename));
copy.setFile(f);
copy.perform();
} else {
self.log(ff + " is not a valid file.")
}
}
}
]]>
</script>
</target>
<target name="delete-pre-build">
<delete dir="${copy.dir}" />
</target>
<target name="xar" depends="copy">
<mkdir dir="${build.dir}"/>
<zip
basedir="${copy.dir}"
destfile="${build.dir}/${project.app}-${project.version}.xar"
excludes="${build.dir}/*"
/>
</target>
<target name="build" depends="include, xar, delete-pre-build"/>
</project>