@@ -8,20 +8,40 @@ Railway Interlocking Simulator - A BSc thesis project (2006/2007) from Brno Univ
88
99## Build System
1010
11- This project uses Apache Ant for building. Java 6 is required (` javac 1.6 ` ), with JUnit for testing.
11+ This project uses Apache Ant for building with Apache Ivy for dependency management. Java 6 is required (` javac 1.6 ` ).
12+
13+ ### Dependency Management
14+
15+ Dependencies are managed via Apache Ivy:
16+ - ** jDisco 1.2.0** - Discrete event simulation library (from Maven local repository)
17+ - ** JUnit 3.8.2** - Testing framework (from Maven Central)
18+
19+ Ivy automatically downloads dependencies during the build. Configuration files:
20+ - ` ivy.xml ` - Dependency declarations
21+ - ` ivysettings.xml ` - Repository resolver configuration
1222
1323### Common Build Commands
1424
15- ** Clean build:**
25+ ** Resolve dependencies:**
26+ ``` bash
27+ ant resolve
28+ ```
29+
30+ ** Clean build (includes dependency resolution and test execution):**
1631``` bash
1732ant clean build
1833```
1934
20- ** Build only:**
35+ ** Build only (compiles main code, tests, and runs tests) :**
2136``` bash
2237ant build
2338```
2439
40+ ** Run tests only:**
41+ ``` bash
42+ ant test
43+ ```
44+
2545** Run simulation (pre-configured shunting loop example):**
2646``` bash
2747ant start
@@ -37,28 +57,44 @@ ant run
3757ant doc
3858```
3959
60+ ** Clean everything including Ivy cache:**
61+ ``` bash
62+ ant clean-all
63+ ```
64+
65+ ### Directory Structure
66+
67+ The project follows Maven/Gradle standard directory layout:
68+ - ` src/main/java/ ` - Main source code
69+ - ` src/test/java/ ` - Test source code
70+ - ` src/main/resources/ ` - Resource files (XML schemas, examples)
71+ - ` build/main/ ` - Compiled main classes
72+ - ` build/test/ ` - Compiled test classes
73+ - ` lib/compile/ ` - Compile-time dependencies (jDisco)
74+ - ` lib/test/ ` - Test dependencies (JUnit)
75+
4076### Running Manually
4177
42- After building with ` ant build ` , run from the ` build/ ` directory :
78+ After building with ` ant build ` , run from the project root :
4379
4480** Simulation mode:**
4581``` bash
46- java -ea cz.vutbr.fit.interlockSim.Main sim [xmlFile]
82+ java -ea -cp " build/main:lib/compile/* " cz.vutbr.fit.interlockSim.Main sim [xmlFile]
4783```
4884
4985** Editor mode:**
5086``` bash
51- java -ea cz.vutbr.fit.interlockSim.Main edit [xmlFile]
87+ java -ea -cp " build/main:lib/compile/* " cz.vutbr.fit.interlockSim.Main edit [xmlFile]
5288```
5389
5490** Built-in examples:**
5591``` bash
56- java -ea cz.vutbr.fit.interlockSim.Main example [exampleName] [endTime]
92+ java -ea -cp " build/main:lib/compile/* " cz.vutbr.fit.interlockSim.Main example [exampleName] [endTime]
5793```
5894
5995To list available examples, run:
6096``` bash
61- java -ea cz.vutbr.fit.interlockSim.Main example
97+ java -ea -cp " build/main:lib/compile/* " cz.vutbr.fit.interlockSim.Main example
6298```
6399
64100** Note:** Enable assertions with ` -ea ` flag. For memory-constrained environments, add ` -Xmx300 ` .
@@ -127,11 +163,13 @@ docker compose build app
127163### Docker Architecture
128164
129165** Root Dockerfile (multi-stage build):**
130- 1 . ** Builder stage** - Uses ` caninjas/jdk6 ` with Ant
131- - Compiles Java sources
132- - Runs tests
133- - Creates JAR with all dependencies
134- 2 . ** Runner stage** - JRE 6 with X11 libraries
166+ 1 . ** Builder stage** - Uses Debian Buster with OpenJDK 11, Maven, and Ant
167+ - Builds jDisco dependency (Maven install)
168+ - Resolves dependencies via Apache Ivy (automatic download)
169+ - Compiles Java sources (Java 6 compatibility mode)
170+ - Runs all tests (build fails if tests fail)
171+ - Creates uber JAR with all dependencies
172+ 2 . ** Runner stage** - Debian Buster with OpenJDK 11 JRE and X11 libraries
135173 - Minimal runtime environment
136174 - X11 forwarding for GUI support
137175 - No build tools in final image
@@ -223,25 +261,32 @@ Both services copy build outputs to `/artifacts` inside the container, which is
223261
224262** XML Configuration:**
225263- Railway networks defined in XML format
226- - Schema: ` src/cz/vutbr/fit/interlockSim/resource/data.xsd `
227- - Example: ` src/cz/vutbr/fit/interlockSim/resource/vyhybna.xml `
264+ - Schema: ` src/main/resources/ cz/vutbr/fit/interlockSim/resource/data.xsd `
265+ - Example: ` src/main/resources/ cz/vutbr/fit/interlockSim/resource/vyhybna.xml `
228266- Elements include: RailSwitch, RailSemaphore, InOut (entry/exit points), track connections
229267
230268### Package Structure
231269
232270```
233- cz.vutbr.fit.interlockSim/
234- ├── Main.java - Application entry point
235- ├── context/ - Context management and factories
236- ├── gui/ - Graphical editor
237- ├── objects/ - Domain model (tracks, paths, cells)
238- ├── sim/ - Simulation scenarios
239- ├── test/ - Unit tests (JUnit)
240- ├── util/ - Utilities and reporting
241- ├── xml/ - XML parsing and serialization
242- └── resource/ - XML schemas and configuration files
243-
244- jDisco/ - Third-party discrete event simulation library
271+ src/
272+ ├── main/
273+ │ ├── java/cz/vutbr/fit/interlockSim/
274+ │ │ ├── Main.java - Application entry point
275+ │ │ ├── context/ - Context management and factories
276+ │ │ ├── gui/ - Graphical editor
277+ │ │ ├── objects/ - Domain model (tracks, paths, cells)
278+ │ │ ├── sim/ - Simulation scenarios
279+ │ │ ├── util/ - Utilities and reporting
280+ │ │ └── xml/ - XML parsing and serialization
281+ │ └── resources/cz/vutbr/fit/interlockSim/
282+ │ └── resource/ - XML schemas and configuration files
283+ └── test/
284+ └── java/cz/vutbr/fit/interlockSim/test/
285+ ├── TestArray2DMap.java - Array2DMap unit tests
286+ ├── TestCell.java - Cell unit tests
287+ └── TestContext.java - Context unit tests
288+
289+ jdisco/ - Third-party discrete event simulation library (separate module)
245290```
246291
247292## Code Style
@@ -265,14 +310,22 @@ This is a working historical codebase from 2007. Stability and preservation are
265310
266311## Testing
267312
268- JUnit tests located in ` cz.vutbr.fit.interlockSim.test/ ` . The ` junit.jar ` library is included in the repository root.
313+ JUnit 3.8.2 tests located in ` src/test/java/cz/vutbr/fit/interlockSim/test/ ` . JUnit is managed via Apache Ivy.
314+
315+ ** Current tests:**
316+ - ` TestArray2DMap ` - 10 tests for 2D array-based map implementation
317+ - ` TestCell ` - 2 tests for cell segment and direction logic
318+ - ` TestContext ` - 4 tests for railway network context operations
269319
270320** Run tests:**
271321``` bash
322+ ant test
323+ # Or as part of build:
272324ant build
273- # Tests run during build
274325```
275326
327+ Tests are automatically executed during the build process. The build will fail if any test fails (` haltonfailure="yes" ` ).
328+
276329## Documentation
277330
278331LaTeX-based thesis documentation in ` text/ ` directory.
0 commit comments