App can now be built using Ant and run from the JAR file.

Note: this requires adding the res/lib folder to the classpath in order to run in Eclipse (included in this commit).
Another commit will follow to remove build artifacts from git.
This commit is contained in:
Woody Folsom
2012-04-02 13:54:55 -04:00
parent 521fac6e08
commit 02c4986c30
10 changed files with 115 additions and 17 deletions

View File

@@ -1,6 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="res/img"/>
<classpathentry kind="src" path="test"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="lib/junit-4.10.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>

90
build.xml Normal file
View File

@@ -0,0 +1,90 @@
<project name="CS8803_P4" default="dist" basedir=".">
<description>
simple example build file
</description>
<!-- set global properties for this build -->
<property name="build" location="classes" />
<property name="dist" location="dist" />
<property name="docs" location="docs" />
<property name="lib" location="lib" />
<property name="project.name" value="CS8803_P4" />
<property name="res" location="res" />
<property name="src" location="src" />
<property name="test" location="test" />
<path id="build.classpath">
<fileset dir="${lib}">
<include name="**/*.jar" />
</fileset>
</path>
<path id="classpath.test">
<path refid="build.classpath" />
<pathelement location="lib/junit-4.10.jar" />
<pathelement location="${build}" />
</path>
<target name="clean" description="clean up">
<!-- Delete the ${build} and ${dist} directory trees -->
<delete dir="${build}" />
<delete dir="${dist}" />
</target>
<target name="compile" depends="copy-resources">
<!-- Compile the java code from ${src} into ${build} -->
<javac srcdir="${src}" destdir="${build}" classpathref="build.classpath" debug="true" source="1.6" target="1.6"/>
</target>
<target name="compile-test" depends="compile">
<javac srcdir="${test}" destdir="${build}" debug="true">
<classpath refid="classpath.test"/>
</javac>
</target>
<target name="copy-resources" depends="init" >
<copy todir="${build}">
<fileset dir="${res}">
<include name="**/*" />
</fileset>
</copy>
</target>
<target name="dist" depends="copy-resources, compile"
description="generate the distribution">
<jar jarfile="${dist}/${project.name}.jar">
<fileset dir="${build}" excludes="**/*Test.class" />
<manifest>
<attribute name="Main-Class" value="view.MainFrame" />
<!-- attribute name="Class-Path" value="../lib/antlr-3.4-complete-no-antlrv2.jar"/ -->
</manifest>
</jar>
</target>
<!-- Creates Javadoc -->
<target name="docs" depends="compile">
<javadoc packagenames="src" sourcepath="${src}" destdir="${docs}">
<!-- Define which files / directory should get included, we include all -->
<fileset dir="${src}">
<include name="**" />
</fileset>
</javadoc>
</target>
<target name="init">
<!-- Create the time stamp -->
<tstamp />
<!-- Create the build directory structure used by compile -->
<mkdir dir="${build}" />
</target>
<target name="test" depends="compile-test">
<junit haltonfailure="true">
<classpath refid="classpath.test" />
<formatter type="brief" usefile="false" />
<batchtest>
<fileset dir="${build}" includes="**/*Test.class" />
</batchtest>
</junit>
</target>
</project>

BIN
lib/junit-4.10.jar Normal file

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

View File

@@ -51,28 +51,22 @@ public class BoardPanel extends JPanel implements Refreshable {
}
public static final URL BLUE_ICON = ClassLoader
.getSystemResource("img/blue.png");
public static final URL BLUE_ICON = BoardPanel.class
.getResource("/img/blue.png");
public static final URL GREEN_ICON = BoardPanel.class
.getResource("/img/green.png");
public static final URL NONE_ICON = BoardPanel.class
.getResource("/img/none.png");
public static final URL RED_ICON = BoardPanel.class
.getResource("/img/red.png");
public static final URL YELLOW_ICON = BoardPanel.class
.getResource("/img/yellow.png");
public static final URL GREEN_ICON = ClassLoader
.getSystemResource("img/green.png");
public static final URL NONE_ICON = ClassLoader
.getSystemResource("img/none.png");
public static final URL RED_ICON = ClassLoader
.getSystemResource("img/red.png");
public static final URL YELLOW_ICON = ClassLoader
.getSystemResource("img/yellow.png");
/**
*
*/
private static final long serialVersionUID = 1L;
private final JLabel[][] board = new JLabel[Board.NUM_ROWS][Board.NUM_COLS];
private final Referee referee;
// private final ImageIcon[][] icons = new
// ImageIcon[Board.NUM_ROWS][Board.NUM_COLS];
public BoardPanel(Referee ref) {
referee = ref;
setLayout(new GridLayout(Board.NUM_ROWS, Board.NUM_COLS));

11
test/model/BoardTest.java Normal file
View File

@@ -0,0 +1,11 @@
package model;
import org.junit.Test;
public class BoardTest {
@Test
public void testConstructor() {
new Board();
}
}