-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
124 lines (105 loc) · 3.26 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
119
120
121
122
123
124
<project name="Lab3" default="compile" basedir="." xmlns:ac="antlib:net.sf.antcontrib">
<taskdef resource="net/sf/antcontrib/antlib.xml" uri="antlib:net.sf.antcontrib">
<classpath>
<fileset dir="./lib/ant-contrib"/>
</classpath>
</taskdef>
<scriptdef name="compare" language="javascript">
<attribute name="lhs" />
<attribute name="rhs" />
<attribute name="property" />
<![CDATA[
var lhs = attributes.get("lhs");
var rhs = attributes.get("rhs");
project.setProperty(attributes.get("property"), lhs.indexOf(rhs) > -1);
]]>
</scriptdef>
<loadproperties srcFile="config/build.properties"/>
<property name="build.number" value="${build.major.number}.${build.minor.number}.${build.revision.number}"/>
<!-- TASK 1 -->
<target name="compile">
<mkdir dir="${classes}"/>
<javac srcdir="${src}" destdir="${classes}" includeAntRuntime="false">
<classpath location="lib/junit-4.12.jar"/>
<classpath location="lib/hamcrest-core-1.3.jar"/>
</javac>
</target>
<!-- TASK 3 -->
<target name="clean">
<delete dir="${build}"/>
</target>
<!-- TASK 2 -->
<target name="build" depends="compile">
<jar destfile="${buildjar}/Lab3.jar" >
<fileset dir="build/classes/" includes="*.class"/>
<fileset dir="local/" includes="*.properties"/>
<fileset dir="image/" includes="*.png*"/>
<manifest>
<attribute name="Main-Class" value="Lab3"/>
</manifest>
</jar>
</target>
<!-- TASK 4 -->
<target name="test" depends="compile" >
<junit fork="yes">
<classpath>
<pathelement location="${classes}"/>
<pathelement location="lib/junit-4.12.jar" />
<pathelement location="lib/hamcrest-core-1.3.jar" />
</classpath>
<formatter type="plain" usefile="false" />
<test name = "TestT"/>
</junit>
</target>
<!-- TASK 5 -->
<target name="native2ascii">
<native2ascii encoding="utf-8" src="local/native" dest="local-copy/native"/>
</target>
<!-- TASK 6 -->
<target name="diff">
<exec executable="git" outputproperty="git_diff_result">
<arg value="ls-files"/> <arg value="-m"/>
</exec>
<echo file="log/kostil.txt" message="${git_diff_result}" append="false">
</echo>
<loadfile property="fileKostil" srcfile="log/kostil.txt"/>
<ac:for list="${difflist}" param="file">
<sequential>
<echo message="Looking whether @{file} has changed"/>
<ac:for param="line" list="${fileKostil}" delimiter="${line.separator}">
<sequential>
<compare lhs="@{line}" rhs="@{file}" property="result"/>
<ac:if>
<equals arg1="${result}" arg2="true" />
<ac:then>
<echo message="@{line}"/>
<echo message="@{file}"/>
<property name="n" value="false" />
</ac:then>
</ac:if>
</sequential>
</ac:for>
</sequential>
</ac:for>
<ac:if>
<equals arg1="${n}" arg2="false" />
<ac:then>
<fail message="Files are not changed."/>
</ac:then>
<ac:else>
<antcall target="diffcommit" />
</ac:else>
</ac:if>
</target>
<target name="diffcommit">
<echo>Commiting...</echo>
<exec executable="git">
<arg value="add"/>
<arg value="." />
</exec>
<exec executable="git">
<arg value="commit"/>
<arg value="-m 'ant diff auto commit on version ${build.number}'"/>
</exec>
</target>
</project>