forked from strongback/strongback-java
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-common.xml
138 lines (124 loc) · 6.53 KB
/
build-common.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
<?xml version="1.0" encoding="ISO-8859-1"?>
<project name="build-common" default="test">
<property name="strongback.dir" location=".."/>
<property file="${strongback.dir}/build.properties"/>
<property name="wpilib.dir" value="${strongback.dir}/libs/wpilib"/>
<property name="ctre.dir" value="${strongback.dir}/libs/ctre"/>
<property name="navx.dir" value="${strongback.dir}/libs/navx-mxp"/>
<property name="java.compile.arg" value=""/>
<property name="java.source.version" value="1.8"/>
<property name="java.target.version" value="1.8"/>
<property name="project.build.dir" value="build"/>
<property name="project.source.dir" value="src"/>
<property name="project.resources.dir" value="resources"/>
<property name="project.output.dir" value="${project.build.dir}/classes"/>
<property name="project.test.source.dir" value="test"/>
<property name="project.test.resources.dir" value="testresources"/>
<property name="project.test.output.dir" value="${project.build.dir}/test-classes"/>
<property name="project.test.report.dir" value="${project.build.dir}/test-reports"/>
<property name="wpi.libs.dir" value="${wpilib.dir}/java/current/lib"/>
<property name="ctre.libs.dir" value="${ctre.dir}/java/lib"/>
<property name="navx.libs.dir" value="${navx.dir}/roborio/java/lib"/>
<property name="test.libs.dir" value="${strongback.dir}/libs/test"/>
<property name="compile.libs.dir" value="${strongback.dir}/libs"/>
<property name="project.jar.name" value="${ant.project.name}.jar"/>
<property name="project.source.jar.name" value="${ant.project.name}-sources.jar"/>
<property file="${strongback.dir}/build.properties"/>
<property file="${wpilib.dir}/wpilib.properties"/>
<!-- Define the classpaths -->
<path id="project.dependency.class.path">
</path>
<!-- Define the classpaths -->
<path id="compile.class.path">
<path refid="project.dependency.class.path"/>
<pathelement location="${project.output.dir}" />
<fileset dir="${compile.libs.dir}" includes="**/*.jar" excludes="**/*-sources.jar"/>
<fileset dir="${wpi.libs.dir}" includes="**/*.jar" excludes="**/*-sources.jar"/>
<fileset dir="${ctre.libs.dir}" includes="**/*.jar" excludes="**/*-sources.jar"/>
<fileset dir="${navx.libs.dir}" includes="**/*.jar" excludes="**/*-sources.jar"/>
</path>
<path id="test.class.path">
<path refid="compile.class.path"/>
<fileset dir="${test.libs.dir}" includes="**/*.jar" excludes="**/*-sources.jar"/>
</path>
<import file="dependencies.xml"/>
<target name="clean">
<delete dir="${project.build.dir}" />
</target>
<!-- Check if there are any JUnit Tests -->
<target name="if-tests">
<condition property="tests-exists">
<available file="${project.test.source.dir}" type="dir"/>
</condition>
</target>
<target name="compile" description="Compile the code">
<echo>Compiling against WPILib ${wpilib.version} installed at ${wpilib.dir}</echo>
<mkdir dir="${project.output.dir}"/>
<javac srcdir="${project.source.dir}"
destdir="${project.output.dir}"
source="${java.source.version}"
target="${java.target.version}"
debug="true"
includeantruntime="false">
<classpath refid="compile.class.path" />
<!--compilerarg value="${java.compile.arg}"/-->
</javac>
<copy todir="${project.output.dir}">
<fileset dir="${project.source.dir}" includes="**/*.xml,**/*.properties,**/*.txt,**/*.ico" />
</copy>
<copy todir="${project.output.dir}" failonerror="false">
<fileset dir="${project.resources.dir}"/>
</copy>
</target>
<target name="compile-tests" depends="compile, if-tests" if="tests-exists" description="Compile the unit tests">
<echo>Compiling against WPILib ${wpilib.version} installed at ${wpilib.dir}</echo>
<mkdir dir="${project.test.output.dir}"/>
<javac srcdir="${project.test.source.dir}"
destdir="${project.test.output.dir}"
source="${java.source.version}"
target="${java.target.version}"
debug="true"
includeantruntime="false">
<classpath refid="test.class.path" />
<classpath>
<pathelement location="${project.test.output.dir}"/>
</classpath>
<!--compilerarg value="${java.compile.arg}"/-->
</javac>
<copy todir="${project.test.output.dir}">
<fileset dir="${project.test.source.dir}" includes="**/*.xml,**/*.properties,**/*.txt,**/*.ico" />
</copy>
<copy todir="${project.output.dir}" failonerror="false">
<fileset dir="${project.test.resources.dir}"/>
</copy>
</target>
<!-- Run the JUnit Tests that are in the 'test' directory of this project -->
<target name="test" depends="compile-tests, if-tests" if="tests-exists" description="Run the unit tests">
<echo>Testing with WPILib ${wpilib.version} installed at ${wpilib.dir}</echo>
<!-- Creates the directories used in the tests -->
<mkdir dir="${project.test.output.dir}" />
<mkdir dir="${project.test.report.dir}" />
<junit printsummary="off" showOutput="false" fork="false" haltonfailure="no" failureproperty="test.failed" >
<classpath refid="test.class.path" />
<classpath>
<pathelement location="${project.test.output.dir}"/>
</classpath>
<formatter type="plain" usefile="false" /> <!-- to screen -->
<batchtest todir="${project.test.report.dir}">
<fileset dir="${project.test.source.dir}">
<include name="**/*Test*.java" />
</fileset>
</batchtest>
</junit>
<fail message="Test failure detected, check test results." if="test.failed" />
</target>
<!-- Override the several targets that will need to use the extra library JARs. -->
<target name="jar" depends="compile, test" description="Build and collect the JARs necessary for the robot">
<mkdir dir="${project.build.dir}" />
<jar destfile="${project.build.dir}/${project.jar.name}" basedir="${project.output.dir}"/>
<jar destfile="${project.build.dir}/${project.source.jar.name}" basedir="${project.source.dir}"/>
</target>
<target name="dist.dependencies">
<antcall target="depend.${ant.project.name}"/>
</target>
</project>