-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.xml
137 lines (116 loc) · 4 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
<!--
Ant simple sample project.
Kick start your java builds.
Find out more at http://www.bodkinconsulting.com
or http://java.net/projects/ant-simple-sample
Instructions:
Put this file in an empty directory and run the 'ant' command in that directory. The build file will create directories and make a very empty jar file in the same directory as the build.xml.
Create src/HW.java and put this code in it.
public class HW
{
public static void main(String [] args)
{
System.out.println("Hello World");
}
}
in the build file below change
<property name="main_class_name" value="changeme"/>
to
<property name="main_class_name" value="HW"/>
Run the ant command again, and now you can run your main class with the command
java -jar antsimple.jar
It should print:
Hellow World
and exit.
Add a junit.jar (from junit.org) into your ANT_HOME/lib directory and run 'ant test'
Create the file test/HWTest.java and add this code.
import junit.framework.*;
public class HWTest extends TestCase {
public void testTrue()
{
assertTrue(true);
}
}
-->
<project name="sztaki-als" default="dist" basedir=".">
<description>
Ant Simple Sample File
</description>
<!-- set global properties for this build -->
<property name="ant.project.name" value="antsimple"/>
<property name="main_class_name" value="changeme"/>
<property name="jarname" value="${ant.project.name}"/>
<!-- set directories -->
<property name="src" location="src"/>
<property name="test" location="test"/>
<property name="build" location="build"/>
<property name="dist" location="dist"/>
<property name="lib" location="lib"/>
<path id="project.classpath">
<pathelement location="${build}" />
<pathelement location="${lib}" />
<!-- <pathelement location="/home/gtakacs/tmp/ozone/dist/lib/*" /> -->
<fileset dir="../stratosphere/dist/lib">
<include name="*.jar" />
</fileset>
</path>
<target name="init">
<!-- Create the time stamp -->
<tstamp/>
<!-- Create directories if needed -->
<mkdir dir="${src}"/>
<mkdir dir="${test}"/>
<mkdir dir="${build}"/>
<mkdir dir="${dist}"/>
</target>
<target name="compile" depends="init" description="compile the source " >
<!-- Compile the java code from ${src} into ${build} -->
<javac debug="true"
srcdir="${src}"
destdir="${build}"
classpathref="project.classpath"/>
<!-- Copy files from ${src} into ${build} -->
<copy todir="${build}">
<fileset dir="${src}">
<exclude name="**/*.java"/>
</fileset>
</copy>
</target>
<!--
Broken???
-->
<target name="test" depends="compiletest" description="run the tests " >
<junit printsummary="yes" fork="yes" haltonfailure="yes">
<formatter type="plain"/>
<batchtest fork="true">
<fileset dir="${test}">
<include name="**/*Test*.java"/>
</fileset>
</batchtest>
<classpath refid="${project.classpath}" />
</junit>
</target>
<target name="compiletest" depends="compile"
description="compile the tests " >
<javac debug="true"
srcdir="${test}"
destdir="${build}"
classpathref="project.classpath" />
</target>
<target name="dist" depends="compile" description="generate the distribution" >
<!-- Create the distribution directory -->
<!-- Put everything in ${build} into the MyProject-${DSTAMP}.jar file -->
<jar jarfile="${dist}/${jarname}-${DSTAMP}.jar" basedir="${build}">
<manifest>
<attribute name="Main-Class"
value="${main_class_name}"/>
</manifest>
</jar>
<copy file="${dist}/${jarname}-${DSTAMP}.jar" tofile="./${jarname}.jar" overwrite="true"/>
</target>
<target name="clean"
description="clean up" >
<!-- Delete the ${build} directory-->
<delete dir="${build}"/>
</target>
</project>