-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
152 lines (138 loc) · 5.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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
<?xml version="1.0" encoding="UTF-8"?>
<project name="lab3" default="build">
<property file="build.properties"/>
<path id="classpath">
<fileset dir="${lib.dir}" includes="*.jar"/>
<fileset dir="${main.dir}" includes="*.java"/>
</path>
<path id="classpath.test">
<pathelement location="${junit}"/>
<pathelement location="${hamcrest}"/>
<pathelement location="${classes.dir}"/>
</path>
<taskdef resource="net/sf/antcontrib/antcontrib.properties">
<classpath>
<pathelement location="${contrib}"/>
</classpath>
</taskdef>
<taskdef resource="net/sf/antcontrib/antlib.xml">
<classpath>
<pathelement location="${contrib}"/>
</classpath>
</taskdef>
<target name="compile" depends="clean">
<echo message="***** COMPILE STARTED *****"/>
<mkdir dir="${classes.dir}"/>
<mkdir dir="${test.classes.dir}"/>
<javac srcdir="${src.dir}" destdir="${classes.dir}" classpathref="classpath" includeantruntime="false"/>
<echo message="***** COMPILE COMPLETED *****"/>
</target>
<target name="build" depends="compile">
<echo message="***** BUILD STARTED *****"/>
<copy todir="${build.dir}">
<fileset dir="${web.dir}"/>
</copy>
<copy todir="${build.dir.lib}">
<fileset dir="${lib.dir}"/>
</copy>
<copy todir="${classes.dir}">
<fileset dir="${resources.dir}"/>
</copy>
<jar destfile="${build.dir}/${ant.project.name}.jar">
<fileset dir="${classes.dir}"/>
<manifest>
<attribute name="Created-By" value="nyapsilon"/>
<attribute name="Manifest-Version" value="1.0"/>
<attribute name="Main-Class" value="NoClass"/>
</manifest>
</jar>
<war destfile="${build.dir}/${ant.project.name}.war" webxml="${build.web.xml}">
<fileset dir="${build.dir}"/>
<manifest>
<attribute name="Created-By" value="nyapsilon"/>
<attribute name="Manifest-Version" value="1.0"/>
<attribute name="Main-Class" value="NoClass"/>
</manifest>
</war>
<echo message="***** BUILD COMPLETED *****"/>
</target>
<target name="clean">
<echo message="***** CLEAN STARTED *****"/>
<delete dir="${build.dir}"/>
<delete dir="${junit.report.dir}"/>
<echo message="***** CLEAN COMPLETED *****"/>
</target>
<target name="test" depends="build">
<echo message="***** TEST STARTED *****"/>
<mkdir dir="${test.classes.dir}"/>
<mkdir dir="${junit.report.dir}"/>
<javac destdir="${test.classes.dir}" srcdir="${test.dir}" includeantruntime="false" encoding="utf-8">
<classpath refid="classpath.test"/>
</javac>
<junit printsummary="on" haltonfailure="true" haltonerror="true">
<classpath>
<path refid="classpath.test"/>
<pathelement location="${test.classes.dir}"/>
</classpath>
<batchtest fork="yes" todir="${junit.report.dir}">
<formatter type="plain"/>
<fileset dir="${test.dir}" includes="*Test.java"/>
</batchtest>
</junit>
<echo message="***** TEST COMPLETED *****"/>
</target>
<target name="native2ascii">
<echo message="***** NATIVE2ASCII STARTED *****"/>
<delete dir="${native2ascii.resources}"/>
<native2ascii src="${resources.dir}"
dest="${native2ascii.resources}"
includes="**/*.properties"/>
<echo message="***** NATIVE2ASCII COMPLETED *****"/>
</target>
<target name="diff" >
<echo message="***** DIFF STARTED *****"/>
<loadfile property="params" srcFile="params.props"/>
<exec executable="git" outputproperty="differences">
<arg value="diff"/>
<arg value="--name-only"/>
</exec>
<property name="commit.flag" value="false"/>
<script language="javascript">
var diffs = project.getProperty("differences").split("\n");
var params = project.getProperty("params").split("\n");
var echo = project.createTask("echo");
var flag = false;
for (var i=0; i<params.length; i++) {
for (var j=0; j<diffs.length; j++) {
if (params[i] === diffs[j]) {
echo.setMessage("*** CHANGED FILE FOUND: " + params[i] + " ***");
echo.perform();
project.setProperty("commit.flag", "true");
flag = true;
break;
}
}
if (flag) break;
}
</script>
<if>
<equals arg1="${commit.flag}" arg2="true"/>
<then>
<echo message="*** FILES FROM PARAMS CHANGED, COMMITING... ***"/>
<exec executable="git">
<arg value="add"/>
<arg value="*"/>
</exec>
<exec executable="git">
<arg value="commit"/>
<arg value="-m"/>
<arg value="feat: :sparkles: some shit added (auto-commit)"/>
</exec>
</then>
<else>
<echo message="*** FILES FROM PARAMS NOT CHANGED ***"/>
</else>
</if>
<echo message="***** DIFF COMPLETED *****"/>
</target>
</project>