aschearer / shade

A 2d game written in Java with real time lighting as a central gameplay mechanic.

This URL has Read+Write access

shade / build.xml
100644 181 lines (160 sloc) 6.895 kb
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
<?xml version="1.0" ?>
 
<!--
 
Shade build file.
 
ant setup Initialize Shade environment.
ant compile Run to compile the code.
ant run Run to launch Shade
ant webstart Deploy shade as a webstart.
ant clean Removes products of the build process, etc.
 
Alex Schearer
-->
<project name="Shade" default="compile">
 
    <property name="src.dir" value="src" />
    <property name="res.dir" value="res" />
    <property name="lib.dir" value="lib" />
    <property name="obj.dir" value="bin" />
    <property name="target.dir" value="." />
    <property name="script.dir" value="script" />
    <property name="webstart.dir" value="${target.dir}/webstart" />
 
    <!-- Set up the Shade environment including preparing the natives. -->
    <target name="setup" depends="check-setup" unless="setup.exists">
        <delete dir="${lib.dir}/natives" />
        <mkdir dir="${lib.dir}/natives" />
        <unzip src="${lib.dir}/natives-win32.jar" dest="${lib.dir}/natives" />
        <unzip src="${lib.dir}/natives-mac.jar" dest="${lib.dir}/natives" />
        <unzip src="${lib.dir}/natives-linux.jar" dest="${lib.dir}/natives" />
    </target>
 
    <!-- Compile and archive Shade. -->
    <target name="jar">
        <antcall target="compile" />
        <antcall target="archive" />
    </target>
 
    <!-- Run Shade. -->
    <target name="run" depends="setup,compile">
        <java fork="true" classname="com.shade.Shade">
            <classpath>
                <pathelement path="${obj.dir}" />
                <fileset dir="${lib.dir}">
                    <include name="**/*.jar" />
                </fileset>
            </classpath>
            <jvmarg value="-Djava.library.path=lib/natives" />
        </java>
    </target>
 
    <!-- Clean up the environment. -->
    <target name="clean">
        <delete includeEmptyDirs="true">
            <fileset dir="${obj.dir}" includes="**/*" defaultExcludes="no" />
        </delete>
        <delete file="${target.dir}/shade.jar" />
        <delete>
            <fileset dir="${src.dir}" includes="**/*.orig" />
        </delete>
        <delete>
            <fileset dir="." defaultExcludes="no">
                <include name="**/*.DS_Store"/>
            </fileset>
        </delete>
        <delete dir="${webstart.dir}" />
    </target>
 
    <target name="format">
        <exec executable="${script.dir}/astyle">
            <arg value="-p" />
            <arg value="-r" />
            <arg value="-c" />
            <arg value="--style=java" />
            <arg value="${src.dir}/*" />
        </exec>
    </target>
 
    <!-- Create a webstart directory in order to deploy Shade. -->
    <target name="webstart" depends="jar">
        <input message="Web server url:" addproperty="codebase" />
        <delete dir="${webstart.dir}" />
        <mkdir dir="${webstart.dir}" />
        <copy file="${script.dir}/htaccess" tofile="${webstart.dir}/.htaccess" />
        <copy file="${target.dir}/shade.jar" tofile="${webstart.dir}/shade.jar" />
        <copy file="${target.dir}/lib/crash.jar" tofile="${webstart.dir}/crash.jar" />
        <copy file="${target.dir}/lib/slickfx.jar" tofile="${webstart.dir}/slickfx.jar" />
        <copy file="${target.dir}/lib/BareBonesBrowserLaunch.jar" tofile="${webstart.dir}/BareBonesBrowserLaunch.jar" />
        <copy file="${script.dir}/template.jnlp" tofile="${webstart.dir}/shade.jnlp">
            <filterchain>
                <replacetokens>
                    <token key="codebase" value="${codebase}" />
                </replacetokens>
            </filterchain>
        </copy>
        <antcall target="signjar" />
    </target>
 
    <!-- Determines whether setup has been run. -->
    <target name="check-setup">
        <condition property="setup.exists">
            <available file="${lib.dir}/natives" type="dir" />
        </condition>
    </target>
 
 
    <!-- Determines whether a keystore exists. -->
    <target name="check-keystore">
        <input message="Username:" addproperty="keystore.alias" />
        <input message="Password:" addproperty="keystore.pass" />
        <condition property="keystore.exists">
            <available file="${target.dir}/${keystore.alias}.ks" type="file" />
        </condition>
    </target>
 
    <!-- Create a key store. -->
    <target name="keystore" depends="check-keystore" unless="keystore.exists">
        <input message="Full Name:" addproperty="keystore.name" />
        <input message="Company:" addproperty="keystore.company" />
 
        <genkey keystore="${target.dir}/${keystore.alias}.ks"
                alias="${keystore.alias}"
                storepass="${keystore.pass}">
            <dname>
                <param name="CN" value="${keystore.name}" />
                <param name="OU" value="${keystore.company}" />
                <param name="O" value="" />
                <param name="C" value=""/>
            </dname>
        </genkey>
    </target>
 
    <!-- Sign's webstart/shade.jar for deployment. -->
    <target name="signjar" depends="keystore">
        <signjar jar="${webstart.dir}/shade.jar"
                 keystore="${target.dir}/${keystore.alias}.ks"
                 storepass="${keystore.pass}"
                 alias="${keystore.alias}" />
        <signjar jar="${webstart.dir}/crash.jar"
                 keystore="${target.dir}/${keystore.alias}.ks"
                 storepass="${keystore.pass}"
                 alias="${keystore.alias}" />
        <signjar jar="${webstart.dir}/slickfx.jar"
                 keystore="${target.dir}/${keystore.alias}.ks"
                 storepass="${keystore.pass}"
                 alias="${keystore.alias}" />
        <signjar jar="${webstart.dir}/BareBonesBrowserLaunch.jar"
                 keystore="${target.dir}/${keystore.alias}.ks"
                 storepass="${keystore.pass}"
                 alias="${keystore.alias}" />
    </target>
 
    <!-- Compile the code put results into obj.dir. -->
    <target name="compile">
        <mkdir dir="${obj.dir}" />
        <javac destdir="${obj.dir}" debug="on">
            <src path="${src.dir}" />
            <classpath>
                <pathelement path="${lib.dir}/slick.jar" />
                <pathelement path="${lib.dir}/lwjgl.jar" />
                <pathelement path="${lib.dir}/crash.jar" />
                <pathelement path="${lib.dir}/slickfx.jar" />
                <pathelement path="${lib.dir}/ibxm.jar" />
                <pathelement path="${lib.dir}/BareBonesBrowserLaunch.jar" />
            </classpath>
        </javac>
        <copy todir="${obj.dir}">
            <fileset dir="${res.dir}" />
        </copy>
    </target>
 
    <!-- Jar compiled code and place result into target.dir. -->
    <target name="archive">
        <jar destfile="${target.dir}/shade.jar" manifest="${script.dir}/manifest.txt">
            <fileset dir="${obj.dir}" />
        </jar>
    </target>
 
</project>