A un-official Battlesnake template written in Java.
Battlesnake documentation can be found at docs.battlesnake.io.
This template is different from the official Java Battlesnake.io Template in a few ways:
- GSON is used for JSON serialization rather than Jackson
- Pure Java Servlets are used rather than the Spark Framework
- Tomcat is used as the servlet container rather than Jetty which is used by default by Spark
- Gradle is used as the build tool rather than Maven
The official Java Template is also simpler and smaller however this template comes out-of-the-box with the following additional features:
- Logging support using Log4j2
- Logs server response time
- Code formatting, removing used imports using spotless
-
Install JDK 11 or higher
-
Install Docker + Docker compose (required for Docker container method)
-
Install Heroku CLI (required for Heroku CLI method)
-
Install .war Heroku deployment plug-in
heroku plugins:install heroku-cli-deploy
) (required for Heroku CLI method) -
Create a Heroku App online or using the Heroku CLI with
heroku create <name>
(alternatively any other hosting service can be used)
Online
Goto play.battlesnake.io
Gradle
- Run the project using either
./gradle run
orgradlew run
for UNIX and Windows platforms respectively. This will build and run the project as a `JAR` using Webapp Runner. - Use
http://localhost:8080
as the snake URL.
- Build the project using either
./gradle build
orgradlew build
for UNIX and Windows platforms respectively. - Run the Docker Tomcat image in a container with
docker-compose up
. - Use
http://localhost:8080/battlesnake
as the snake URL.
Heroku-GitHub Integration
- Go the dashboard for the Heroku app.
- Click on the
deploy
tab. - Scroll down to the
Deployment method
and selectGitHub
. - Enter the repository name and click
Connect
.
- Build .war file
./gradlew build
- Deploy to Heroku
heroku war:deploy build/libs/battlesnake.war --app <name>
- Use
https://[name].herokuapp.com/
as the snake URL.
- Built by Ben Austin and Jaxson Van Doorn
- Adapted from tflinz's snake
- Designed for Battlesnake.io competition