-
Notifications
You must be signed in to change notification settings - Fork 12
Developing a Java Module
It is highly recommended to read the Creating a Module -- Start to Finish guide that covers everything with explanations and screenshots.
Java modules are the most abundant modules for Toast. Java modules run the fastest, have the widest access, and can be packaged nice and neat into a .jar file to be transported.
Developing a Java module is very simple. First of all, download the HotPlate CLI. Once you've setup HotPlate on your OS, you can go ahead and run toast init
in your module directory and follow the prompts. This will setup your file structure for Toast and GradleRIO.
If you don't want to use HotPlate and want to manually setup your module, download the Toast Universal release from this repo and extract its contents. Edit the build.gradle
file to resemble your own settings and continue on. All future commands starting with toast
should instead start with gradlew.bat
on windows and ./gradlew
on unix (linux/mac).
Before you can get started writing java code, you need to setup your environment.
Eclipse users should run toast eclipse
and import the module directory as an existing project in eclipse.
IntelliJ Users should run toast idea
and double-click the .ipr
file to open IntelliJ to their Toast Project.
Now we can start writing your code. If you're using HotPlate, a class file has already been generated for you. Go ahead and edit this class file so that the robotInit()
method contains logger.info("Hello World!")
. This should make your Module Class print "Hello World!" to the console when your module is loaded.
HotPlate and Gradle automatically set run configurations for you. In Eclipse, the run configuration is called "{YourModule}-Sim", and in IntelliJ, it is called "{YourModule}-Sim" and is located under the "Launch" folder. Before you run this, make sure an empty folder called "run" exists in your Module Directory, as this is where Toast will store it's files.
Go ahead and launch the Run Configuration and your Simulation Environment should start right up. This is how you test your code before deploying it to the RoboRIO.
Deploying your Code is done by running the command gradlew deploy
. This will attempt to find your RoboRIO, copy the code over and run it. If you wish to deploy using a USB Stick (recommended), you must run gradlew build
and then copy the .jar file under build/libs/
to your USB Stick's toast directory.