JMRI Code: Building with Command Line ToolsThose of you who prefer a command line approach might want to investigate ant and maven, build utilities for Java projects. In the JMRI devlopment ecosystem, these two tools complement each other, each providing unique capabilities the other tool does not.
AntYou computer may already have Ant installed as part of a developer tools package. Try
ant -versionto check. JMRI requires at least version 1.10.6, and should work with any version after that.
If you need to install it, Ant is available for download at http://ant.apache.org/ or via the usual package managers.
- Create a directory to contain your project.
- In that project directory, get the code from GitHub. This will create a jmri subdirectory where Ant will run, and load it with source, tests and resources. It will also create and populate directories for xml, libraries, etc. in the project directory.
- Change to the newly created jmri subdirectory. To compile, type ant debug.
- To run the program, type ant decoderpro or ant panelpro, and sit back to watch it go.
- To run the test suite, type ant alltest.
- To build a jmri.jar file, type ant dist. Note that you don't have to create the jmri.jar file to run the program.
- To erase all previously compiled results and force the program to be entirely built from scratch, type ant clean.
To make sure everything is working, before you e.g. commit your code back, please do:
ant clean alltest
and make sure the tests run cleanly.
A new JMRI checkout should build cleanly. If not, please check with the JMRIusers or jmri-developers mailings lists for help.
MavenMaven is an extensible plugin-based build tool for Java development. Maven is available for download at http://maven.apache.org/. Maven will download the appropriate plugins and dependencies as needed. After installation, the following can be done from your JMRI working copy (see Getting the Code for instructions on creating a working copy):
- Run unit and integration tests
mvn test -Dtest=PATTERNto run specific tests. See Running a Single Test for more details, including running only a single test method.
- Check for vulnerabilities in JMRI dependencies
mvn compile net.ossindex:ossindex-maven-plugin:audit
- Check for newer versions of JMRI dependencies
- Check for newer versions of the maven plugins
- Run DecoderPro
mvn antrun:run -Danttarget=decoderpro
- Run PanelPro
mvn antrun:run -Danttarget=panelpro
scripts/mvn-testincludes all the options necessary to run the Travis CI test Maven job from your local command line.